How can you create a window without caption and border using CreateWindowEx()? And I why do you use '|' OR operator to combine styles instead of '&' And?
A:
int WINAPI WinMain(....)
{
MSG msg;
WNDCLASS wc={0};
wc.lpszClassName="MyClass";
wc.lpfnWndProc=DefWindowProc;//You MUST use your own wndproc here
wc.hInstance=hInstance;
wc.hbrBackground=(HBRUSH)(COLOR_3DFACE+1);
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
if (!RegisterClass(&wc)) {/*Handle Error*/}
HWND hwnd;
hwnd=CreateWindowEx(0,wc.lpszClassName,0,WS_POPUP|WS_VISIBLE|WS_SYSMENU,9,9,99,99,0,0,0,0);
if (!hwnd) {/*Handle Error*/}
while(GetMessage(&msg,0,0,0)>0)DispatchMessage(&msg);
return 0;
}
If you want a border, you can add WS_BORDER or WS_DLGFRAME (Not both). If you don't want to show the window in the taskbar, add the WS_EX_TOOLWINDOW extended style.
As to why you need to bitwise OR the styles; OR will combine all the style values, AND is used (by windows) to check which styles are set. Say we had two styles (WS_FOO=1,WS_BAR=2):
- 1 AND 2 = 0 (Binary: 01 AND 10 = 00)
- 1 OR 2 = 3 (Binary: 01 OR 10 = 11)
See wikipedia for more info.
Anders
2010-08-22 14:38:38