Create control class from CWnd-derived
Hello,
I am writting a class derived from CWnd. However, I do not find a good point to start. I think that the simplest case is using CWnd to write a CButton. Has anyone done it or Do you know any resources for this problem.
Thank you very much!
Best,
Re: Create control class from CWnd-derived
Quote:
Originally Posted by
GBM25_11
I am writting a class derived from CWnd. However, I do not find a good point to start. I think that the simplest case is using CWnd to write a CButton. Has anyone done it or Do you know any resources for this problem.
Why not consider writing some not-yet-existing controls since MFC already has its own CButton class.
Re: Create control class from CWnd-derived
Well, the problem is understanding Windows and than MFC. What you wrote is a contradiction:
Use either CWnd oe CButton class to crete window you want.
You cannot use CWnd class to create CButton object.
CWnd class is used to create just about any window you want. You choose Window class from either: from Windows set of control classes or registering your own window class.
You can use CWnd class to create button window but MFC variety of wrappers, has CButton class (derived from CWnd) you can use.
If you want to use CWnd class to create button, pass button class name as parameter to CreateWindow or CreateWindowEx.
Re: Create control class from CWnd-derived
Quote:
Originally Posted by
JohnCz
Well, the problem is understanding Windows and than MFC. What you wrote is a contradiction:
Use either CWnd oe CButton class to crete window you want.
You cannot use CWnd class to create CButton object.
CWnd class is used to create just about any window you want. You choose Window class from either: from Windows set of control classes or registering your own window class.
You can use CWnd class to create button window but MFC variety of wrappers, has CButton class (derived from CWnd) you can use.
If you want to use CWnd class to create button, pass button class name as parameter to CreateWindow or CreateWindowEx.
Hello, I am sorry because using a wrong name. I used the word "CButton", which is not very appropriate. I mean deriving a class CMyButton from CWnd, which has almost all of the characteristics of CButton.
Thank you for your comments.
Re: Create control class from CWnd-derived
First thing to become a good programmer is learning how to translate your thoughts into terms everybody can understand; define common basic terms that can be used to carry a discussion knowing that we are talking about the same thing.
Having said so: Why not to use CButton class as a base class for CMyButton?
Is using CWnd as a base class for CMyButton an exercise?
Re: Create control class from CWnd-derived
Yes, I would like to study from the simplest project for a more complex application.
Thank you for your care!
1 Attachment(s)
Re: Create control class from CWnd-derived
I can appreciate this, but in order to do so, I would suggest some reading about Windows programming and MFC.
Try creating Win32 application to get familiar with windows classes, main message loop, window procedure, windows messages and windows API.
Than try MFC that wraps most of the windows APIs.
I have attached sample project for starters.