Library tutorials & articles
Attaching and Detaching Objects
By Joseph M. Newcomer, published on 13 Oct 2001
Introduction
MFC provides a set of "wrapper objects" that contain embedded Windows objects. For example, a CWnd wraps an HWND, a CFont wraps an HFONT, a CBrush wraps an HBRUSH, and so on. These are summarized in the table below. There are some significant interactions between the MFC and Windows objects, which you need to understand.
Failure to deal with these issues can lead to problems with spontaneous ASSERT statements, access errors, disappearing objects, and other, more subtle problems.
This essay attempts to elucidate the issues of dealing with the MFC/Windows interface.
| MFC Ojbect | Windows Object | (variant) |
| CWnd | HWND | any window |
| CEdit | HWND | EDIT |
| CListBox | HWND | LISTBOX |
| CStatic | HWND | STATIC |
| CComboBox | HWND | COMBOBOX |
| CGDIObject | (gdi object) | (any) |
| CBitmap | HBITMAP | |
| CBrush | HBRUSH | |
| CPen | HPEN | |
| CFont | HFONT | |
| CRegion | HRGN | |
| CPalette | HPALETTE |
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.