Solved

Getting the right wNotifyCommands using the user32.dll

Posted on 2004-08-16
6
579 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:develc
  • 3
  • 2
6 Comments
 

Expert Comment

by:SoftMar_SA
ID: 11821160
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.
0
 
LVL 1

Author Comment

by:develc
ID: 11828987
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.
;-)
0
 

Expert Comment

by:SoftMar_SA
ID: 11832025
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....

0
 
LVL 1

Author Comment

by:develc
ID: 11850711
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 ..." http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21089688.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
0
 

Accepted Solution

by:
SoftMar_SA earned 500 total points
ID: 11891427
I see what you are trying to do.... I once did something very similar. An earlier version of Outlook always used to show a logon dialog on my pc.  The user name was always there, just needed to press OK. I had Outlook in my Startup folder. I wrote an application to automatically press the OK button to log Outlook in for me.

My approach was

1. Do the FindWindow on the window class - I think you already know how to do this.
2. I then called EnumChildWindows to enumerate the child windows. If I remember correctly the first child window was
    the OK button.
3. Having got the Window Handle of the OK button I then posted WM_LBUTTONDOWN/WM_LBUTTONUP messages to the
    button.

This faked a mouse click on the button.

The button would then send it's own WM_COMMAND messages....

This worked. Unfortunately I no longer have the code... I think this approach would work for you as well.

I've been trying to get my copy of Outlook 2003 to show the message so I could try to knock togethor the code.... But it doesn't seem to want to. Maybe a setting somewhere. I already have an application that calls it via MAPI.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now