CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2010
    Location
    Romania
    Posts
    8

    Lightbulb GetMessage() questions

    Hi,

    I want to write a program that listens for a window action (creates a window or closes a window) and when a window is created i get new window handle in an HWND array and remove it when i close the window.
    By now i'm able to retrieve the main window handle and i guess i have to use the GetMessage() function, something like this;

    HWND parent = FindWindow(NULL,"Main Window Name");
    MSG msg;

    while (GetMessage(&msg, parent, 0, 0))
    {
    if (msg.message == WM_CREATE )
    MessageBox(NULL,"new window","Message:",MB_OK);

    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }

    Please give me some suggestions or at least point me to some good tutorials.
    PS: i'm really new with win32 programming ...

    Thank you.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: GetMessage() questions

    Are you referring to a window action within your application or another process?

  3. #3
    Join Date
    Sep 2010
    Location
    Romania
    Posts
    8

    Re: GetMessage() questions

    I'm referring to a window from another application, i read what i could find on codeguru yesterday and i understand that i have to make it with hooks, which right now look kind of complicated. I understood a bit of how they work, but they are still pretty blurry. Actually my software is intended to click on a button when it appears on some specific windows so i guess that if i find the message that the window sends when the button appears i could intercept this message with a hook and click on the button in the window although it's in background ( i made the function for clicks with PostMessage and it works).
    Do you have any suggestions ? Is this possible ?
    thank you

  4. #4
    Join Date
    Sep 2010
    Location
    Romania
    Posts
    8

    Re: GetMessage() questions

    i played around with Spy++ over the window that i have to post the click to an i filtered the messages and i came up with this:
    00031084 P message: 0x0118 [Unknown] wParam:0000FFF8 lParam:97B03836
    after this message has appeared for 4 times in a row, i have to click on the button.
    is there any way i can use this ?

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: GetMessage() questions

    Do you have any suggestions ? Is this possible ?
    Not with GetMessage. GetMessage is intended to process messages from the message queue belonging to current thread. So, in your case there's nothing left but hooks.
    Best regards,
    Igor

  6. #6
    Join Date
    Sep 2010
    Location
    Romania
    Posts
    8

    Re: GetMessage() questions

    yes, i posted that before i found out about hooks ...

    so for that type of message, what hook procedure could be used ?
    the message is : 00031084 P message: 0x0118 [Unknown] wParam:0000FFF8 lParam:97B03836
    i'm thinking WH_CALLWNDPROC ... maybe you could direct me to some examples with the exact hook i need ... because all i found is about keyboard hooking

  7. #7
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: GetMessage() questions

    Quote Originally Posted by rzv View Post
    yes, i posted that before i found out about hooks ...

    so for that type of message, what hook procedure could be used ?
    the message is : 00031084 P message: 0x0118 [Unknown] wParam:0000FFF8 lParam:97B03836
    i'm thinking WH_CALLWNDPROC ... maybe you could direct me to some examples with the exact hook i need ... because all i found is about keyboard hooking
    Have you tried searching for "window hooking"?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured