c++ - How to receive messages using a message-only window in a console application? -


i've created simple win32 console application creates hidden message-only window , waits messages, full code below.

#include <iostream> #include <windows.h>  namespace {   lresult callback windowprocedure(hwnd hwnd, uint umsg, wparam wparam, lparam lparam)   {     if (umsg == wm_copydata)       std::cout << "got message!" << std::endl;     return defwindowproc(hwnd, umsg, wparam, lparam);   } }  int main() {   wndclass windowclass = {};   windowclass.lpfnwndproc = windowprocedure;   lpcwstr windowclassname = l"foobarmessageonlywindow";   windowclass.lpszclassname = windowclassname;   if (!registerclass(&windowclass)) {     std::cout << "failed register window class" << std::endl;     return 1;   }   hwnd messagewindow = createwindow(windowclassname, 0, 0, 0, 0, 0, 0, hwnd_message, 0, 0, 0);   if (!messagewindow) {     std::cout << "failed create message-only window" << std::endl;     return 1;   }    msg msg;   while (getmessage(&msg, 0, 0, 0) > 0) {     translatemessage(&msg);     dispatchmessage(&msg);   }   return msg.wparam; } 

however, i'm not receiving messages application. getmessage() blocks , never returns. use findwindowex() same class name in application sends message, , finds window. message apparently never being received.

am doing wrong here? minimal application can receive window messages?

your messages may blocked user interface privilege isolation. in case can use changewindowmessagefilterex() function allow wm_copydata message through.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -