有没有办法将 Windows 10 win32 / gdi++ GUI 程序的样式更改为 Windows 95?
Is there a way of changing the style of a Windows 10 win32 / gdi++ GUI program into Windows 95?
Windows95主题:
Windows 10个主题:
Windows 95 主题外观绝对适合我的程序。有没有办法使用编写程序的 Win32 API 和 GDI+ 来做到这一点?
您可以使用SetWindowTheme函数
- 包括
- 在
Properties->Linker->Input->Additional Dependencies
中添加对 uxtheme.lib 的依赖。
- 创建 window 后调用
SetWindowTheme(hwnd, L" ", L" ");
。
示例如下:
#include <windows.h>
#include <Uxtheme.h>
LPCWSTR g_szClassName = L"myWindowClass";
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassEx(&wc))
{
MessageBox(NULL, L"Window Registration Failed!", L"Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
hwnd = CreateWindow(
g_szClassName,
L"The title of my window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 600, 600,
NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
SetWindowTheme(hwnd, L"", L"");
while (GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
输出:
编辑:
可以参考Visual Styles
,and in What's New
:
Through Windows 7, visual styles are on by default but the user can turn them off by selecting Windows Classic theme or by turning off the Themes service. When visual styles are off, all UI gets the classic look, and most visual styles APIs are not available. Visual styles off mode has been retained through Windows 7 to support the various high contrast themes, as well as Windows Classic theme. If you want to support both visual styles and high contrast themes in the same application, you typically need to maintain two separate code paths for rendering controls.
如果你想enable visual styles。
Windows95主题:
Windows 10个主题:
Windows 95 主题外观绝对适合我的程序。有没有办法使用编写程序的 Win32 API 和 GDI+ 来做到这一点?
您可以使用SetWindowTheme函数
- 包括
- 在
Properties->Linker->Input->Additional Dependencies
中添加对 uxtheme.lib 的依赖。 - 创建 window 后调用
SetWindowTheme(hwnd, L" ", L" ");
。
示例如下:
#include <windows.h>
#include <Uxtheme.h>
LPCWSTR g_szClassName = L"myWindowClass";
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassEx(&wc))
{
MessageBox(NULL, L"Window Registration Failed!", L"Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
hwnd = CreateWindow(
g_szClassName,
L"The title of my window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 600, 600,
NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
SetWindowTheme(hwnd, L"", L"");
while (GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
输出:
编辑:
可以参考Visual Styles
,and in What's New
:
Through Windows 7, visual styles are on by default but the user can turn them off by selecting Windows Classic theme or by turning off the Themes service. When visual styles are off, all UI gets the classic look, and most visual styles APIs are not available. Visual styles off mode has been retained through Windows 7 to support the various high contrast themes, as well as Windows Classic theme. If you want to support both visual styles and high contrast themes in the same application, you typically need to maintain two separate code paths for rendering controls.
如果你想enable visual styles。