### ButtonBox Example with Icon and Text Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/ControlBox/Other.md Use ButtonBox to create a button with an icon and text. This example shows a save button with a 'save.png' icon and '保存' text. ```xml ``` -------------------------------- ### Start GIF Playback Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/Control.md Starts playing a GIF animation. Allows specifying the frame to stop on and the number of playback cycles. ```cpp void StartGifPlayForUI(GifStopType frame = kGifStopFirst,int playcount = -1) ``` -------------------------------- ### Get Prompt Text (wstring) Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/RichEdit.md Retrieves the prompt text as a wide string. ```cpp std::wstring GetPromptText() ``` -------------------------------- ### StartGifPlayForUI Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/Control.md Initiates the playback of a GIF animation for the UI. Allows control over the starting frame and playback count. ```APIDOC ## StartGifPlayForUI ### Description Plays a GIF animation. ### Method void ### Parameters #### Parameters - **frame** (GifStopType) - Optional - Description: The frame to stop at after playback. Defaults to kGifStopFirst. - **playcount** (int) - Optional - Description: The number of times to play the GIF. Defaults to -1 (infinite). ### Return Value None ``` -------------------------------- ### GetPromptText Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/RichEdit.md Gets the prompt text. ```APIDOC ## GetPromptText ### Description Gets the prompt text. ### Method ```cpp std::wstring GetPromptText() ``` ### Parameters None ### Returns - (std::wstring) - The prompt text content. ``` -------------------------------- ### Get Background Image Path Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/Control.md Retrieves the file path of the background image. ```cpp std::wstring GetBkImage() ``` -------------------------------- ### Get Initial Window Size Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/Window.md Retrieves the window's size when it is first created, optionally including shadow. ```cpp CSize GetInitSize(bool bContainShadow = false) ``` -------------------------------- ### GetUTF8PromptText Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/RichEdit.md Gets the prompt text in UTF8 format. ```APIDOC ## GetUTF8PromptText ### Description Gets the prompt text in UTF8 format. ### Method ```cpp std::string GetUTF8PromptText() ``` ### Parameters None ### Returns - (std::string) - The prompt text content in UTF8 format. ``` -------------------------------- ### Get Height Percent Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/Window.md Retrieves the initial height of the window as a percentage of the screen height. ```cpp double GetHeightPercent() ``` -------------------------------- ### Get Prompt Text (string UTF8) Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/RichEdit.md Retrieves the prompt text encoded as a UTF-8 string. ```cpp std::string GetUTF8PromptText() ``` -------------------------------- ### GetWinStyle Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/RichEdit.md Gets the window style of the control. Returns the window style value. ```APIDOC ## GetWinStyle ### Description Gets the window style of the control. ### Method ```cpp LONG GetWinStyle() ``` ### Parameters None ### Returns - LONG: Returns the window style. ``` -------------------------------- ### Get Skin File Path Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Utils/WindowImplBase.md Retrieves the path to the skin XML file used by the window. This file defines the window's appearance and layout. ```cpp virtual std::wstring GetSkinFile() ``` -------------------------------- ### Get Size Box Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/Window.md Retrieves the dimensions defining the resizable borders of the window. ```cpp UiRect GetSizeBox() ``` -------------------------------- ### Get Text Content Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/RichEdit.md Retrieve the plain text content of the RichEdit control. ```cpp std::wstring GetText() ``` -------------------------------- ### Create and Display a Basic Window Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/GETTING-STARTED.md Initializes the framework, creates a new window instance, and displays it centered on the screen. Ensure the window header file is included before creating the window. ```cpp void MainThread::Init() { nbase::ThreadManager::RegisterThread(kThreadUI); // 获取资源路径,初始化全局参数 // 默认皮肤使用 resources\themes\default // 默认语言使用 resources\lang\zh_CN // 如需修改请指定 Startup 最后两个参数 std::wstring theme_dir = QPath::GetAppPath(); ui::GlobalManager::Startup(theme_dir + L"resources\", ui::CreateControlCallback(), false); // 创建一个默认带有阴影的居中窗口 BasicForm* window = new BasicForm(); window->Create(NULL, BasicForm::kClassName.c_str(), WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX, 0); window->CenterWindow(); window->ShowWindow(); } ``` -------------------------------- ### GetSel (long) Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/RichEdit.md Gets the start and end character positions of the selected text. The positions are returned via reference parameters. ```APIDOC ## GetSel (long) ### Description Gets the start and end character positions of the selected text. ### Method ```cpp void GetSel(long& nStartChar, long& nEndChar) ``` ### Parameters - **nStartChar** (long&) - Output - The starting position of the selection. - **nEndChar** (long&) - Output - The ending position of the selection. ``` -------------------------------- ### Get Tooltip Window Handle Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/Window.md Retrieves the window handle associated with tooltip information. ```cpp HWND GetTooltipWindow() ``` -------------------------------- ### OnCreate Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Utils/WindowImplBase.md Handles the window creation message. Use InitWindow to implement custom window initialization. ```APIDOC ## OnCreate ### Description Handles the window creation message. Use InitWindow to implement custom window initialization. ### Method `LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)` ### Parameters #### Path Parameters - **uMsg** (UINT) - Message ID - **wParam** (WPARAM) - Additional message parameters - **lParam** (LPARAM) - Additional message parameters - **bHandled** (BOOL&) - Whether the message has already been processed. ### Response #### Success Response - **Return Value** (LRESULT) - The result of message processing. ``` -------------------------------- ### GetSel (CHARRANGE) Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/RichEdit.md Gets the start and end positions of the selected text using a CHARANGE structure. The structure will be populated with the selection range. ```APIDOC ## GetSel (CHARRANGE) ### Description Gets the start and end positions of the selected text using a CHARANGE structure. ### Method ```cpp void GetSel(CHARRANGE &cr) ``` ### Parameters - **cr** (CHARRANGE&) - Output - A CHARANGE structure that will be populated with the start and end positions of the selection. ``` -------------------------------- ### Get Maximize Info Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/Window.md Retrieves the information defining the window's maximized state. ```cpp UiRect GetMaximizeInfo() ``` -------------------------------- ### Init Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/Control.md Initializes the control. ```APIDOC ## Init ### Description Initializes the control. ### Method ```cpp virtual void Init() ``` ### Parameters None ``` -------------------------------- ### Get Selected Text Range (CHARRANGE) Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/RichEdit.md Retrieve the start and end positions of the currently selected text using a CHARANGE structure. ```cpp void GetSel(CHARRANGE &cr) ``` -------------------------------- ### Get Shadow Corner Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/Window.md Retrieves the nine-grid description for the shadow's border. ```cpp UiRect GetShadowCorner() ``` -------------------------------- ### Get Selected Text Range (long) Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/RichEdit.md Retrieve the start and end character positions of the currently selected text as separate long integers. ```cpp void GetSel(long& nStartChar, long& nEndChar) ``` -------------------------------- ### Handle Window Creation Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Utils/WindowImplBase.md Handles the WM_CREATE message, which is sent when the window is first created. Use InitWindow for initialization logic. ```cpp LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) ``` -------------------------------- ### GetText Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/RichEdit.md Gets the text content of the control. Returns the text as a wide string. ```APIDOC ## GetText ### Description Gets the text content of the control. ### Method ```cpp std::wstring GetText() ``` ### Parameters None ### Returns - std::wstring: Returns the text content of the control. ``` -------------------------------- ### Init Method Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/Control.md Initializes the control. This is a virtual method intended to be overridden by derived classes. ```cpp virtual void Init() ``` -------------------------------- ### DoInit Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/Control.md Called by Init, this function has the same functionality as Init. ```APIDOC ## DoInit ### Description Called by Init, this function has the same functionality as Init. ### Method ```cpp virtual void DoInit() ``` ### Parameters None ``` -------------------------------- ### Get Text Length with Flags Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/RichEdit.md Get the length of the text in the RichEdit control, with options to specify how the length is determined using flags. ```cpp long GetTextLength(DWORD dwFlags = GTL_DEFAULT) ``` -------------------------------- ### Set Initial Window Size Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/Window.md Sets the initial width and height of the window, with options for shadow inclusion and DPI scaling. ```cpp void SetInitSize(int cx, int cy, bool bContainShadow = false, bool bNeedDpiScale = true) ``` -------------------------------- ### GetCaretRect Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/RichEdit.md Gets the rectangular position of the caret. ```APIDOC ## GetCaretRect ### Description Gets the rectangular position of the caret. ### Method ```cpp RECT GetCaretRect() ``` ### Parameters None ### Returns - (RECT) - The rectangular position of the caret. ``` -------------------------------- ### Get Skin Folder Path Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Utils/WindowImplBase.md Retrieves the path to the skin folder used by the window. This is typically the directory containing skin resources. ```cpp virtual std::wstring GetSkinFolder() ``` -------------------------------- ### GetCaretColor Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/RichEdit.md Gets the current color of the caret. ```APIDOC ## GetCaretColor ### Description Gets the current color of the caret. ### Method ```cpp std::wstring GetCaretColor() ``` ### Parameters None ### Returns - (std::wstring) - The current caret color. ``` -------------------------------- ### ActiveWindow Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Utils/WindowImplBase.md Activates the window. ```APIDOC ## ActiveWindow ### Description Activates the window. ### Method `virtual void ActiveWindow()` ### Response #### Success Response - **Return Value** (void) - This method does not return a value. ``` -------------------------------- ### GetSkinFile Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Utils/WindowImplBase.md Retrieves the skin XML file path. This method should be implemented to get the actual skin XML file. ```APIDOC ## GetSkinFile ### Description Retrieves the skin XML file path. This method should be implemented to get the actual skin XML file. ### Method `virtual std::wstring GetSkinFile()` ### Response #### Success Response - **Return Value** (std::wstring) - The path to the skin XML file. ``` -------------------------------- ### SetInitSize Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/Window.md Sets the initial size of the window when it is first created. This method also allows for DPI scaling adjustments. Takes width (cx), height (cy), and optional booleans for shadow inclusion and DPI scaling. ```APIDOC ## SetInitSize ### Description Sets the initial size of the window. ### Parameters #### Path Parameters - **cx** (int) - Required - The initial width. - **cy** (int) - Required - The initial height. - **bContainShadow** (bool) - Optional - If false, cx and cy do not include shadow dimensions; defaults to false. - **bNeedDpiScale** (bool) - Optional - If false, the size is not adjusted for DPI scaling; defaults to true. ``` -------------------------------- ### GetFocusedImage Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Controls/RichEdit.md Gets the image displayed when the control has focus. ```APIDOC ## GetFocusedImage ### Description Gets the image displayed when the control has focus. ### Method ```cpp std::wstring GetFocusedImage() ``` ### Parameters None ### Returns - (std::wstring) - The path to the focused image. ``` -------------------------------- ### Application Title Bar with HBox Source: https://github.com/netease-im/nim_duilib_framework/blob/master/docs/Containers/HBox.md An example of a standard application title bar using HBox for horizontal arrangement. It includes minimize, maximize/restore, and close buttons, with a flexible space at the beginning. ```xml