[c++ windows]capturing mouse click event from a window that isn't mine

468 Views Asked by At

I want to detect when the mouse is pressed on my wallpaper. So I got the wallpaper handle and now I'm trying to add a message loop to it, but its not working for some reason.

Here's my code so far:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow)
{
    HWND hWallPaper = getWallPaperHWND();

    if (hWallPaper != NULL)
    {

        MSG msg;
        while (GetMessage(&msg, hWallPaper, 0, 0))
        {
            MessageBox(NULL, "msg", "got message", MB_OK);
        }


    }
    else
        MessageBox(NULL,"Window wasn't found","window not found",MB_OK);
    return 0;
}

Why isn't it showing a message box when I fire an even on the wallpaper, like when I click on it or even just move the mouse?

0

There are 0 best solutions below