Link to home
Start Free TrialLog in
Avatar of develc
develcFlag for Germany

asked on

Getting the right wNotifyCommands using the user32.dll

Hello,

I try to handle a window automatically.
With Spy++ I already found out the right lParam and the WM_Command Code.
But if I monitor the window - the wNotifyCode is wrong.
I've to send a BN_CLICKED WM_Command but with my routine I send a Code 0 (send from a menue) Message.

Is there anywhere a documentation where the wNotifyCommands are explained?
Is there a way to calculate them?
Did anybody already handle a window with a BN_CLICKED Message?

I would be gratefully for every advice.
Thanks.
develc
Avatar of SoftMar_SA
SoftMar_SA

You can download Microsoft's Platform SDK from: http://www.microsoft.com/msdownload/platformsdk/sdkupdate/

That will contain documentation on WM_COMMAND

For BN_CLICKED, the WM_COMMAND parameters are as follows:
wParam - The low-order word contains the button's control identifier. The high-order word specifies the notification
               message.
lParam - Handle to the button.

There is lots more documentation on button processing in the SDK.

You could also search for the same information online at msdn.microsoft.com.
Avatar of develc

ASKER

Hello SoftMar_SA,

thank you very much for your message.

On MSDN I already found very generally information but not much details.
For example :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfcnotes_tn061.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfcnotes_tn062.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsmessageclasslparamtopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vissdk11/html/viprolparam.asp
and so on.


Maybe there are some better sites there.
Do you know some?

Do you can give me any example how to use the right lParam and wParam with the information from Spy++?
For example the message I want to handle got the WM_Command 0x111 and the lParam 0x000012A6
and the wParam 0x00D1672 if I monitor the windows there is wNotifyCode:BN_Clicked wID:4774 hwndCTl:000D1672.
But when I use my routine and use the Params from Spy++ I send a wNotifyCode:0 (send from a menue) WID:4774

So maybe I got one failure in the high and low order words?
Do anybody knows a good documentation for that?

Any more advices are welcome.
;-)
Not sure what language your using.... Or what your trying to achieve...

Are you trying to handle a button press or fake a button press...

Here is a rough fragment to illustrate handling a button in C - This would be in your message loop

HWND hCtrl;

switch (msg)
{
   case  WM_COMMAND :
    {
       notifyCode = HIWORD(wParam); // 0 if from a menu, 1 accellerator, otherwise control notification code

       if (notifyCode == BN_CLICKED)
       {
          btnID  = LOWORD (wParam)   // Button ID - identifies which button send the message
          hCtrl = lParam;                     // Window handle of your button

          ... Code to handle your button press. You can determine which button was pressed from the button ID (btnID)
        }
    }
}

When sending a WM_COMMAND message yourself, construct your wParam, lParam parameters as follows:

wParam = MAKEWPARAM (btnID, BN_CLICKED);
lParam   = NULL; // or the window handle of the button if you know it.

It sounds like you've been setting the notification code part of the wParam to 0 - which would not indicate a button click.

If the notification is 0, your are processing a menu selection... in which case the LOWORD (wParam) is the menuitem ID and not a button ID....

Avatar of develc

ASKER

Hello SoftMar_SA,

thank you very very much your effort.
I'm really glad that someone helps me.

I prefer using C# - but for the generally questions with the params it may plays not such a big role.
What I'm trying to achieve, can you read under the following question :
"Commit a Outllook Message automatically ..." https://www.experts-exchange.com/questions/21089688/Commit-a-Outllook-Message-automatically-using-the-user32-dll-Problems-with-the-right-wNotifiyCode.html
Unfortunaltely this question isn't answered until yet.
To sum up, I want to rebuild / reconstruct the following freeware tool : http://www.contextmagic.com/express-clickyes/.

I thought the wParam is a hex Code?
And you're right with my code - I'm sending the notification of 0 which processing a menu selection, despite I'm using the
hex code which is shown in Spy++ when you click the okay Button - where is my failure?

What is the result when the lParam is Null?

I hope you don't give up!
;-)

Thank you.
Best regards
develc
ASKER CERTIFIED SOLUTION
Avatar of SoftMar_SA
SoftMar_SA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial