overriding CDialog::Create
-
Hi, im trying to override create function for modelessDialog Box.. as follows.. CTestDlgDlg (application name) BOOL CTestDlgDlg::Create(UINT nID, CWnd* pParent) { CDialogTemplate dlt; int nResult; // load dialog template if (!dlt.Load(MAKEINTRESOURCE(CTestDlgDlg::IDD))) return FALSE; // get pointer to the modified dialog template LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate); LPDLGTEMPLATE pDlgTemplate = (LPDLGTEMPLATE)pdata; //pDlgTemplate->style |= DS_SETFONT; // set your own font, for example "Arial", 10 pts. dlt.SetFont(L"Arial", 12); // let MFC know that you are using your own template m_lpszTemplateName = NULL; //InitModalIndirect(pdata); // display dialog box //nResult = CDialog::DoModal(); // unlock memory object // CDialog::Create(nID,pParent); CDialog::CreateDlgIndirect(pDlgTemplate, pParent, AfxGetInstanceHandle()); GlobalUnlock(dlt.m_hTemplate); } But it behaves same as modal Dialog box Instead of modeless .. Please try to help..
-
Hi, im trying to override create function for modelessDialog Box.. as follows.. CTestDlgDlg (application name) BOOL CTestDlgDlg::Create(UINT nID, CWnd* pParent) { CDialogTemplate dlt; int nResult; // load dialog template if (!dlt.Load(MAKEINTRESOURCE(CTestDlgDlg::IDD))) return FALSE; // get pointer to the modified dialog template LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate); LPDLGTEMPLATE pDlgTemplate = (LPDLGTEMPLATE)pdata; //pDlgTemplate->style |= DS_SETFONT; // set your own font, for example "Arial", 10 pts. dlt.SetFont(L"Arial", 12); // let MFC know that you are using your own template m_lpszTemplateName = NULL; //InitModalIndirect(pdata); // display dialog box //nResult = CDialog::DoModal(); // unlock memory object // CDialog::Create(nID,pParent); CDialog::CreateDlgIndirect(pDlgTemplate, pParent, AfxGetInstanceHandle()); GlobalUnlock(dlt.m_hTemplate); } But it behaves same as modal Dialog box Instead of modeless .. Please try to help..
Is there a CDialog::CreateDlgIndirect? There sure is a CDialog::CreateDialogIndirect.
«_Superman_» I love work. It gives me something to do between weekends.
-
Is there a CDialog::CreateDlgIndirect? There sure is a CDialog::CreateDialogIndirect.
«_Superman_» I love work. It gives me something to do between weekends.
-
Hi, im trying to override create function for modelessDialog Box.. as follows.. CTestDlgDlg (application name) BOOL CTestDlgDlg::Create(UINT nID, CWnd* pParent) { CDialogTemplate dlt; int nResult; // load dialog template if (!dlt.Load(MAKEINTRESOURCE(CTestDlgDlg::IDD))) return FALSE; // get pointer to the modified dialog template LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate); LPDLGTEMPLATE pDlgTemplate = (LPDLGTEMPLATE)pdata; //pDlgTemplate->style |= DS_SETFONT; // set your own font, for example "Arial", 10 pts. dlt.SetFont(L"Arial", 12); // let MFC know that you are using your own template m_lpszTemplateName = NULL; //InitModalIndirect(pdata); // display dialog box //nResult = CDialog::DoModal(); // unlock memory object // CDialog::Create(nID,pParent); CDialog::CreateDlgIndirect(pDlgTemplate, pParent, AfxGetInstanceHandle()); GlobalUnlock(dlt.m_hTemplate); } But it behaves same as modal Dialog box Instead of modeless .. Please try to help..
This is from MSDN "Quote" FIX: The CDialog::Create() function returns an incorrect value when a dialog box is created in Visual C++ View products that this article applies to. This article was previously published under Q193099 "Unquote" Sample: // Create a modeless dialog box. In this example, m_pModeless is a // member variable of type CModeless where CModeless is a CDialog- // derived class. IDD_MODELESS is the ID number of a dialog-box template // resource. m_pModeless = new CModeless; if (m_pModeless->Create(IDD_MODELESS, this) && ::IsWindow(m_pModeless->m_hWnd)) { // ... succeeded in dialog-box creation. } else { // ... failed in dialog-box creation. } Once again from MSDN. For me personally. I have always created the dialog box first, tested it as a modal dialog and then made it modeless by creating it as follows: LogonDlg* pDlg = new LogonDlg; // create it if necessary LogonDlg * pApp = (LogonDlg*)AfxGetApp()->m_pMainWnd; if (pApp->m_hWnd == NULL && !pApp->Create(LogonDlg::IDD)) { CTraceLog::TraceMsg( "InitInstance failed to create LogonDlg" ); return FALSE; } pApp->SetVisibility( SW_HIDE );
-
CDialog::CreateDlgIndirect is present it"s a private function in dlgcore.cpp ..it"s a CWND class member function....
But it's not virtual, so if CreateDlgIndirect is called using an instance pointer typed as CDialog (which is highly likely, as CDialog is the only class with visibility of that method), it'll always call the CDialog version of the method.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p