handle to Dialog box -
07-25-2003
, 07:03 PM
Hello, I am fairly new to c++.net programming. In my
program, I'm trying to create a CButton object through a
dialog box. I want to create this object during run-time.
In the view class, I have the following:
void CdialogView::OnOpenDialogBox()
{
// TODO: Add your command handler code here
CDialogBox dlg;
dlg.DoModal();
}
In the CDialogBox class I used to following code:
// Create a push button.
HWND hWnd=this->m_hWnd; //Handle to dialog box
CButton myButton;
BOOL b= myButton.Create(_T("My button"),
WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
CRect(10,10,100,30), (CWnd*)&hWnd,100000);
The boolean value b returns FALSE. THe only problem I can
see with this is the dialog boxes's handle, this->m_hWnd,
because the Create function requires this variable. Did I
use the right handle?
Thanks! |