#include <iostream>
#include <windows.h>
using namespace std;
//This is our message callback
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int main()
{
//Create window class
WNDCLASS wc;
memset(&wc, 0, sizeof(wc));
wc.cbSize = sizeof(wc);
wc.lpfnWndProc = WndProc;
wc.lpszClassName = "myWindowClass";
RegisterClass(&wc);
//Create window (uses HWND_MESSAGE as the parent window to create message only window)
HWND window = CreateWindow(szWndClass, "HotkeyMesageWindow", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL);
if(!window)
{
cerr << "Can't create window!" << endl;
exit(1);
}
// Main message loop:
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
DON'T use this code exactly, It will need adjusted to use peek message. Right now it's waiting for the user to click the 'x' which you won't have on your message only window. I'll get back to you later with better code.