Problem with create style of CChildFrame

This is a discussion on Problem with create style of CChildFrame within the Windows Programming forums, part of the Platform Specific Boards category; I am creating MDI project using extended classes : CMDIFrameWndExCWinAppExCMDIChildWndExMy view class is derived from CScrollView.Code is working fine if ...

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    7

    Problem with create style of CChildFrame

    I am creating MDI project using extended classes : CMDIFrameWndExCWinAppExCMDIChildWndExMy view class is derived from CScrollView.Code is working fine if I don't apply any style to Child window in PreCreateWindow. But when i apply style with visibility true then some debug assertion comes.On debugging further i came to know that asertion comes in below block while redrawing window.
    Code:
    void CMFCBaseTabCtrl::SetLocation(Location location)
    {
    ASSERT_VALID(this);
    m_location = location;
    RecalcLayout();
    if (GetSafeHwnd() != NULL)
    {
    GetParent()->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_ALLCHILDREN);
    }
    }
    other thing which i noticed is that when child window is created with style with WS_VISIBLE then Ondraw() of view class is called before OnInitialUpdate()

    My code and logic was working fine without using extended classes so i don't want to change it as it would be a lot of re-work. So can anybody guide me what to do ?

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    I have not used MDI for some years.....You need to narrow down the issue (eliminte possibilities until the cause is revealed).

    What reason/code is in the assert()?

    Check the parent and child OnPaint() methods and find which one the assert() is thrown (conditional breakpoints will help in the OnPaint()'s ).

    Use differing flags to reduce the scope of the redraw (RDW_NOCHILDREN)

    Are you using the clip children style?

    Use the parents client/window rect as the rect to redraw (rather than null).

    Is GetLastError() giving any meaningfull info?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Sep 2010
    Posts
    7

    Problem with create style of CChildFrame

    To reproduce the assertion:

    Just create a new project and inherit the view class with CSrcollView. Extend your classes with
    CMDIFrameWndEx, CMDIChildWndEx, CWinAppEx
    repectively. Set scroll size in oninitialupdate of view class. Now run the progam without opening any window on startup. Open the document. New tab is created. Its working fine. Now add following lines in
    CChildFrame::PreCreateWindow(CREATESTRUCT& cs)


    Code:
    cs.style = WS_CHILD | WS_VISIBLE | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | FWS_ADDTOTITLE | WS_EX_CLIENTEDGE | WS_MAXIMIZEBOX | WS_MAXIMIZE;

    Now u will get assertion at:


    Code:
     
    void CScrollView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
    {
    ...
    #ifdef
    _DEBUG 
    if (m_nMapMode == MM_NONE){ 
    TRACE(traceAppMsg, 0,
    "Error: must call SetScrollSizes() or SetScaleToFitSize()"); 
    TRACE(traceAppMsg, 0)
    "\tbefore painting scroll view.\n"); 
    ASSERT(FALSE);
    return;
    }

    If i remove WS_VISIBLE style, then there is no assertion. I don't know the reason.
    To resolve this i just added

    Code:
     m_nMapMode = MM_TEXT;
    in constructor of view class.
    So it is working fine. But still i don't understand why OnDraw is called before OnInitialUpdate() in this case as this is totally shaking my logic.

    Now my actual problem starts. I have to call a function of a class in OnInitialUpdate. In that function I have to point view class object. i am getting view class like

    (MyViewClass*)((CMDIFrameWnd*)AfxGetMainWnd())->MDIGetActive()->GetActiveView())


    on further modularising above line i came to know that MDIGetActive is returning null.

    now can anyone help me out.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 05:23 AM
  2. Problem with Vectors And Pointers
    By Shamino in forum Game Programming
    Replies: 3
    Last Post: 01-21-2006, 06:23 PM
  3. winxp style background color problem
    By johny145 in forum Windows Programming
    Replies: 0
    Last Post: 07-06-2005, 10:22 AM
  4. Bitmap/Icon Toolbar Problem
    By loko in forum Windows Programming
    Replies: 3
    Last Post: 02-09-2005, 09:20 AM
  5. Style sheet problem.
    By adrianxw in forum Tech Board
    Replies: 1
    Last Post: 05-04-2003, 05:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21