Simple simulation of styles
#define UNICODE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD);
TCHAR *szAppName = TEXT("WinExStyle");
TCHAR *szFrameClass = TEXT("cWinFrame");
HWND hFrame;
int nStyle;
struct _tWinStyles {
DWORD dwStyle;
TCHAR *Name;
} WinStyles[] = {
{WS_EX_CLIENTEDGE,TEXT("WS_EX_CLIENTEDGE")},
{WS_EX_DLGMODALFRAME,TEXT("WS_EX_DLGMODALFRAME")},
{WS_EX_STATICEDGE,TEXT("WS_EX_STATICEDGE")},
{WS_EX_WINDOWEDGE,TEXT("WS_EX_WINDOWEDGE")},
{WS_EX_TOOLWINDOW,TEXT("WS_EX_TOOLWINDOW")},
{WS_EX_PALETTEWINDOW,TEXT("WS_EX_PALETTEWINDOW")},
{0, TEXT("NONE")},
};
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wcx;
MSG msg;
wcx.cbSize = sizeof(WNDCLASSEX);
wcx.style = CS_HREDRAW | CS_VREDRAW;
wcx.lpfnWndProc = (WNDPROC) WndProc;
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
wcx.hInstance = hInstance;
wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
wcx.hbrBackground= (HBRUSH)COLOR_3DSHADOW;
wcx.lpszMenuName = NULL;
wcx.lpszClassName= szFrameClass;
wcx.hIconSm = 0;
if (!RegisterClassEx(&wcx))
return 0;
hFrame = CreateWindowEx(0, szFrameClass, szAppName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
300, 100,
NULL, NULL, hInstance, NULL);
if(!hFrame) return 0;
ShowWindow(hFrame, nCmdShow);
UpdateWindow(hFrame);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg) {
case WM_CREATE:
SetTimer(hWnd, 1, 2000, TimerProc);
return 0;
case WM_DESTROY:
KillTimer(hWnd, 1);
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
VOID CALLBACK TimerProc( HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
SetWindowText(hWnd, WinStyles[nStyle].Name);
SetWindowLongPtr(hWnd, GWL_EXSTYLE, WinStyles[nStyle].dwStyle);
ShowWindow(hWnd, SW_HIDE);
ShowWindow(hWnd, SW_SHOW);
HDC hDC = GetDC(hWnd);
TextOut(hDC, 5, 5, WinStyles[nStyle].Name, lstrlen(WinStyles[nStyle].Name));
ReleaseDC(hWnd, hDC);
if (++nStyle >= sizeof(WinStyles)/sizeof(WinStyles[0]))
nStyle = 0;
}