SendMessage Hwnd, WM_HELP, 0, 0

  • 18 years ago


    Some time ago I created an overlay that works on every titelbar for whatever application is active. It has a minimize, maximize, restore and close button that works. What I use for this is:

    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    PostMessage Hwnd, WMCLOSE, 0, 0

    And of course SW
    The problem is that the Help button is not working. That is the question mark in the title bar. For a sample right click on your desktop and show the properties.

    You would think that the code:

    SendMessage lastHwnd, WM_HELP, 0, 0

    should work but it is not. Even the function:
    Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
    SetForegroundWindow Hwnd

    Does not help.

    full working code of this can be found here on Planet Source Code. In the menu it's the 'Active titlebar tickertape demo' And in the source code just  look at frmBrowser. It's the code under the question mark that is not working.

  • 18 years ago

    according to this:

    it should work... but hey if it doesnt then hmmm....

    the reason is that (thanks to james for pointing this out) that your not parsing the HELPINFO structure:


    Private Type POINTTYPE
       x As Long
       y As Long
    End Type
     cbsize As Long
     icontexttype As Long
     ictrlId As Long
     hitemhandle As Long
     dwcontextId As Long
     mousepos As POINT
    End Type
    Const HELPINFO
    WINDOW = 1

    the above was converted from:

    now try it again... looking at this page:

    thanks to the MSDN Library/Platform SDK!

  • 18 years ago


    This does not do what I expected. It's one step away from it.
    Apperently the WMHELP message works on a control and not a window.
    It will show the helpmessage for a control.
    What I want is what happens when you press the question mark in the title bar.
    It's probably a different WM
    message. I will look around.


  • 18 years ago

    damm i hate when that happens..

    its not a bug(from Microsoft) from what i can see...

  • 18 years ago

    Yes, but it's still strange.
    You have the WMClose that is a button in the title bar, the SWMINIMIZE, ...
    So where is the help?

  • 18 years ago

    I still can't find the simple solution.
    Maybe this will help but that will take some time:
    Capture the mouse
    change the cursor to the question mark with arrow.
    On mous click send the WM_HELP to whatever is under the mouse.

    Maybe I can find the window when i subclass a window.
    I will try that first.

  • 18 years ago

    Guess it does not work like this.
    When I subclass a window and use the folowing code to filter out some messages


    Const WMNCHITTEST = 132
    If uMsg = WM
    NCHITTEST Then Exit Sub

    Const WMMOUSEMOVE = 512
    If uMsg = WM
    MOUSEMOVE Then Exit Sub

    Const WMSETCURSOR = 32
    If uMsg = WM
    SETCURSOR Then Exit Sub

    Const WMNCMOUSEMOVE = 160
    If uMsg = WM
    NCMOUSEMOVE Then Exit Sub

    debug.print uMsg

    If uMsg = WM

    Then you will see that there are no other windows messages.

    So as I said the only solution is:
    change the cursor
    use SetCapture for keeping track of the mous
    on the mouse click the hwnd of the control below it
    send the WM_Help to the control using the structure pointed out by Thushan.

    Or does anyone else has an other sugestion?

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook