Skip to content

Instantly share code, notes, and snippets.

@qiuchengxuan
Created March 17, 2015 05:27
Show Gist options
  • Save qiuchengxuan/6ae947cd1f6d1fff1a49 to your computer and use it in GitHub Desktop.
Save qiuchengxuan/6ae947cd1f6d1fff1a49 to your computer and use it in GitHub Desktop.
MFC message only invisible window
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