Library tutorials & articles
Attaching and Detaching Objects
Creation
Creation of most objects involves a two-step process. The first step is to create a C++ object, which is the "wrapper" around the Windows object. The next step is to create the actual Windows object. Some parameterized constructors do both of these steps at once. For example,
CPen pen;
Creates an MFC object, a CPen, but does not associate an HPEN with it. But the constructor
CPen pen(PS_SOLID, 0, RGB(255, 0, 0));
creates an MFC object, a CPen, then creates the underlying Windows object, the HPEN, and attaches that object to the CPen.
You can do this implicitly, by using the Create method (which is sometimes gratuitously renamed, as far as I can tell because the designers of MFC were not C++ experts). For example, to create a pen you can do
CPen pen; pen.CreatePen(PS_SOLID, 0, RGB(255, 0, 0));
(MFC has CreatePen and CreatePenIndirect, which is silly, because there is no Create method in either the CPen or the CGDIObject superclass).
Related articles
Related discussion
-
VS2005 app's won't run on another machine
by ted4444 (0 replies)
-
VB.NET: Hide and show table using radio buttons
by converter2009 (1 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
How to create a games like FIFA08
by mawcot (0 replies)
-
Binary Studio | software development outsourcing Ukraine
by shane124 (4 replies)
Sorry posted in wrong thread
i am new to VC++, while creating a model dialog from a cwnd class i am getting a Assertion error.
can any one tell me where i did wrong.
class CAuthen:: public CWnd
{
............
..
public:
CAuthenDlg auth_dlg;
..
public :
void checkAuthentication();
};
void CAuthen :: checkAuthentication()
{
..
..
..
if( auth_dlg.DoModal() == IDOK)
{
...
// some operation goes here
}
..
..
}
This thread is for discussions of Attaching and Detaching Objects.