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. Add Message Handler in VC7.0

Add Message Handler in VC7.0

Scheduled Pinned Locked Moved C / C++ / MFC
csharpvisual-studioquestionlearning
8 Posts 3 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.
  • P Offline
    P Offline
    pie
    wrote on last edited by
    #1

    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.

    J 1 Reply Last reply
    0
    • P pie

      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.

      J Offline
      J Offline
      Jason Henderson
      wrote on last edited by
      #2

      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 this ON_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

      P 1 Reply Last reply
      0
      • J Jason Henderson

        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 this ON_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

        P Offline
        P Offline
        pie
        wrote on last edited by
        #3

        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.

        J L 3 Replies Last reply
        0
        • P pie

          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.

          J Offline
          J Offline
          Jason Henderson
          wrote on last edited by
          #4

          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

          P 1 Reply Last reply
          0
          • J Jason Henderson

            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

            P Offline
            P Offline
            pie
            wrote on last edited by
            #5

            But 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)

            1 Reply Last reply
            0
            • P pie

              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.

              J Offline
              J Offline
              Jason Henderson
              wrote on last edited by
              #6

              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

              P 1 Reply Last reply
              0
              • J Jason Henderson

                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

                P Offline
                P Offline
                pie
                wrote on last edited by
                #7

                Aah, thank you.. Exactly what I was looking for!

                1 Reply Last reply
                0
                • P pie

                  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.

                  L Offline
                  L Offline
                  l a u r e n
                  wrote on last edited by
                  #8

                  join the freaking club why oh why did they get rid of class wizard??? :mad:


                  "there is no spoon"
                  biz stuff   about me

                  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