『第 22 楼』:
微软的技术支持
使用 LLM 解释/回答一下
要确保您的应用程序在 Windows XP 中使用新的外观风格,您需要使用一个声明来指定对 ComCtl32 版本 6 的依赖,从而确保链接到 ComCtl32。如果您有任何自行绘制的控件,那么今后要通过 uxtheme.dll 来绘制它们,而不是自己绘制。如果您想让它们看起来和 UI 的其他部分相似,就应该这样做。
下面这段代码绘制可识别主题的按钮:
rtButton.top = 100;
rtButton.left = 10;
rtButton.bottom = 130;
rtButton.right = 200;
hTheme = OpenThemeData(hWnd, L"Button");
DrawThemeBackground(hTheme, hdc, BP_PUSHBUTTON, PBS_NORMAL, &rtButton, NULL);
DrawThemeText(hTheme, hdc, BP_PUSHBUTTON, PBS_NORMAL, wzTMB, wcslen(wzTMB),
DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS | DT_SINGLELINE, 0, &rtButton);
创建自行绘制的按钮的一个常见原因是想添加位图。现在,ComCtl32 版本 6 的按钮通过与一个图象列表相关联,能够结合开发人员提供的位图。无论您是更新现有应用程序,还是编写新应用程序,一定要用 ComCtl32 版本 6 声明和版本 5 测试您的应用程序,看看您的窗口、对话框和新外观放在一起效果如何。
下面的代码绘制带位图的按钮:
Button_ImageList.himl = himl;
Button_ImageList.uAlign = BUTTON_IMAGELIST_ALIGN_LEFT;
Button_ImageList.margin.top = 3;
Button_ImageList.margin.bottom = 3;
Button_ImageList.margin.left = 3;
Button_ImageList.margin.right = 3;
hwndImageBtn = CreateWindow(L"Button",wzText,WS_CHILD | BS_PUSHBUTTON,0,0,0,0,hWndParent,NULL,hInst,NULL);
Button_SetImageList(hwndImageBtn, &Button_ImageList);
Button_GetIdealSize(hwndImageBtn, &sizeBtn);
SetWindowPos(hwndImageBtn, hWndParent, 10, 10, sizeBtn.cx, sizeBtn.cy, SWP_SHOWWINDOW | SWP_NOZORDER | SWP_NOACTIVATE);
To ensure your application uses the new appearance style in Windows XP, you need a declaration to specify the dependency on ComCtl32 version 6 to ensure linking to ComCtl32. If you have any self-drawn controls, in the future you should draw them through uxtheme.dll instead of drawing them yourself. You should do this if you want them to look similar to other parts of the UI.
The following code draws a theme-aware button:
rtButton.top = 100;
rtButton.left = 10;
rtButton.bottom = 130;
rtButton.right = 200;
hTheme = OpenThemeData(hWnd, L"Button");
DrawThemeBackground(hTheme, hdc, BP_PUSHBUTTON, PBS_NORMAL, &rtButton, NULL);
DrawThemeText(hTheme, hdc, BP_PUSHBUTTON, PBS_NORMAL, wzTMB, wcslen(wzTMB),
DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS | DT_SINGLELINE, 0, &rtButton);
A common reason for creating a self-drawn button is to add a bitmap. Now, buttons in ComCtl32 version 6 can incorporate bitmaps provided by developers by associating with an image list. Whether you are updating an existing application or writing a new one, be sure to use the ComCtl32 version 6 declaration and test your application with version 5 to see how your windows, dialogs, and the new appearance work together.
The following code draws a button with a bitmap:
Button_ImageList.himl = himl;
Button_ImageList.uAlign = BUTTON_IMAGELIST_ALIGN_LEFT;
Button_ImageList.margin.top = 3;
Button_ImageList.margin.bottom = 3;
Button_ImageList.margin.left = 3;
Button_ImageList.margin.right = 3;
hwndImageBtn = CreateWindow(L"Button",wzText,WS_CHILD | BS_PUSHBUTTON,0,0,0,0,hWndParent,NULL,hInst,NULL);
Button_SetImageList(hwndImageBtn, &Button_ImageList);
Button_GetIdealSize(hwndImageBtn, &sizeBtn);
SetWindowPos(hwndImageBtn, hWndParent, 10, 10, sizeBtn.cx, sizeBtn.cy, SWP_SHOWWINDOW | SWP_NOZORDER | SWP_NOACTIVATE);
|