Click here to Skip to main content
15,922,696 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dynamically creating classes by name Pin
Cedric Moonen29-Mar-06 0:11
Cedric Moonen29-Mar-06 0:11 
GeneralRe: Dynamically creating classes by name Pin
Rob Caldecott29-Mar-06 0:15
Rob Caldecott29-Mar-06 0:15 
QuestionTrouble opening connection to serial port through "CreateFile" Pin
Ting Li Che28-Mar-06 22:55
Ting Li Che28-Mar-06 22:55 
AnswerRe: Trouble opening connection to serial port through "CreateFile" Pin
_anil_28-Mar-06 23:10
_anil_28-Mar-06 23:10 
GeneralRe: Trouble opening connection to serial port through "CreateFile" Pin
Ting Li Che29-Mar-06 2:35
Ting Li Che29-Mar-06 2:35 
AnswerRe: Trouble opening connection to serial port through "CreateFile" Pin
David Crow29-Mar-06 3:35
David Crow29-Mar-06 3:35 
QuestionSubClassWindow, a big confusion for me , I am almost about to cry Pin
yang__lee28-Mar-06 22:47
yang__lee28-Mar-06 22:47 
AnswerRe: SubClassWindow, a big confusion for me , I am almost about to cry Pin
Shoaib Patel28-Mar-06 22:53
Shoaib Patel28-Mar-06 22:53 
FROM MSDN:
just an attempt to help u

Call this member function to "dynamically subclass" a window and attach it to this CWnd object.
BOOL SubclassWindow(
HWND hWnd
);
Parameters
hWnd
A handle to the window.

Return Value
Nonzero if the function is successful; otherwise 0.

Remarks
When a window is dynamically subclassed, windows messages will route through the CWnd's message map and call message handlers in the CWnd's class first. Messages that are passed to the base class will be passed to the default message handler in the window.
This member function attaches the Windows control to a CWnd object and replaces the window's WndProc and AfxWndProc functions. The function stores a pointer to the old WndProc in the CWnd object.
Note The window must not already be attached to an MFC object when this function is called.

Example
// The following code shows how to subclass the edit control and list box
// controls inside a combo box. It uses WM_CTLCOLOR for subclassing.
// CSuperComboBox represents the combo box
HBRUSH CSuperComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if (nCtlColor == CTLCOLOR_EDIT)
{
//Edit control
if (m_edit.GetSafeHwnd() == NULL)
m_edit.SubclassWindow(pWnd->GetSafeHwnd());
}
else if (nCtlColor == CTLCOLOR_LISTBOX)
{
//ListBox control
if (m_listbox.GetSafeHwnd() == NULL)
m_listbox.SubclassWindow(pWnd->GetSafeHwnd());
}
HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}

void CSuperComboBox::OnDestroy()
{
//unsubclass edit and list box before destruction
if (m_edit.GetSafeHwnd() != NULL)
m_edit.UnsubclassWindow();
if (m_listbox.GetSafeHwnd() != NULL)
m_listbox.UnsubclassWindow();
CComboBox::OnDestroy();
}
Smile | :)
Question[Message Deleted] Pin
ddmcr28-Mar-06 22:44
ddmcr28-Mar-06 22:44 
AnswerRe: Check List Box - recommendations Pin
Ștefan-Mihai MOGA28-Mar-06 23:48
professionalȘtefan-Mihai MOGA28-Mar-06 23:48 
QuestionDestroyWindow is giving me a headache Pin
Waldermort28-Mar-06 22:29
Waldermort28-Mar-06 22:29 
QuestionProblem With List Ctrl Pin
Mahesh Kulkarni28-Mar-06 22:29
Mahesh Kulkarni28-Mar-06 22:29 
AnswerRe: Problem With List Ctrl Pin
Rage28-Mar-06 22:33
professionalRage28-Mar-06 22:33 
GeneralRe: Problem With List Ctrl Pin
Mahesh Kulkarni28-Mar-06 22:40
Mahesh Kulkarni28-Mar-06 22:40 
GeneralRe: Problem With List Ctrl Pin
Ștefan-Mihai MOGA28-Mar-06 23:51
professionalȘtefan-Mihai MOGA28-Mar-06 23:51 
Questionquestion about WINCORE.CPP Pin
HOW WHAT28-Mar-06 21:32
HOW WHAT28-Mar-06 21:32 
QuestionGuyz!! help me out hear Pin
evita77728-Mar-06 20:34
evita77728-Mar-06 20:34 
AnswerRe: Guyz!! help me out hear Pin
Cedric Moonen28-Mar-06 20:37
Cedric Moonen28-Mar-06 20:37 
GeneralRe: Guyz!! help me out here Pin
evita77728-Mar-06 20:52
evita77728-Mar-06 20:52 
GeneralRe: Guyz!! help me out hear Pin
Rage28-Mar-06 20:55
professionalRage28-Mar-06 20:55 
GeneralRe: Guyz!! help me out hear Pin
evita77728-Mar-06 21:04
evita77728-Mar-06 21:04 
JokeRe: Guyz!! help me out hear Pin
Rage28-Mar-06 21:04
professionalRage28-Mar-06 21:04 
GeneralRe: Guyz!! help me out hear Pin
evita77728-Mar-06 21:10
evita77728-Mar-06 21:10 
JokeRe: Guyz!! help me out hear Pin
Rage28-Mar-06 20:39
professionalRage28-Mar-06 20:39 
GeneralRe: Guyz!! help me out hear Pin
evita77728-Mar-06 20:54
evita77728-Mar-06 20:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.