graber
asked on
Document problem in SDI splitview application
I am having trouble with a SDI application that uses a static Split window. From the standard SDI AppWizard generated I
added two new classes, CSplitWnd:pulic CSplitterWnd and CControlFormView:pulic CFormView. To the CMainFrame
Class I used AppWizard to add the function OnCreateClient, and added a member variable CSplitWnd m_SplitWnd. The
OnCreateClient is nothing strange:
BOOL CMainFrame::OnCreateClient (LPCREATES TRUCT lpcs, CCreateContext* pContext)
{
if(m_SplitWnd.CreateStatic (this, 1, 2))
{
return FALSE;
}
if(m_SplitWnd.CreateView(0 ,0,RUNTIME _CLASS(CCo ntrolFormV iew), CSize(120,300), pContext))
{
return FALSE;
}
if(m_SplitWnd.CreateView(0 ,1,RUNTIME _CLASS(CHa ckView),CS ize(300,30 0),pContex t))
{
return FALSE;
}
m_SplitWnd.SetActivePane(0 ,0);
return TRUE;
}
Everything compiles with the exception of the following three errors.
MainFrm.cpp
*******************\hackvi ew.h(21) : error C2143: syntax error : missing ';' before '*'
*******************\hackvi ew.h(21) : error C2501: 'CHackDoc' : missing storage-class or type specifiers
*******************\hackvi ew.h(21) : error C2501: 'GetDocument' : missing storage-class or type specifiers
All three errors point to the same line:
// Attributes
public:
(21)-> CHackDoc* GetDocument();
In the last application that I used this I remove the document checking and it worked fine. They where used in a
CMDIChildWnd. I seem I can't get away with the same approach here. The results compiles and runs but with strange
results. Let me know what additional information you need and I will gladly provide it. Thanks
Gregg
garaber@fedex.com
added two new classes, CSplitWnd:pulic CSplitterWnd and CControlFormView:pulic CFormView. To the CMainFrame
Class I used AppWizard to add the function OnCreateClient, and added a member variable CSplitWnd m_SplitWnd. The
OnCreateClient is nothing strange:
BOOL CMainFrame::OnCreateClient
{
if(m_SplitWnd.CreateStatic
{
return FALSE;
}
if(m_SplitWnd.CreateView(0
{
return FALSE;
}
if(m_SplitWnd.CreateView(0
{
return FALSE;
}
m_SplitWnd.SetActivePane(0
return TRUE;
}
Everything compiles with the exception of the following three errors.
MainFrm.cpp
*******************\hackvi
*******************\hackvi
*******************\hackvi
All three errors point to the same line:
// Attributes
public:
(21)-> CHackDoc* GetDocument();
In the last application that I used this I remove the document checking and it worked fine. They where used in a
CMDIChildWnd. I seem I can't get away with the same approach here. The results compiles and runs but with strange
results. Let me know what additional information you need and I will gladly provide it. Thanks
Gregg
garaber@fedex.com
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Put a breakpoint in OnNewDocument, trace it from there, find the problem.
Without the code I can't do much.
Without the code I can't do much.
ASKER
BOOL CWinApp::ProcessShellComma nd(CComman dLineInfo& rCmdInfo)
{
BOOL bResult = TRUE;
switch (rCmdInfo.m_nShellCommand)
{
case CCommandLineInfo::FileNew:
if (!AfxGetApp()->OnCmdMsg(ID _FILE_NEW, 0, NULL, NULL))
OnFileNew();
if (m_pMainWnd == NULL)
bResult = FALSE;
break;
it is failing both of the if statement for the new file case when ProcessShellCommand is called from the apps InitInstance()
{
BOOL bResult = TRUE;
switch (rCmdInfo.m_nShellCommand)
{
case CCommandLineInfo::FileNew:
if (!AfxGetApp()->OnCmdMsg(ID
OnFileNew();
if (m_pMainWnd == NULL)
bResult = FALSE;
break;
it is failing both of the if statement for the new file case when ProcessShellCommand is called from the apps InitInstance()
I know that, you've said it.
But try stepping into those functions and see where, in the MFC source code, it stops working.
But try stepping into those functions and see where, in the MFC source code, it stops working.
ASKER
Mfc\Src\Cmdtarg.cpp
AFX_STATIC BOOL AFXAPI _AfxDispatchCmdMsg(CCmdTar get* pTarget, UINT nID, int nCode, AFX_PMSG pfn, void* pExtra, UINT nSig, AFX_CMDHANDLERINFO* pHandlerInfo)
// return TRUE to stop routing
{
ASSERT_VALID(pTarget);
UNUSED(nCode); // unused in release builds
union MessageMapFunctions mmf;mmf.pfn = pfn; BOOL bResult = TRUE;
// default is ok
if (pHandlerInfo != NULL)
{
// just fill in the information, don't do it
pHandlerInfo->pTarget = pTarget;
pHandlerInfo->pmf = mmf.pfn;
return TRUE;
}
switch (nSig)
{
case AfxSig_vv:
// normal command or control notification
ASSERT(CN_COMMAND == 0); // CN_COMMAND same as BN_CLICKED
ASSERT(pExtra == NULL);
****(pTarget->*mmf.pfn_COM MAND)();** ********** ********** ********** ********** ********** *
break;
This is the value of pTarget when it fails
-pTarget 0x00417850 class CHackApp theApp
+CObject {CObject}
+classCCmdTarget {"CCmdTarget"}
+_messageEntries 0x5f4b54a8 struct AFX_MSGMAP_ENTRY const * const CCmdTarget::_messageEntrie s
+messageMap {...}
+_commandEntries 0x5f4b5558 struct AFX_OLECMDMAP_ENTRY const * const CCmdTarget::_commandEntrie s
+commandMap {...}
+_dispatchEntries 0x5f4b54d0 struct AFX_DISPMAP_ENTRY const * const CCmdTarget::_dispatchEntri es
_dispatchEntryCount 4294967295
_dwStockPropMask 4294967295
+dispatchMap {...}
+_connectionEntries 0x5f4b5548 struct AFX_CONNECTIONMAP_ENTRY const * const CCmdTarget::_connectionEnt ries
+connectionMap {...}
+_interfaceEntries 0x5f4b5530 struct AFX_INTERFACEMAP_ENTRY const * const CCmdTarget::_interfaceEntr ies
+interfaceMap {...}
+_eventsinkEntries 0x5f4b5500 struct AFX_EVENTSINKMAP_ENTRY const * const CCmdTarget::_eventsinkEntr ies
_eventsinkEntryCount 4294967295
+eventsinkMap {...}
m_dwRef 1
+m_pOuterUnknown 0x00000000
m_xInnerUnknown 0
+m_xDispatch {...}
m_bResultExpected 1
+m_xConnPtContainer {...}
+m_pModuleState 0x00420078
AFX_STATIC BOOL AFXAPI _AfxDispatchCmdMsg(CCmdTar
// return TRUE to stop routing
{
ASSERT_VALID(pTarget);
UNUSED(nCode); // unused in release builds
union MessageMapFunctions mmf;mmf.pfn = pfn; BOOL bResult = TRUE;
// default is ok
if (pHandlerInfo != NULL)
{
// just fill in the information, don't do it
pHandlerInfo->pTarget = pTarget;
pHandlerInfo->pmf = mmf.pfn;
return TRUE;
}
switch (nSig)
{
case AfxSig_vv:
// normal command or control notification
ASSERT(CN_COMMAND == 0); // CN_COMMAND same as BN_CLICKED
ASSERT(pExtra == NULL);
****(pTarget->*mmf.pfn_COM
break;
This is the value of pTarget when it fails
-pTarget 0x00417850 class CHackApp theApp
+CObject {CObject}
+classCCmdTarget {"CCmdTarget"}
+_messageEntries 0x5f4b54a8 struct AFX_MSGMAP_ENTRY const * const CCmdTarget::_messageEntrie
+messageMap {...}
+_commandEntries 0x5f4b5558 struct AFX_OLECMDMAP_ENTRY const * const CCmdTarget::_commandEntrie
+commandMap {...}
+_dispatchEntries 0x5f4b54d0 struct AFX_DISPMAP_ENTRY const * const CCmdTarget::_dispatchEntri
_dispatchEntryCount 4294967295
_dwStockPropMask 4294967295
+dispatchMap {...}
+_connectionEntries 0x5f4b5548 struct AFX_CONNECTIONMAP_ENTRY const * const CCmdTarget::_connectionEnt
+connectionMap {...}
+_interfaceEntries 0x5f4b5530 struct AFX_INTERFACEMAP_ENTRY const * const CCmdTarget::_interfaceEntr
+interfaceMap {...}
+_eventsinkEntries 0x5f4b5500 struct AFX_EVENTSINKMAP_ENTRY const * const CCmdTarget::_eventsinkEntr
_eventsinkEntryCount 4294967295
+eventsinkMap {...}
m_dwRef 1
+m_pOuterUnknown 0x00000000
m_xInnerUnknown 0
+m_xDispatch {...}
m_bResultExpected 1
+m_xConnPtContainer {...}
+m_pModuleState 0x00420078
ASKER
Adjusted points to 150
Is that a VC5 or VC6 project? if it's VC5 (our project hasn't moved to vc6 yet) could you zip the files and mail them to me? i will run it and debug it, it doesn't look like a big thing but I don't think we can solve it via this question ;-)
Your OnCreateClient code is flawed:
if(m_SplitWnd.CreateStatic (this, 1, 2))
{
return FALSE;
}
if(m_SplitWnd.CreateView(0 ,0,RUNTIME _CLASS(CCo ntrolFormV iew), CSize(120,300), pContext))
{
return FALSE;
}
if(m_SplitWnd.CreateView(0 ,1,RUNTIME _CLASS(CHa ckView),CS ize(300,30 0),pContex t))
{
return FALSE;
}
Here it is, the right thing:
if(!m_SplitWnd.CreateStati c(this, 1, 2))
{
return FALSE;
}
if(!m_SplitWnd.CreateView( 0,0,RUNTIM E_CLASS(CC ontrolForm View), CSize(120,300), pContext))
{
return FALSE;
}
if(!m_SplitWnd.CreateView( 0,1,RUNTIM E_CLASS(CH ackView),C Size(300,3 00),pConte xt))
{
return FALSE;
}
In your CMainFrame::OnCreateClient , you were not handling return values correctly and prevented the creation of the mainframe.
Also at first i could not set breakpoints, in your C/C++ settings the debug info was set to none, it yshould be Program Database for a debug build.
Hope it helps,
ps: the views don't seem to draw anything, but that's something to come i guess.
if(m_SplitWnd.CreateStatic
{
return FALSE;
}
if(m_SplitWnd.CreateView(0
{
return FALSE;
}
if(m_SplitWnd.CreateView(0
{
return FALSE;
}
Here it is, the right thing:
if(!m_SplitWnd.CreateStati
{
return FALSE;
}
if(!m_SplitWnd.CreateView(
{
return FALSE;
}
if(!m_SplitWnd.CreateView(
{
return FALSE;
}
In your CMainFrame::OnCreateClient
Also at first i could not set breakpoints, in your C/C++ settings the debug info was set to none, it yshould be Program Database for a debug build.
Hope it helps,
ps: the views don't seem to draw anything, but that's something to come i guess.
ASKER