winapi - How to handle the message-only window to get the messages from the console window? -


i'm trying know when console window has moved created new message-only window messages of console don't know if working because message apparently never being received.

#define winver 0x0501 #include <windows.h> #include <iostream>  wndproc glpfnconsolewindow; // new using namespace std;  lresult apientry mainwndproc(hwnd hwnd, uint umsg, wparam wparam, lparam lparam) {     switch (umsg)     {         case wm_size:         cout<<"window moved"<<endl;         break;         case wm_destroy:         postquitmessage(0);         break;         default:         // new         return callwindowproc(glpfnconsolewindow, hwnd, umsg, wparam, lparam);         //return defwindowproc(hwnd, umsg, wparam, lparam);     } }  int winapi winmain(hinstance hinstance, hinstance hprevinstance,     lpstr lpcmdline, int ncmdshow) {     hwnd hwnd;     msg msg;     const char lpcszclassname[] = "messageclass";     wndclassex  windowclassex;      // == new     hwnd conshwnd;     conshwnd = getconsolewindow();     glpfnconsolewindow = (wndproc)setwindowlong(conshwnd, gwl_wndproc, (long)mainwndproc);     // ==      zeromemory(&windowclassex, sizeof(wndclassex));     windowclassex.cbsize        = sizeof(wndclassex);     windowclassex.lpfnwndproc   = mainwndproc;     windowclassex.hinstance     = hinstance;     windowclassex.lpszclassname = lpcszclassname;      if (registerclassex(&windowclassex) != 0)     {         // create message-only window     hwnd = createwindowex(0, lpcszclassname, null, 0, 0, 0, 0, 0, hwnd_message, null, hinstance, null);         if (hwnd != null)         cout<<"window created"<<endl;         else         unregisterclass(lpcszclassname, hinstance);     }     showwindow(hwnd,ncmdshow);     while(getmessage(&msg, null, 0, 0) > 0)     {         translatemessage(&msg);         dispatchmessage(&msg);     }      return (int)msg.wparam; } 

perhaps should process wm_move, which, according documentation, sent after window has been moved. wm_size sent when size changes.

i think problem wm_move , wm_size messages going console window rather hidden window.

i suspect you'll have call getconsolewindow console window handle, , call setwindowlong attach window proc console window. sure pass messages on original window proc.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -