Add Message Handler in VC7.0
-
Hello.. I'm reading a book that describes how I can use build in wizards in Visual Studio 6.0 to add message handlers. It tells me to right click the class, and click add windows message handler.. But i'm using VC7.0.. Where can I find this functionallity? Specifically I want to add an OnCreate handler.
-
Hello.. I'm reading a book that describes how I can use build in wizards in Visual Studio 6.0 to add message handlers. It tells me to right click the class, and click add windows message handler.. But i'm using VC7.0.. Where can I find this functionallity? Specifically I want to add an OnCreate handler.
A message handler is just another function. In your header file add this declaration:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
In your implementation file where it says,BEGIN_MESSAGE_MAP(_CYourWindow_, CWnd)
this is where you tell it what method is going to handle which message. Add thisON_WM_CREATE()
somewhere in the MESSAGE_MAP. Then add your function to the implementation file like this:int CYourWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
// your code goes here
}BTW, I'm assuming MFC is used. Otherwise you'll have this huge switch statement to modify.
"We have done so much in the last 2 years, and it doesn't happen by standing around with your finger in your ear, hoping everyone thinks that that's nice." - Donald Rumsfeld
Jason Henderson
blog -
A message handler is just another function. In your header file add this declaration:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
In your implementation file where it says,BEGIN_MESSAGE_MAP(_CYourWindow_, CWnd)
this is where you tell it what method is going to handle which message. Add thisON_WM_CREATE()
somewhere in the MESSAGE_MAP. Then add your function to the implementation file like this:int CYourWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
// your code goes here
}BTW, I'm assuming MFC is used. Otherwise you'll have this huge switch statement to modify.
"We have done so much in the last 2 years, and it doesn't happen by standing around with your finger in your ear, hoping everyone thinks that that's nice." - Donald Rumsfeld
Jason Henderson
blog -
Yes, but I was getting tierd of writing code like that and wanted the wizard to do it for me. I just can't seem to find the "Add Message Handler"-wizard in VC 7.0.
If its in a dialog, you can right click on the control.
"We have done so much in the last 2 years, and it doesn't happen by standing around with your finger in your ear, hoping everyone thinks that that's nice." - Donald Rumsfeld
Jason Henderson
blog -
If its in a dialog, you can right click on the control.
"We have done so much in the last 2 years, and it doesn't happen by standing around with your finger in your ear, hoping everyone thinks that that's nice." - Donald Rumsfeld
Jason Henderson
blogBut it's not. My book tells me to "Right-click CMainFrame in the ClassView window, select Add Windows Message Handler, double-click WM_CREATE, and click Edit Existing. You'll find yourself in the empty message handler body, poised to type in the finished code. ClassWizard has already done everything else, including adding an ON_WM_CREATE entry to the message map." But there's no "add windows message handler" in VC 7.0(at least I can't spot it)
-
Yes, but I was getting tierd of writing code like that and wanted the wizard to do it for me. I just can't seem to find the "Add Message Handler"-wizard in VC 7.0.
You can also go to class view, click on the class, right-click and go to properties. Then click on the messages button and add your handler.
"We have done so much in the last 2 years, and it doesn't happen by standing around with your finger in your ear, hoping everyone thinks that that's nice." - Donald Rumsfeld
Jason Henderson
blog -
You can also go to class view, click on the class, right-click and go to properties. Then click on the messages button and add your handler.
"We have done so much in the last 2 years, and it doesn't happen by standing around with your finger in your ear, hoping everyone thinks that that's nice." - Donald Rumsfeld
Jason Henderson
blog -
Yes, but I was getting tierd of writing code like that and wanted the wizard to do it for me. I just can't seem to find the "Add Message Handler"-wizard in VC 7.0.