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. MFC: CView and Control

MFC: CView and Control

Scheduled Pinned Locked Moved C / C++ / MFC
6 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.
  • R Offline
    R Offline
    Remi Morin
    wrote on last edited by
    #1

    Hi, I am developing a Document/view application that display different kind of curve. To do so i've used a common CView derived class... but now I want to add some control inside my view on the drawing area. Just for a demo I've insert "false button". ie bitmap picture and I'm trapping their position on LButtonDown... so it's just for demo. For now I'm seaching a good tutorial or code example who give me the possibility to add all kind of control in a view. I still need to be able to draw (whit dc's function) and to use splitter curve. So if anyone have something who can help thank Rémi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

    N 1 Reply Last reply
    0
    • R Remi Morin

      Hi, I am developing a Document/view application that display different kind of curve. To do so i've used a common CView derived class... but now I want to add some control inside my view on the drawing area. Just for a demo I've insert "false button". ie bitmap picture and I'm trapping their position on LButtonDown... so it's just for demo. For now I'm seaching a good tutorial or code example who give me the possibility to add all kind of control in a view. I still need to be able to draw (whit dc's function) and to use splitter curve. So if anyone have something who can help thank Rémi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

      N Offline
      N Offline
      Naresh Karamchetty
      wrote on last edited by
      #2

      I'm almost certain you can't add a control to a CView-derived vie wusing the resource editor. You would have to try it programmatically. One idea is to declare a member variable of type CButton, initialize it in your view class's constructor, and then call its Show function in the view's OnDraw function. I must admit, I'm not entirely clear as to how you would go about handling events from such a button. I believe you have to assign a control ID to the button and use the ON_BN_CLICKED macro to map the message to a specific function. "What would this country be without this great land of our?" -Ronald Reagan

      R 1 Reply Last reply
      0
      • N Naresh Karamchetty

        I'm almost certain you can't add a control to a CView-derived vie wusing the resource editor. You would have to try it programmatically. One idea is to declare a member variable of type CButton, initialize it in your view class's constructor, and then call its Show function in the view's OnDraw function. I must admit, I'm not entirely clear as to how you would go about handling events from such a button. I believe you have to assign a control ID to the button and use the ON_BN_CLICKED macro to map the message to a specific function. "What would this country be without this great land of our?" -Ronald Reagan

        R Offline
        R Offline
        Remi Morin
        wrote on last edited by
        #3

        Hehe! Same for me it's the only thing I've found but for now I was'nt able to assing an Id and I don't want to edit myself the ressources. So I derived the class of the control I wanna use and override everything I need. It's not clean but it work... to my mind they must exist a better way to do so. Still waiting for!:) Thank you for you'r answer Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

        N 1 Reply Last reply
        0
        • R Remi Morin

          Hehe! Same for me it's the only thing I've found but for now I was'nt able to assing an Id and I don't want to edit myself the ressources. So I derived the class of the control I wanna use and override everything I need. It's not clean but it work... to my mind they must exist a better way to do so. Still waiting for!:) Thank you for you'r answer Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

          N Offline
          N Offline
          Naresh Karamchetty
          wrote on last edited by
          #4

          To assign an ID you just use one of those #define macros. Editing the resource file won't help because everytime the resources are compiled or edited, or soemthing like that, the resource file is erased and written anew. "What would this country be without this great land of our?" -Ronald Reagan

          J 1 Reply Last reply
          0
          • N Naresh Karamchetty

            To assign an ID you just use one of those #define macros. Editing the resource file won't help because everytime the resources are compiled or edited, or soemthing like that, the resource file is erased and written anew. "What would this country be without this great land of our?" -Ronald Reagan

            J Offline
            J Offline
            Jake Palmer
            wrote on last edited by
            #5

            The way to declare IDs is to go to the Resources tab, right click on the top level folder and select Resource Symbols. It has an icon of text "ID=", which demonstrates its use as defining global IDs. Click "new" and you can make "ID_BUTTON_SOMETHING" and then use that anywhere in your project. Handling that button will require adding an entry to the message map. In the cpp file of the class you want to receive the message (your view class, most likely), after the BEGIN_MESSAGE_MAP, add the entry: ON_COMMAND(ID_BUTTON_SOMETHING, OnButtonSomething). Button clicks should automatically call the function OnButtonSomething, which you will need to declare in the header file (afx_msg void OnButtonSomething()) and implement in the cpp file. Hope this helps :cool: Jake

            R 1 Reply Last reply
            0
            • J Jake Palmer

              The way to declare IDs is to go to the Resources tab, right click on the top level folder and select Resource Symbols. It has an icon of text "ID=", which demonstrates its use as defining global IDs. Click "new" and you can make "ID_BUTTON_SOMETHING" and then use that anywhere in your project. Handling that button will require adding an entry to the message map. In the cpp file of the class you want to receive the message (your view class, most likely), after the BEGIN_MESSAGE_MAP, add the entry: ON_COMMAND(ID_BUTTON_SOMETHING, OnButtonSomething). Button clicks should automatically call the function OnButtonSomething, which you will need to declare in the header file (afx_msg void OnButtonSomething()) and implement in the cpp file. Hope this helps :cool: Jake

              R Offline
              R Offline
              Remi Morin
              wrote on last edited by
              #6

              thank you very much for you'r help. this subject is now a good tutorial "HOW TO: Use any kind of control in a view" now every control work very well thanks :) ;) ;P :-D :laugh: :-D ;P ;) :) Remi Morin Rmorin@Operamail.com Remi.Morin@Lyrtech.com

              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