Solved

Document problem in SDI splitview application

Posted on 1998-11-18
9
392 Views
Last Modified: 2013-11-20
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(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
    if(m_SplitWnd.CreateStatic(this, 1, 2))
    {
        return FALSE;
    }
    if(m_SplitWnd.CreateView(0,0,RUNTIME_CLASS(CControlFormView), CSize(120,300), pContext))
    {
        return FALSE;
    }
    if(m_SplitWnd.CreateView(0,1,RUNTIME_CLASS(CHackView),CSize(300,300),pContext))
    {
        return FALSE;
    }
    m_SplitWnd.SetActivePane(0,0);
    return TRUE;
}

Everything compiles with the exception of the following three errors.
MainFrm.cpp
*******************\hackview.h(21) : error C2143: syntax error : missing ';' before '*'
*******************\hackview.h(21) : error C2501: 'CHackDoc' : missing storage-class or type specifiers
*******************\hackview.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
0
Comment
Question by:graber
  • 5
  • 4
9 Comments
 
LVL 3

Accepted Solution

by:
plaroche earned 150 total points
ID: 1324920
Your MainFrm.cpp seems to include hackview.h, and that hackview.h does not at that moment know what CHackDoc is.

Add this line before
   class CHackView : public CView

class CHackDoc;

what this does is "predeclare" the class, so that your file compiles. if this doesn't work simply include in hackview.h the document header file.

0
 
LVL 2

Author Comment

by:graber
ID: 1324921
Can you give me some more information?  I caught header problem in one of those forehead slapping routines and corrected it.  Now it is coming back saying that it has failed to create an empty document.  Can you still help?
0
 
LVL 3

Expert Comment

by:plaroche
ID: 1324922
Put a breakpoint in OnNewDocument, trace it from there, find the problem.
Without the code I can't do much.
0
 
LVL 2

Author Comment

by:graber
ID: 1324923
BOOL CWinApp::ProcessShellCommand(CCommandLineInfo& 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()
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:plaroche
ID: 1324924
I know that, you've said it.
But try stepping into those functions and see where, in the MFC source code, it stops working.
0
 
LVL 2

Author Comment

by:graber
ID: 1324925
Mfc\Src\Cmdtarg.cpp

AFX_STATIC BOOL AFXAPI _AfxDispatchCmdMsg(CCmdTarget* 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_COMMAND)();*****************************************************
    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::_messageEntries
+messageMap  {...}
+_commandEntries 0x5f4b5558 struct AFX_OLECMDMAP_ENTRY const * const                               CCmdTarget::_commandEntries
+commandMap  {...}
+_dispatchEntries      0x5f4b54d0 struct AFX_DISPMAP_ENTRY const * const                              CCmdTarget::_dispatchEntries
                            _dispatchEntryCount      4294967295
                            _dwStockPropMask      4294967295
+dispatchMap      {...}
+_connectionEntries 0x5f4b5548 struct AFX_CONNECTIONMAP_ENTRY const *                                           const  CCmdTarget::_connectionEntries
+connectionMap      {...}
+_interfaceEntries      0x5f4b5530 struct AFX_INTERFACEMAP_ENTRY const * const                              CCmdTarget::_interfaceEntries
+interfaceMap      {...}
+_eventsinkEntries      0x5f4b5500 struct AFX_EVENTSINKMAP_ENTRY const * const                              CCmdTarget::_eventsinkEntries
                            _eventsinkEntryCount      4294967295
+eventsinkMap      {...}
                            m_dwRef      1
+m_pOuterUnknown 0x00000000
                              m_xInnerUnknown      0
+m_xDispatch      {...}
                    m_bResultExpected      1
+m_xConnPtContainer      {...}
+m_pModuleState      0x00420078

0
 
LVL 2

Author Comment

by:graber
ID: 1324926
Adjusted points to 150
0
 
LVL 3

Expert Comment

by:plaroche
ID: 1324927
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 ;-)
0
 
LVL 3

Expert Comment

by:plaroche
ID: 1324928
Your OnCreateClient code is flawed:

      if(m_SplitWnd.CreateStatic(this, 1, 2))
      {
            return FALSE;
      }
      if(m_SplitWnd.CreateView(0,0,RUNTIME_CLASS(CControlFormView), CSize(120,300), pContext))
      {
            return FALSE;
      }
      if(m_SplitWnd.CreateView(0,1,RUNTIME_CLASS(CHackView),CSize(300,300),pContext))
      {
            return FALSE;
      }


Here it is, the right thing:

      if(!m_SplitWnd.CreateStatic(this, 1, 2))
      {
            return FALSE;
      }
      if(!m_SplitWnd.CreateView(0,0,RUNTIME_CLASS(CControlFormView), CSize(120,300), pContext))
      {
            return FALSE;
      }
      if(!m_SplitWnd.CreateView(0,1,RUNTIME_CLASS(CHackView),CSize(300,300),pContext))
      {
            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.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expand macro to ask for filename column 8 36
Tab names are off by one 5 53
Process filename extension 3 172
matchUp  challenge 9 91
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now