Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Can anybody see what I'm doing wrong?

Can anybody see what I'm doing wrong?

Scheduled Pinned Locked Moved C / C++ / MFC
c++learningcomarchitecturequestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Oinka
    wrote on last edited by
    #1

    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

    R 1 Reply Last reply
    0
    • O 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. -Oinka

      R Offline
      R Offline
      Roger Allen
      wrote on last edited by
      #2

      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.

      O 1 Reply Last reply
      0
      • R Roger Allen

        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.

        O Offline
        O Offline
        Oinka
        wrote on last edited by
        #3

        thanks for your help!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups