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