Can anybody see what I'm doing wrong?
-
I'm using Visual C++ 6.0 SP5 I create a new MFC Appwizard project, I choose SDI with doc/view architecture support, then I leave everything at the defaults until it asks me How do you want your toolbars to look? and I choose Internet Explorer Rebars then finish. In the resource editor under dialogs I edit the IDR_MAINFRAME dialog and add a button to it. I double click my newly created button to add an onclick handler. Classwizard pops up with a message saying IDR_MAINFRAME is a new resource... do you want to add a class for it? and I choose create a new class. Then I give this new class a name and leave everything at the defaults and push OK. Now I close Classwizard and go back to the resource editor and double click my button again to add the event handler. This time it prompts me for the name of the event handler and I just leave it as the default OnButton1. Then in the code for the event handler I just put something simple to test out the button like
AfxMessageBox("bleah");
I run the program and the button is grayed out... If I add an activex control to the dialog it will be enabled but the event handlers will be ignored. anybody know why? I am stumped... since microsoft sucks I bet that the new dialog class it creates is somehow messed up but I'm a bit of a beginner so I can't really tell a messed up class from a good one and I can't tell a message map from my own butt. Any ideas are appreciated. -Oinka -
I'm using Visual C++ 6.0 SP5 I create a new MFC Appwizard project, I choose SDI with doc/view architecture support, then I leave everything at the defaults until it asks me How do you want your toolbars to look? and I choose Internet Explorer Rebars then finish. In the resource editor under dialogs I edit the IDR_MAINFRAME dialog and add a button to it. I double click my newly created button to add an onclick handler. Classwizard pops up with a message saying IDR_MAINFRAME is a new resource... do you want to add a class for it? and I choose create a new class. Then I give this new class a name and leave everything at the defaults and push OK. Now I close Classwizard and go back to the resource editor and double click my button again to add the event handler. This time it prompts me for the name of the event handler and I just leave it as the default OnButton1. Then in the code for the event handler I just put something simple to test out the button like
AfxMessageBox("bleah");
I run the program and the button is grayed out... If I add an activex control to the dialog it will be enabled but the event handlers will be ignored. anybody know why? I am stumped... since microsoft sucks I bet that the new dialog class it creates is somehow messed up but I'm a bit of a beginner so I can't really tell a messed up class from a good one and I can't tell a message map from my own butt. Any ideas are appreciated. -OinkaStandrad MFC routing code will automatically disable menu/toolbar item if it command find a message handler in any of the following classes: CYourApp CMainFrame CYourDoc CYourView As you chose "Create a new class..." when associating the message OnButton1() handler, you probably did not get it put in the message map for one of these classes. What you should have done is "Select an existing class", which is probably CMainFrame or CYourDoc depdning on what you want to do. Typically if you need the handler to go in a specific class, I would start up class wizard and select the class you want the handler in. Then select the correct menu/toolbar button id and create a message map handler that way. Roger Allen Sonork 100.10016 Death come early, death come late, It takes us all, there is no reason. For every purpose under heaven, To each a turn, to each a season. A time to weep and a time to sigh, A time to laugh and a time to cry, A time to be born and a time to die. Dust to dust and ashes to ashes, And so I end my song.
-
Standrad MFC routing code will automatically disable menu/toolbar item if it command find a message handler in any of the following classes: CYourApp CMainFrame CYourDoc CYourView As you chose "Create a new class..." when associating the message OnButton1() handler, you probably did not get it put in the message map for one of these classes. What you should have done is "Select an existing class", which is probably CMainFrame or CYourDoc depdning on what you want to do. Typically if you need the handler to go in a specific class, I would start up class wizard and select the class you want the handler in. Then select the correct menu/toolbar button id and create a message map handler that way. Roger Allen Sonork 100.10016 Death come early, death come late, It takes us all, there is no reason. For every purpose under heaven, To each a turn, to each a season. A time to weep and a time to sigh, A time to laugh and a time to cry, A time to be born and a time to die. Dust to dust and ashes to ashes, And so I end my song.