Solved

Sending WM_COMMAND messages

Posted on 1998-08-13
5
580 Views
Last Modified: 2013-11-20
Is it possible to send out a WM_COMMAND message ?
If so how do you set the parameters.

If not, how do you add a command message to the message queue??
0
Comment
Question by:manx
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:bernfarr
ID: 1320748
You can send out any message using the SendMessage() call.

LRESULT SendMessage( HWND hWnd,
  UINT Msg,       // message to send (WM_COMMAND in your case)
  WPARAM wParam,  // first message parameter
  LPARAM lParam   // second message parameter);

You need to figure out who you're sending the message to and what exactly you're sending. For WM_COMMAND, the parameters are as follows (from the WM_COMMAND reference):
  wNotifyCode = HIWORD(wParam);
  wID = LOWORD(wParam);
  hwndCtl = (HWND) lParam;

Which message queue do you want to add the command to? The one for your application?
0
 
LVL 6

Accepted Solution

by:
snoegler earned 50 total points
ID: 1320749
For what purpose do you want to send a WM_COMMAND message?
The parameters are like this:
wNotifyCode=HIWORD(wParam) - sth. like BN_CLICKED
wID=LOWORD(wParam) - identifier of the control ( ID_FILE_OPEN or ID_OK )
hwndCtl=(HWND)lParam - window handle of the control

hwndCtl is NULL if the message came from a menu item or accelerator, otherwise
it contains the window handle of the control from which the message has been sent
You can obtain the handle by calling CWnd::GetDlgItem() with the ID of the control.
I hope that helps ;)
0
 

Author Comment

by:manx
ID: 1320750
I would like to send the message to the application queue. As I would like to execute a event immediately after a certain function is executed.

What is wrong with this command format ?

SendMessage(WM_COMMAND(BN_CLICKED,ID_FILE_CLOSE,NULL);

It gives me a "term does not evaluate to a function" (C2064) error ?
0
 
LVL 6

Expert Comment

by:snoegler
ID: 1320751
SendMessage(WM_COMMAND,
                         MAKELONG(ID_FILE_CLOSE,0),
                         NULL)
Look into the WM_COMMAND docs:
wNotifyCode is '0' when the message is sent from a menu,
hwndCtl is also NULL.

BTW: WM_COMMAND(x,y,z) is not defined - that's the cause of the error.
0
 

Author Comment

by:manx
ID: 1320752
Thanks
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

Suggested Solutions

Title # Comments Views Activity
Running shell command from Access 3 68
ADO Memory leak with DELPHI 2007 37 170
Creating Labels and Frequency list style reports in SAS code 9 92
sumHeights  challenge 17 65
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

919 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

20 Experts available now in Live!

Get 1:1 Help Now