Created
March 17, 2015 05:27
-
-
Save qiuchengxuan/6ae947cd1f6d1fff1a49 to your computer and use it in GitHub Desktop.
MFC message only invisible window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
HWND CreateMessageOnlyWindow(HINSTANCE hInstance) | |
{ | |
WNDCLASSEX wx = {}; | |
wx.cbSize = sizeof(WNDCLASSEX); | |
wx.lpfnWndProc = WndProc; | |
wx.hInstance = hInstance; | |
wx.lpszClassName = L"Message-Only Window"; | |
wx.style=0; | |
wx.cbClsExtra = wx.cbWndExtra = 0; | |
wx.hIcon = NULL; | |
wx.hCursor = NULL; | |
wx.hbrBackground = NULL; | |
wx.lpszMenuName = NULL; | |
wx.hIconSm=NULL; | |
if ( RegisterClassEx(&wx) ) | |
return CreateWindow(L"Message-Only Window", NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_MESSAGE, NULL, NULL, NULL); | |
else | |
return NULL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment