Sintax
asked on
Sending a command (not a message)
Hi,
I have an application which does many things based on menu item clicks. The functions are written in classes which are very complicated and hard to access. I want to be able to trigger the function assigned to ID_PRX_CHANGEVIEW. Is there a way to "trick" the application and emulate the menuitem selection so the hidden function would be called? This is vital since the code is too big and many object instances are hidden from the MainFrame (this is where I wish to emulate the command)
Please help,
Sintax
I have an application which does many things based on menu item clicks. The functions are written in classes which are very complicated and hard to access. I want to be able to trigger the function assigned to ID_PRX_CHANGEVIEW. Is there a way to "trick" the application and emulate the menuitem selection so the hidden function would be called? This is vital since the code is too big and many object instances are hidden from the MainFrame (this is where I wish to emulate the command)
Please help,
Sintax
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If ID_PRX_CHANGEVIEW is menu item (is it ?) than check is there only one override for that command (only in CDocument). If it is then tru to send message to your CChildFrame window not to CMainFrame.
ASKER
It doesn't do what it should.
I have SendMessage(WM_COMMAND, ID_PRX_CHANGEVIEW, (LPARAM )NULL); in the mainframe. And I have an ON_COMMAND(ID_PRX_CHANGEVI EW,OnChang e) in the DBViewDoc with a messagebox in OnChange. This messagebox is NEVER raised.
Sintax
I have SendMessage(WM_COMMAND, ID_PRX_CHANGEVIEW, (LPARAM )NULL); in the mainframe. And I have an ON_COMMAND(ID_PRX_CHANGEVI
Sintax
Do You try to look from Debugger ?
Is there any enter in Your function OnChange() ?
What happened if You click on menu item ID_PRX_CHANGEVIEW ?
Is there any enter in Your function OnChange() ?
What happened if You click on menu item ID_PRX_CHANGEVIEW ?
Delay your calling of SendMessage(WM_COMMAND, ID_PRX_CHANGEVIEW, (LPARAM )NULL);
Describe your last comment.
ASKER
I managed to solve the command send, however I need to use HWND_BROADCAST to make it get the command. This is ok in some cases, however, when you have a lot of windows, eachone gets the command and may respond to it. How can I send the command to the document ? The problem is I have a fake window which relays, thus making the processing only possible with the broadcast.
Sintax
Sintax
I don't understand. Which window is sending the WM_COMMAND? try sending it to the frame by obtaining the mainframe pointer. AfxGetMainWnd()(sp?) and sending the command to it. The command routing will kick in and send it first to the active view, then to its document, and so on...
ASKER
I have SendMessage(WM_COMMAND, ID_PRX_CHANGEVIEW, (LPARAM )NULL); in the mainframe. And I have an ON_COMMAND(ID_PRX_CHANGEVI
Sintax