Solved

Sending WM_COMMAND messages

Posted on 1998-08-13
5
579 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 discusses moving either the default database or any database to a new volume.

762 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

14 Experts available now in Live!

Get 1:1 Help Now