Solved

Sending a command (not a message)

Posted on 2001-07-03
9
247 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:Sintax
9 Comments
 
LVL 2

Accepted Solution

by:
MadYugoslav earned 150 total points
ID: 6247701
SendMessage(WM_COMMAND, D_PRX_CHANGEVIEW, (LPARAM )NULL);
0
 
LVL 1

Author Comment

by:Sintax
ID: 6247786
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_CHANGEVIEW,OnChange) in the DBViewDoc with a messagebox in OnChange. This messagebox is NEVER raised.

Sintax
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6247811
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.
0
 
LVL 1

Author Comment

by:Sintax
ID: 6247873
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_CHANGEVIEW,OnChange) in the DBViewDoc with a messagebox in OnChange. This messagebox is NEVER raised.

Sintax
0
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.

 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6247886
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 ?
0
 
LVL 9

Expert Comment

by:BeyondWu
ID: 6251009
Delay your calling of SendMessage(WM_COMMAND, ID_PRX_CHANGEVIEW, (LPARAM )NULL);
0
 
LVL 2

Expert Comment

by:MadYugoslav
ID: 6252082
Describe your last comment.
0
 
LVL 1

Author Comment

by:Sintax
ID: 6252179
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
0
 

Expert Comment

by:lil_elvis2000
ID: 6254076
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...
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
modThree challenge 4 79
zeroFront challenge 7 80
withoutTen challenge 14 100
Use of condition with 'serial' in ansible 2 50
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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.

895 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

13 Experts available now in Live!

Get 1:1 Help Now