S
Suresh Kansujiya
Guest
Hello All,
i am getting this error when i am debugging the project . error is given below as
File: f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dlgcore.cpp
and dlgcore.cpp is as
#include "stdafx.h"
#include "occimpl.h"
#define new DEBUG_NEW
INT_PTR CALLBACK AfxDlgProc(HWND hWnd, UINT message, WPARAM, LPARAM)
{
if (message == WM_INITDIALOG)
{
// special case for WM_INITDIALOG
CDialog* pDlg = DYNAMIC_DOWNCAST(CDialog, CWnd::FromHandlePermanent(hWnd));
if (pDlg != NULL)
return pDlg->OnInitDialog();
else
return 1;
}
return 0;
}BEGIN_MESSAGE_MAP(CDialog, CWnd)
//{{AFX_MSG_MAP(CDialog)
ON_COMMAND(IDOK, &CDialog::OnOK)
ON_COMMAND(IDCANCEL, &CDialog::OnCancel)
ON_MESSAGE(WM_COMMANDHELP, &CDialog::OnCommandHelp)
ON_MESSAGE(WM_HELPHITTEST, &CDialog::OnHelpHitTest)
ON_MESSAGE(WM_INITDIALOG, &CDialog::HandleInitDialog)
ON_MESSAGE(WM_SETFONT, &CDialog::HandleSetFont)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CDialog:reTranslateMessage(MSG* pMsg)
{
// for modeless processing (or modal)
ASSERT(m_hWnd != NULL);
// allow tooltip messages to be filtered
if (CWnd:reTranslateMessage(pMsg))
return TRUE;
// dont translate dialog messages when in Shift+F1 help mode
CFrameWnd* pFrameWnd = GetTopLevelFrame();
if (pFrameWnd != NULL && pFrameWnd->m_bHelpMode)
return FALSE;
if (pMsg->message == WM_KEYDOWN &&
(pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_CANCEL) &&
:GetWindowLong(pMsg->hwnd, GWL_STYLE) & ES_MULTILINE) &&
_AfxCompareClassName(pMsg->hwnd, _T("Edit")))
{
HWND hItem = ::GetDlgItem(m_hWnd, IDCANCEL);
if (hItem == NULL || ::IsWindowEnabled(hItem))
{
SendMessage(WM_COMMAND, IDCANCEL, 0);
return TRUE;
}
}
// filter both messages to dialog and from children
return PreTranslateInput(pMsg);
}
BOOL CDialog::OnCmdMsg(UINT nID, int nCode, void* pExtra,
AFX_CMDHANDLERINFO* pHandlerInfo)
{if (CWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
if ((nCode != CN_COMMAND && nCode != CN_UPDATE_COMMAND_UI) ||
!IS_COMMAND_ID(nID) || nID >= 0xf000)
{
// control notification or non-command button or system command
return FALSE; // not routed any further
}
// if we have an owner window, give it second crack
CWnd* pOwner = GetParent();
if (pOwner != NULL)
{
TRACE(traceCmdRouting, 1, "Routing command id 0x%04X to owner window.\n", nID);
ASSERT(pOwner != this);
if (pOwner->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
}
// last crack goes to the current CWinThread object
CWinThread* pThread = AfxGetThread();
if (pThread != NULL)
{
TRACE(traceCmdRouting, 1, "Routing command id 0x%04X to app.\n", nID);
if (pThread->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
}
TRACE(traceCmdRouting, 1, "IGNORING command id 0x%04X sent to %hs dialog.\n", nID,
GetRuntimeClass()->m_lpszClassName);
return FALSE;
}
CDialog::CDialog()
{
ASSERT(m_hWnd == NULL);
AFX_ZERO_INIT_OBJECT(CWnd);
}
CDialog::~CDialog()
{
if (m_hWnd != NULL)
{
TRACE(traceAppMsg, 0, "Warning: calling DestroyWindow in CDialog::~CDialog --\n");
TRACE(traceAppMsg, 0, "\tOnDestroy or PostNcDestroy in derived class will not be called.\n");
DestroyWindow();
}
}
void CDialog::OnPaint()
{
CPaintDC dc(this);
if (PaintWindowlessControls(&dc))
return;
Default();
}
BOOL CDialog::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
{
ASSERT(IS_INTRESOURCE(lpszTemplateName) ||
AfxIsValidString(lpszTemplateName));
m_lpszTemplateName = lpszTemplateName; // used for help
if (IS_INTRESOURCE(m_lpszTemplateName) && m_nIDHelp == 0)
m_nIDHelp = LOWORD((DWORD_PTR)m_lpszTemplateName);
#ifdef _DEBUG
if (!_AfxCheckDialogTemplate(lpszTemplateName, FALSE))
{
ASSERT(FALSE); // invalid dialog template name
PostNcDestroy(); // cleanup if Create fails too soon
return FALSE;
}
#endif //_DEBUG
HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);
HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);
HGLOBAL hTemplate = LoadResource(hInst, hResource); //this is break point when i retry debuge
BOOL bResult = CreateIndirect(hTemplate, pParentWnd, hInst);
FreeResource(hTemplate);
return bResult;
}
// for backward compatibility
BOOL CDialog::CreateIndirect(HGLOBAL hDialogTemplate, CWnd* pParentWnd)
{
return CreateIndirect(hDialogTemplate, pParentWnd, NULL);
}
BOOL CDialog::CreateIndirect(HGLOBAL hDialogTemplate, CWnd* pParentWnd,
HINSTANCE hInst)
{
ASSERT(hDialogTemplate != NULL);
LPCDLGTEMPLATE lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
BOOL bResult = CreateIndirect(lpDialogTemplate, pParentWnd, NULL, hInst);
UnlockResource(hDialogTemplate);
return bResult;
}
// for backward compatibility
BOOL CDialog::CreateIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd,
void* lpDialogInit)
{
return CreateIndirect(lpDialogTemplate, pParentWnd, lpDialogInit, NULL);
}
BOOL CDialog::CreateIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd,
void* lpDialogInit, HINSTANCE hInst)
{
ASSERT(lpDialogTemplate != NULL);
if (pParentWnd == NULL)
pParentWnd = AfxGetMainWnd();
m_lpDialogInit = lpDialogInit;
return CreateDlgIndirect(lpDialogTemplate, pParentWnd, hInst);
}
BOOL CWnd::CreateDlg(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
{
// load resource
LPCDLGTEMPLATE lpDialogTemplate = NULL;
HGLOBAL hDialogTemplate = NULL;
HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);
HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);
hDialogTemplate = LoadResource(hInst, hResource);
if (hDialogTemplate != NULL)
lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
ASSERT(lpDialogTemplate != NULL);
// create a modeless dialog
BOOL bSuccess = CreateDlgIndirect(lpDialogTemplate, pParentWnd, hInst);
// free resource
UnlockResource(hDialogTemplate);
FreeResource(hDialogTemplate);
return bSuccess;
}
BOOL CWnd::CreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate,
CWnd* pParentWnd, HINSTANCE hInst)
{
#ifdef _DEBUG
if ( AfxGetApp()->IsKindOf( RUNTIME_CLASS( COleControlModule ) ) )
{
TRACE(traceAppMsg, 0, "Warning: Creating dialog from within a COleControlModule application is not a supported scenario.\n");
}
#endif
ASSERT(lpDialogTemplate != NULL);
if (pParentWnd != NULL)
ASSERT_VALID(pParentWnd);
if(!hInst)
hInst = AfxGetResourceHandle();
#ifndef _AFX_NO_OCC_SUPPORT
_AFX_OCC_DIALOG_INFO occDialogInfo;
COccManager* pOccManager = afxOccManager;
#endif
HGLOBAL hTemplate = NULL;
HWND hWnd = NULL;
#ifdef _DEBUG
DWORD dwError = 0;
#endif
TRY
{
VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTLS_REG));
AfxDeferRegisterClass(AFX_WNDCOMMCTLSNEW_REG);
#ifdef _UNICODE
AfxInitNetworkAddressControl();
#endif
#ifndef _AFX_NO_OCC_SUPPORT
// separately create OLE controls in the dialog template
if (pOccManager != NULL)
{
if (!SetOccDialogInfo(&occDialogInfo))
return FALSE;
lpDialogTemplate = pOccManager->PreCreateDialog(&occDialogInfo,
lpDialogTemplate);
}
if (lpDialogTemplate == NULL)
return FALSE;
#endif //!_AFX_NO_OCC_SUPPORT
// If no font specified, set the system font.
CString strFace;
WORD wSize = 0;
BOOL bSetSysFont = !CDialogTemplate::GetFont(lpDialogTemplate, strFace,
wSize);
if (bSetSysFont)
{
CDialogTemplate dlgTemp(lpDialogTemplate);
dlgTemp.SetSystemFont(wSize);
hTemplate = dlgTemp.Detach();
}
if (hTemplate != NULL)
lpDialogTemplate = (DLGTEMPLATE*)GlobalLock(hTemplate);
// setup for modal loop and creation
m_nModalResult = -1;
m_nFlags |= WF_CONTINUEMODAL;
// create modeless dialog
AfxHookWindowCreate(this);
hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
pParentWnd->GetSafeHwnd(), AfxDlgProc);
#ifdef _DEBUG
dwError = ::GetLastError();
#endif
}
CATCH_ALL(e)
{
DELETE_EXCEPTION(e);
m_nModalResult = -1;
}
END_CATCH_ALL
#ifndef _AFX_NO_OCC_SUPPORT
if (pOccManager != NULL)
{
if (hWnd != NULL)
{
pOccManager->PostCreateDialog(&occDialogInfo);
SetOccDialogInfo(NULL);
}
}
#endif //!_AFX_NO_OCC_SUPPORT
if (!AfxUnhookWindowCreate())
PostNcDestroy(); // cleanup if Create fails too soon
// handle EndDialog calls during OnInitDialog
#ifdef _DEBUG
#ifndef _AFX_NO_OCC_SUPPORT
// Saving the old flag for checking WF_CONTINUEMODAL (if the object has not been destroyed)
// This needs to be after ::CreateDialogIndirect().
DWORD dwOldFlags = 0;
if (hWnd != NULL)
dwOldFlags = m_nFlags;
#endif
#endif
if (hWnd != NULL && !(m_nFlags & WF_CONTINUEMODAL))
{
:estroyWindow(hWnd);
hWnd = NULL;
}
if (hTemplate != NULL)
{
GlobalUnlock(hTemplate);
GlobalFree(hTemplate);
}
// help with error diagnosis (only if WM_INITDIALOG didnt EndDialog())
if (hWnd == NULL)
{
#ifdef _DEBUG
#ifndef _AFX_NO_OCC_SUPPORT
if (dwOldFlags & WF_CONTINUEMODAL)
{
if (afxOccManager == NULL)
{
TRACE(traceAppMsg, 0, >> If this dialog has OLE controls:\n");
TRACE(traceAppMsg, 0, >> AfxEnableControlContainer has not been called yet.\n");
TRACE(traceAppMsg, 0, >> You should call it in your apps InitInstance function.\n");
}
else if (dwError != 0)
{
TRACE(traceAppMsg, 0, "Warning: Dialog creation failed! GetLastError returns 0x%8.8X\n", dwError);
}
}
#ifdef _DEBUG
void CDialog::AssertValid() const
{
CWnd::AssertValid();
}
void CDialog:ump(CDumpContext& dc) const
{
CWnd:ump(dc);
dc << "m_lpszTemplateName = ";
if (IS_INTRESOURCE(m_lpszTemplateName))
dc << (int)LOWORD((DWORD_PTR)m_lpszTemplateName);
else
dc << m_lpszTemplateName;
dc << "\nm_hDialogTemplate = " << (void*)m_hDialogTemplate;
dc << "\nm_lpDialogTemplate = " << (void*)m_lpDialogTemplate;
dc << "\nm_pParentWnd = " << (void*)m_pParentWnd;
dc << "\nm_nIDHelp = " << m_nIDHelp;
dc << "\n";
}
// diagnostic routine to check for and decode dialog templates
// return FALSE if a program error occurs (i.e. bad resource ID or
// bad dialog styles).
BOOL AFXAPI _AfxCheckDialogTemplate(LPCTSTR lpszResource, BOOL bInvisibleChild)
{
ASSERT(lpszResource != NULL);
HINSTANCE hInst = AfxFindResourceHandle(lpszResource, RT_DIALOG);
HRSRC hResource = ::FindResource(hInst, lpszResource, RT_DIALOG);
if (hResource == NULL)
{
if (DWORD_PTR(lpszResource) > 0xffff)
TRACE(traceAppMsg, 0, _T("ERROR: Cannot find dialog template named %s.\n"),
lpszResource);
else
TRACE(traceAppMsg, 0, "ERROR: Cannot find dialog template with IDD 0x%04X.\n",
LOWORD((DWORD_PTR)lpszResource));
return FALSE;
}
if (!bInvisibleChild)
return TRUE; // thats all we need to check
// we must check that the dialog template is for an invisible child
// window that can be used for a form-view or dialog-bar
HGLOBAL hTemplate = LoadResource(hInst, hResource);
if (hTemplate == NULL)
{
TRACE(traceAppMsg, 0, "Warning: LoadResource failed for dialog template.\n");
// this is only a warning, the real call to CreateDialog will fail
return TRUE; // not a program error - just out of memory
}
DLGTEMPLATEEX* pTemplate = (DLGTEMPLATEEX*)LockResource(hTemplate);
DWORD dwStyle;
if (pTemplate->signature == 0xFFFF)
dwStyle = pTemplate->style;
else
dwStyle = ((DLGTEMPLATE*)pTemplate)->style;
UnlockResource(hTemplate);
FreeResource(hTemplate);
if (dwStyle & WS_VISIBLE)
{
if (DWORD_PTR(lpszResource) > 0xffff)
TRACE(traceAppMsg, 0, _T("ERROR: Dialog named %s must be invisible.\n"),
lpszResource);
else
TRACE(traceAppMsg, 0, "ERROR: Dialog with IDD 0x%04X must be invisible.\n",
LOWORD((DWORD_PTR)lpszResource));
return FALSE;
}
if (!(dwStyle & WS_CHILD))
{
if (DWORD_PTR(lpszResource) > 0xffff)
TRACE(traceAppMsg, 0, _T("ERROR: Dialog named %s must have the child style.\n"),
lpszResource);
else
TRACE(traceAppMsg, 0, "ERROR: Dialog with IDD 0x%04X must have the child style.\n",
LOWORD((DWORD_PTR)lpszResource));
return FALSE;
}
return TRUE;
}
#endif //_DEBUG
IMPLEMENT_DYNAMIC(CDialog, CWnd)
waiting for your valuable response
Thanks and regards
Suresh kan
sure
Continue reading...
i am getting this error when i am debugging the project . error is given below as
File: f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dlgcore.cpp
and dlgcore.cpp is as
#include "stdafx.h"
#include "occimpl.h"
#define new DEBUG_NEW
INT_PTR CALLBACK AfxDlgProc(HWND hWnd, UINT message, WPARAM, LPARAM)
{
if (message == WM_INITDIALOG)
{
// special case for WM_INITDIALOG
CDialog* pDlg = DYNAMIC_DOWNCAST(CDialog, CWnd::FromHandlePermanent(hWnd));
if (pDlg != NULL)
return pDlg->OnInitDialog();
else
return 1;
}
return 0;
}BEGIN_MESSAGE_MAP(CDialog, CWnd)
//{{AFX_MSG_MAP(CDialog)
ON_COMMAND(IDOK, &CDialog::OnOK)
ON_COMMAND(IDCANCEL, &CDialog::OnCancel)
ON_MESSAGE(WM_COMMANDHELP, &CDialog::OnCommandHelp)
ON_MESSAGE(WM_HELPHITTEST, &CDialog::OnHelpHitTest)
ON_MESSAGE(WM_INITDIALOG, &CDialog::HandleInitDialog)
ON_MESSAGE(WM_SETFONT, &CDialog::HandleSetFont)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CDialog:reTranslateMessage(MSG* pMsg)
{
// for modeless processing (or modal)
ASSERT(m_hWnd != NULL);
// allow tooltip messages to be filtered
if (CWnd:reTranslateMessage(pMsg))
return TRUE;
// dont translate dialog messages when in Shift+F1 help mode
CFrameWnd* pFrameWnd = GetTopLevelFrame();
if (pFrameWnd != NULL && pFrameWnd->m_bHelpMode)
return FALSE;
if (pMsg->message == WM_KEYDOWN &&
(pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_CANCEL) &&
:GetWindowLong(pMsg->hwnd, GWL_STYLE) & ES_MULTILINE) &&
_AfxCompareClassName(pMsg->hwnd, _T("Edit")))
{
HWND hItem = ::GetDlgItem(m_hWnd, IDCANCEL);
if (hItem == NULL || ::IsWindowEnabled(hItem))
{
SendMessage(WM_COMMAND, IDCANCEL, 0);
return TRUE;
}
}
// filter both messages to dialog and from children
return PreTranslateInput(pMsg);
}
BOOL CDialog::OnCmdMsg(UINT nID, int nCode, void* pExtra,
AFX_CMDHANDLERINFO* pHandlerInfo)
{if (CWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
if ((nCode != CN_COMMAND && nCode != CN_UPDATE_COMMAND_UI) ||
!IS_COMMAND_ID(nID) || nID >= 0xf000)
{
// control notification or non-command button or system command
return FALSE; // not routed any further
}
// if we have an owner window, give it second crack
CWnd* pOwner = GetParent();
if (pOwner != NULL)
{
TRACE(traceCmdRouting, 1, "Routing command id 0x%04X to owner window.\n", nID);
ASSERT(pOwner != this);
if (pOwner->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
}
// last crack goes to the current CWinThread object
CWinThread* pThread = AfxGetThread();
if (pThread != NULL)
{
TRACE(traceCmdRouting, 1, "Routing command id 0x%04X to app.\n", nID);
if (pThread->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
}
TRACE(traceCmdRouting, 1, "IGNORING command id 0x%04X sent to %hs dialog.\n", nID,
GetRuntimeClass()->m_lpszClassName);
return FALSE;
}
CDialog::CDialog()
{
ASSERT(m_hWnd == NULL);
AFX_ZERO_INIT_OBJECT(CWnd);
}
CDialog::~CDialog()
{
if (m_hWnd != NULL)
{
TRACE(traceAppMsg, 0, "Warning: calling DestroyWindow in CDialog::~CDialog --\n");
TRACE(traceAppMsg, 0, "\tOnDestroy or PostNcDestroy in derived class will not be called.\n");
DestroyWindow();
}
}
void CDialog::OnPaint()
{
CPaintDC dc(this);
if (PaintWindowlessControls(&dc))
return;
Default();
}
BOOL CDialog::Create(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
{
ASSERT(IS_INTRESOURCE(lpszTemplateName) ||
AfxIsValidString(lpszTemplateName));
m_lpszTemplateName = lpszTemplateName; // used for help
if (IS_INTRESOURCE(m_lpszTemplateName) && m_nIDHelp == 0)
m_nIDHelp = LOWORD((DWORD_PTR)m_lpszTemplateName);
#ifdef _DEBUG
if (!_AfxCheckDialogTemplate(lpszTemplateName, FALSE))
{
ASSERT(FALSE); // invalid dialog template name
PostNcDestroy(); // cleanup if Create fails too soon
return FALSE;
}
#endif //_DEBUG
HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);
HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);
HGLOBAL hTemplate = LoadResource(hInst, hResource); //this is break point when i retry debuge
BOOL bResult = CreateIndirect(hTemplate, pParentWnd, hInst);
FreeResource(hTemplate);
return bResult;
}
// for backward compatibility
BOOL CDialog::CreateIndirect(HGLOBAL hDialogTemplate, CWnd* pParentWnd)
{
return CreateIndirect(hDialogTemplate, pParentWnd, NULL);
}
BOOL CDialog::CreateIndirect(HGLOBAL hDialogTemplate, CWnd* pParentWnd,
HINSTANCE hInst)
{
ASSERT(hDialogTemplate != NULL);
LPCDLGTEMPLATE lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
BOOL bResult = CreateIndirect(lpDialogTemplate, pParentWnd, NULL, hInst);
UnlockResource(hDialogTemplate);
return bResult;
}
// for backward compatibility
BOOL CDialog::CreateIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd,
void* lpDialogInit)
{
return CreateIndirect(lpDialogTemplate, pParentWnd, lpDialogInit, NULL);
}
BOOL CDialog::CreateIndirect(LPCDLGTEMPLATE lpDialogTemplate, CWnd* pParentWnd,
void* lpDialogInit, HINSTANCE hInst)
{
ASSERT(lpDialogTemplate != NULL);
if (pParentWnd == NULL)
pParentWnd = AfxGetMainWnd();
m_lpDialogInit = lpDialogInit;
return CreateDlgIndirect(lpDialogTemplate, pParentWnd, hInst);
}
BOOL CWnd::CreateDlg(LPCTSTR lpszTemplateName, CWnd* pParentWnd)
{
// load resource
LPCDLGTEMPLATE lpDialogTemplate = NULL;
HGLOBAL hDialogTemplate = NULL;
HINSTANCE hInst = AfxFindResourceHandle(lpszTemplateName, RT_DIALOG);
HRSRC hResource = ::FindResource(hInst, lpszTemplateName, RT_DIALOG);
hDialogTemplate = LoadResource(hInst, hResource);
if (hDialogTemplate != NULL)
lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
ASSERT(lpDialogTemplate != NULL);
// create a modeless dialog
BOOL bSuccess = CreateDlgIndirect(lpDialogTemplate, pParentWnd, hInst);
// free resource
UnlockResource(hDialogTemplate);
FreeResource(hDialogTemplate);
return bSuccess;
}
BOOL CWnd::CreateDlgIndirect(LPCDLGTEMPLATE lpDialogTemplate,
CWnd* pParentWnd, HINSTANCE hInst)
{
#ifdef _DEBUG
if ( AfxGetApp()->IsKindOf( RUNTIME_CLASS( COleControlModule ) ) )
{
TRACE(traceAppMsg, 0, "Warning: Creating dialog from within a COleControlModule application is not a supported scenario.\n");
}
#endif
ASSERT(lpDialogTemplate != NULL);
if (pParentWnd != NULL)
ASSERT_VALID(pParentWnd);
if(!hInst)
hInst = AfxGetResourceHandle();
#ifndef _AFX_NO_OCC_SUPPORT
_AFX_OCC_DIALOG_INFO occDialogInfo;
COccManager* pOccManager = afxOccManager;
#endif
HGLOBAL hTemplate = NULL;
HWND hWnd = NULL;
#ifdef _DEBUG
DWORD dwError = 0;
#endif
TRY
{
VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTLS_REG));
AfxDeferRegisterClass(AFX_WNDCOMMCTLSNEW_REG);
#ifdef _UNICODE
AfxInitNetworkAddressControl();
#endif
#ifndef _AFX_NO_OCC_SUPPORT
// separately create OLE controls in the dialog template
if (pOccManager != NULL)
{
if (!SetOccDialogInfo(&occDialogInfo))
return FALSE;
lpDialogTemplate = pOccManager->PreCreateDialog(&occDialogInfo,
lpDialogTemplate);
}
if (lpDialogTemplate == NULL)
return FALSE;
#endif //!_AFX_NO_OCC_SUPPORT
// If no font specified, set the system font.
CString strFace;
WORD wSize = 0;
BOOL bSetSysFont = !CDialogTemplate::GetFont(lpDialogTemplate, strFace,
wSize);
if (bSetSysFont)
{
CDialogTemplate dlgTemp(lpDialogTemplate);
dlgTemp.SetSystemFont(wSize);
hTemplate = dlgTemp.Detach();
}
if (hTemplate != NULL)
lpDialogTemplate = (DLGTEMPLATE*)GlobalLock(hTemplate);
// setup for modal loop and creation
m_nModalResult = -1;
m_nFlags |= WF_CONTINUEMODAL;
// create modeless dialog
AfxHookWindowCreate(this);
hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
pParentWnd->GetSafeHwnd(), AfxDlgProc);
#ifdef _DEBUG
dwError = ::GetLastError();
#endif
}
CATCH_ALL(e)
{
DELETE_EXCEPTION(e);
m_nModalResult = -1;
}
END_CATCH_ALL
#ifndef _AFX_NO_OCC_SUPPORT
if (pOccManager != NULL)
{
if (hWnd != NULL)
{
pOccManager->PostCreateDialog(&occDialogInfo);
SetOccDialogInfo(NULL);
}
}
#endif //!_AFX_NO_OCC_SUPPORT
if (!AfxUnhookWindowCreate())
PostNcDestroy(); // cleanup if Create fails too soon
// handle EndDialog calls during OnInitDialog
#ifdef _DEBUG
#ifndef _AFX_NO_OCC_SUPPORT
// Saving the old flag for checking WF_CONTINUEMODAL (if the object has not been destroyed)
// This needs to be after ::CreateDialogIndirect().
DWORD dwOldFlags = 0;
if (hWnd != NULL)
dwOldFlags = m_nFlags;
#endif
#endif
if (hWnd != NULL && !(m_nFlags & WF_CONTINUEMODAL))
{
:estroyWindow(hWnd);
hWnd = NULL;
}
if (hTemplate != NULL)
{
GlobalUnlock(hTemplate);
GlobalFree(hTemplate);
}
// help with error diagnosis (only if WM_INITDIALOG didnt EndDialog())
if (hWnd == NULL)
{
#ifdef _DEBUG
#ifndef _AFX_NO_OCC_SUPPORT
if (dwOldFlags & WF_CONTINUEMODAL)
{
if (afxOccManager == NULL)
{
TRACE(traceAppMsg, 0, >> If this dialog has OLE controls:\n");
TRACE(traceAppMsg, 0, >> AfxEnableControlContainer has not been called yet.\n");
TRACE(traceAppMsg, 0, >> You should call it in your apps InitInstance function.\n");
}
else if (dwError != 0)
{
TRACE(traceAppMsg, 0, "Warning: Dialog creation failed! GetLastError returns 0x%8.8X\n", dwError);
}
}
#ifdef _DEBUG
void CDialog::AssertValid() const
{
CWnd::AssertValid();
}
void CDialog:ump(CDumpContext& dc) const
{
CWnd:ump(dc);
dc << "m_lpszTemplateName = ";
if (IS_INTRESOURCE(m_lpszTemplateName))
dc << (int)LOWORD((DWORD_PTR)m_lpszTemplateName);
else
dc << m_lpszTemplateName;
dc << "\nm_hDialogTemplate = " << (void*)m_hDialogTemplate;
dc << "\nm_lpDialogTemplate = " << (void*)m_lpDialogTemplate;
dc << "\nm_pParentWnd = " << (void*)m_pParentWnd;
dc << "\nm_nIDHelp = " << m_nIDHelp;
dc << "\n";
}
// diagnostic routine to check for and decode dialog templates
// return FALSE if a program error occurs (i.e. bad resource ID or
// bad dialog styles).
BOOL AFXAPI _AfxCheckDialogTemplate(LPCTSTR lpszResource, BOOL bInvisibleChild)
{
ASSERT(lpszResource != NULL);
HINSTANCE hInst = AfxFindResourceHandle(lpszResource, RT_DIALOG);
HRSRC hResource = ::FindResource(hInst, lpszResource, RT_DIALOG);
if (hResource == NULL)
{
if (DWORD_PTR(lpszResource) > 0xffff)
TRACE(traceAppMsg, 0, _T("ERROR: Cannot find dialog template named %s.\n"),
lpszResource);
else
TRACE(traceAppMsg, 0, "ERROR: Cannot find dialog template with IDD 0x%04X.\n",
LOWORD((DWORD_PTR)lpszResource));
return FALSE;
}
if (!bInvisibleChild)
return TRUE; // thats all we need to check
// we must check that the dialog template is for an invisible child
// window that can be used for a form-view or dialog-bar
HGLOBAL hTemplate = LoadResource(hInst, hResource);
if (hTemplate == NULL)
{
TRACE(traceAppMsg, 0, "Warning: LoadResource failed for dialog template.\n");
// this is only a warning, the real call to CreateDialog will fail
return TRUE; // not a program error - just out of memory
}
DLGTEMPLATEEX* pTemplate = (DLGTEMPLATEEX*)LockResource(hTemplate);
DWORD dwStyle;
if (pTemplate->signature == 0xFFFF)
dwStyle = pTemplate->style;
else
dwStyle = ((DLGTEMPLATE*)pTemplate)->style;
UnlockResource(hTemplate);
FreeResource(hTemplate);
if (dwStyle & WS_VISIBLE)
{
if (DWORD_PTR(lpszResource) > 0xffff)
TRACE(traceAppMsg, 0, _T("ERROR: Dialog named %s must be invisible.\n"),
lpszResource);
else
TRACE(traceAppMsg, 0, "ERROR: Dialog with IDD 0x%04X must be invisible.\n",
LOWORD((DWORD_PTR)lpszResource));
return FALSE;
}
if (!(dwStyle & WS_CHILD))
{
if (DWORD_PTR(lpszResource) > 0xffff)
TRACE(traceAppMsg, 0, _T("ERROR: Dialog named %s must have the child style.\n"),
lpszResource);
else
TRACE(traceAppMsg, 0, "ERROR: Dialog with IDD 0x%04X must have the child style.\n",
LOWORD((DWORD_PTR)lpszResource));
return FALSE;
}
return TRUE;
}
#endif //_DEBUG
IMPLEMENT_DYNAMIC(CDialog, CWnd)
waiting for your valuable response
Thanks and regards
Suresh kan
sure
Continue reading...