Re: Inheritance and MFC - Completed
Joe,
I finally figured it out. =
http://www.codeproject.com/miscctrl/customcontrol.asp
I am creating a control, which contains a control.
I wasn't sure how to go about creating a control and was just doing =
basic things.
SomeClass::OnMouseMove(int x, int y)
{
MyControl.OnMouseMove(x, y);
}
SomeClass::OnDraw(CDC* pDC)
{
MyControl.OnDraw(pDC);
}
That worked just fine, Until I wanted to add a scrollbar to my control.
I considered it a control, but in reality it wasn't a control, but just =
an object.
I couldn't quite figure out how to make the object independent and turn =
it into a control.
What I needed to do was register a window class in order to receive =
messages be able
to create the scrollbar control.
That, plus I would not need the OnDraw() or OnMouseMove() outside the =
control.
This is what I am doing. (It's basically in the link, except for the =
inheritance)
CGridSB : public CGrid, CWnd
{
DELCARE_MESSAGEMAP();
CScrollbar bar;
Create();
RegisterWindowClass();
bar.Create(this....) //works now because this class is registered to =
receive messages.
}
MessageMap Warnings
warning C4407: cast between different pointer to member representations, =
compiler may generate incorrect code
CGridSB : public CWnd, CGrid //Fixes the warning and error
I had to remove the CGrid: public CObject like David said.
Thanks,