创建余山一个CDialog,在OnInitDialog中
HWND hWnd = ::FindWindow(_T("TXGuiFoundation"), _T("QQ"))
::SetParent(hWnd, GetSafeHwnd())
::SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) &~WS_POPUP | WS_CHILD)
//移动到合适的位塌毁橡置
CRect rc
GetClientRect(rc)
::MoveWindow(hWnd, rc.left, rc.top, rc.Width(), rc.Height()-20, TRUE)
::BringWindowToTop(hWnd)
::ShowWindow(hWnd, SW_SHOW)
方法如下:用CView*或者CFrameWnd*给雹冲他做父窗口 一般你是做成非模陪誉态对话框就用Create Example
CMyDialog* pDialog
void CMyWnd::OnSomeAction()
{
//pDialog initialized to NULL in the constructor of CMyWnd class
pDialog = new CMyDialog()
//Check if new succeeded and we got a valid pointer to a dialog object
if(pDialog != NULL)
{
BOOL ret = pDialog->Create(IDD_MYDIALOG,/*父窗口*/)
if(!ret) //Create failed.
AfxMessageBox("Error creating Dialog")
pDialog->源乱歼ShowWindow(SW_SHOW)
}
else
AfxMessageBox("Error Creating Dialog Object")
}
1、首模拍先创建一个基于对话框的“MFC应用程序”;2、在旦答羡解决方案里的资源文件处添加新窗口,即新Dialog
3、在新窗口上右击添加类向导
4、然后在主窗口里相应的事件里添加新窗口的头文举键件和类对象,例:
CNewCreateDlg dlgdlg.DoModal()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)