Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » CExtResizableDialog question Collapse All
Subject Author Date
tera tera Jun 17, 2009 - 2:02 AM

Hello.


 


cTest2Dlg.Create(  CTest2Dlg::IDD,     this );


 


 


By a program, I make Dialog with Create.


By mouse double click, I terminate a dialog.





Then the following menus were permanently displayed.



I ask for a revision.


 

Technical Support Jun 17, 2009 - 9:16 AM

Thank you for reporting this issue. To fix it, please update the source code for the CExtWS::WindowProc() method:

 virtual LRESULT WindowProc(
            UINT message,
            WPARAM wParam,
            LPARAM lParam
            ) 
      {
            if(         (     message == WM_CREATE 
                        &&    (!(   IsKindOf( RUNTIME_CLASS(CDialog) )
                              ||    IsKindOf( RUNTIME_CLASS(CPropertyPage) )
                              ||    IsKindOf( RUNTIME_CLASS(CPropertySheet) )
                              ))
                        )
                  ||    message == WM_INITDIALOG
                  )
            {
                  LRESULT lResult = CExtWSBase::WindowProc( message, wParam, lParam );
                  _InitSizeGripper();
                  if( m_bAutoSubclassChildControls )
                        SubclassChildControls();
                  return lResult;
            }

            if( message == WM_WINDOWPOSCHANGED )
            {
                  LRESULT lResult = CExtWSBase::WindowProc( message, wParam, lParam );
            
                  LPWINDOWPOS lpWindowPos = 
                        reinterpret_cast < LPWINDOWPOS > (lParam);
                  ASSERT( lpWindowPos != NULL );

                  if(         m_wndGripper.m_hWnd != NULL 
                        &&    ::IsWindow( m_wndGripper.m_hWnd )
                        )
                  {

                        __EXT_MFC_LONG_PTR dwExStyle = ::__EXT_MFC_GetWindowLong( GetSafeHwnd(), GWL_EXSTYLE );
                        bool bRTL = ( (dwExStyle & WS_EX_LAYOUTRTL) != 0 ) ? true : false;
                        if( m_bGripperRTL != bRTL )
                              _InitSizeGripper();

                        CRect rcClient;               
                        GetClientRect( &rcClient );
                  
                        CSize szGripperSize = 
                              PmBridge_GetPM()->GetResizingGriperSize( this );

                        m_wndGripper.SetWindowPos(
                              NULL,
                              rcClient.right - szGripperSize.cx,
                              rcClient.bottom - szGripperSize.cy,
                              0, 
                              0,
                              SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOACTIVATE
                              );

                        m_wndGripper.Invalidate();
                        m_wndGripper.UpdateWindow();
                  }

                  if( (lpWindowPos->flags&SWP_NOSIZE) != 0 )
                        return lResult;

                  if(         ::IsWindowVisible( m_hWnd ) 
                        // - 2.64
                        // && PmBridge_GetPM()->GetCb2DbTransparentMode( this )
                        )
                  {
                        // if m_hWnd is dialog, then redraw all child controls
                        bool bDlg = false;
                        TCHAR strClassName[ _MAX_PATH + 1 ] = _T("");
                        ::GetClassName( m_hWnd, strClassName, _MAX_PATH );
                        if( _tcscmp( strClassName, _T("#32770") ) == 0 )
                              bDlg = true;
                        if( bDlg )
                        {
                              RedrawWindow( NULL, NULL, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ERASENOW| RDW_NOCHILDREN|RDW_NOFRAME );
                              for( CWnd * pWnd = this->GetWindow(GW_CHILD); pWnd != NULL; pWnd = pWnd->GetWindow(GW_HWNDNEXT) )
                              {
                                    if( (pWnd->GetStyle() & WS_VISIBLE) == 0 )
                                          continue;
                                    pWnd->RedrawWindow( NULL, NULL, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ERASENOW|RDW_NOFRAME );
                              }
                        } // if( bDlg )
                  }

                  return lResult;
            } // if( message == WM_WINDOWPOSCHANGED )

            if(         message == WM_PRINT 
                  ||    message == WM_PRINTCLIENT
                  )
            {
                  CExtWSBase::WindowProc( message, wParam, lParam );
                  
                  CDC dc;
                  dc.Attach( (HDC)wParam );

                  CRect rcRgnWnd, rcRgnClient;
                  GetWindowRect( &rcRgnWnd );
                  GetClientRect( &rcRgnClient );
                  
                  if( (lParam&(PRF_CLIENT|PRF_ERASEBKGND)) != 0 )
                  {
                        CPoint ptVpOffset( 0, 0 );
                        if( (lParam&PRF_NONCLIENT) != 0 )
                        {
                              CRect rcWnd = rcRgnWnd, rcClient = rcRgnClient;
                              ClientToScreen( &rcClient );
                              ptVpOffset.x = rcWnd.left - rcClient.left;
                              ptVpOffset.y = rcWnd.top - rcClient.top;
                        }

                        if(         ptVpOffset.x != 0
                              ||    ptVpOffset.y != 0
                              )
                              dc.OffsetViewportOrg(
                                    -ptVpOffset.x,
                                    -ptVpOffset.y
                                    );

                        for(  CWnd * pWnd = GetWindow( GW_CHILD );
                                    pWnd != NULL && pWnd != this;
                                    pWnd = pWnd->GetWindow( GW_HWNDNEXT )
                              )
                        {
                              if( (pWnd->GetStyle() & WS_VISIBLE) == 0 )
                                    continue;
                              CRect rcChild;
                              pWnd->GetWindowRect( &rcChild );
                              ScreenToClient( &rcChild );
                              dc.ExcludeClipRect( &rcChild );
                        }
                        
                        COLORREF clrBackground = GetBkColor();
                        bool bTransparent = false;
                        if(         PmBridge_GetPM()->GetCb2DbTransparentMode(this)
                              &&    ( clrBackground == COLORREF(-1L) )
                              )
                        {
                              CExtPaintManager::stat_ExcludeChildAreas(
                                    dc,
                                    GetSafeHwnd(),
                                    CExtPaintManager::stat_DefExcludeChildAreaCallback
                                    );
                              if( PmBridge_GetPM()->PaintDockerBkgnd( true, dc, this ) )
                                    bTransparent = true;
                        }
                        if(         (! bTransparent)
                              &&    clrBackground != COLORREF(-1L)
                              )
                              dc.FillSolidRect(
                                    &rcRgnClient,
                                    clrBackground
                                    );    

                        dc.SelectClipRgn( NULL );

                        PmBridge_GetPM()->OnPaintSessionComplete( this );

                        if(         ptVpOffset.x != 0
                              ||    ptVpOffset.y != 0
                              )
                              dc.OffsetViewportOrg(
                                    ptVpOffset.x,
                                    ptVpOffset.y
                                    );
                  } // if( (lParam&(PRF_CLIENT|PRF_ERASEBKGND)) != 0 )
                  
                  if( (lParam&PRF_CHILDREN) != 0 )
                        CExtPaintManager::stat_PrintChildren(
                              m_hWnd,
                              message,
                              dc.GetSafeHdc(),
                              lParam,
                              false
                              );
                  dc.Detach();
                  return (!0);
            }

            if( message == WM_PAINT )
            {
                  ASSERT_VALID( this );

                  bool bDlg = IsKindOf(RUNTIME_CLASS(CDialog)) ? true : false;
                  if( !bDlg )
                  {
                        TCHAR strClassName[ _MAX_PATH + 1 ] = _T("");
                        ::GetClassName( m_hWnd, strClassName, _MAX_PATH );
                        __EXT_MFC_STRLWR( strClassName, _MAX_PATH + 1 );
                        if( _tcsstr( strClassName, _T("#") ) != NULL )
                              bDlg = true;
                  }

                  // look through the message map to see 
                  // if this message is handled by user
                  const AFX_MSGMAP_ENTRY * lpEntry = 
                        _FindMessageMapHandler(
                              message,
                              0, 0
                        );
                  
                  bool bPainted = false;
                  //if( !(bDlg && GetParent() == NULL) ) 
                  if( !bDlg ) 
                  {
                        if( lpEntry != NULL )
                        {
                              // invoke the user defined message handler
                              union 
                              {
                                    AFX_PMSG pfn;
                                    void (AFX_MSG_CALL CCmdTarget::*pfn_COMMAND)();
                              } mmf;
                              mmf.pfn = lpEntry->pfn;
                              (this->*mmf.pfn_COMMAND)();
                              // return 0L;
                              bPainted = true;
                        } // if( lpEntry != NULL )
                  }

                  if( !bPainted )
                  {
                        CPaintDC dc( this );
                        COLORREF clrBackground = GetBkColor();
                        bool bTransparent = false;
                        if(         PmBridge_GetPM()->GetCb2DbTransparentMode(this)
                              &&    ( clrBackground == COLORREF(-1L) )
                              )
                        {
                              CExtPaintManager::stat_ExcludeChildAreas(
                                    dc,
                                    GetSafeHwnd(),
                                    CExtPaintManager::stat_DefExcludeChildAreaCallback
                                    );
                              if( PmBridge_GetPM()->PaintDockerBkgnd( true, dc, this ) )
                                    bTransparent = true;
                        }
                        if(         (! bTransparent)
                              &&    clrBackground != COLORREF(-1L)
                              )
                        {
                              CRect rcClient;
                              GetClientRect( &rcClient );
                              dc.FillSolidRect(
                                    &rcClient,
                                    clrBackground
                                    );    
                        }
                        PmBridge_GetPM()->OnPaintSessionComplete( this );
                  }

//                if( bDlg && GetParent() == NULL ) 
                  if( bDlg ) 
                  {
                        if( lpEntry != NULL )
                        {
                              // invoke the user defined message handler
                              union 
                              {
                                    AFX_PMSG pfn;
                                    void (AFX_MSG_CALL CCmdTarget::*pfn_COMMAND)();
                              } mmf;
                              mmf.pfn = lpEntry->pfn;
                              (this->*mmf.pfn_COMMAND)();
                              return 0L;
                        } // if( lpEntry != NULL )
                  }

                  return 0L;
            } // if( message == WM_PAINT )

            if( message == WM_ERASEBKGND )
            {
                  ASSERT_VALID( this );

                  // look through the message map to see 
                  // if this message is handled by user
                  const AFX_MSGMAP_ENTRY * lpEntry = 
                        _FindMessageMapHandler(
                              message,
                              0, 0
                        );
                  if( lpEntry != NULL )
                  {
                        // invoke the user defined message handler
                        union 
                        {
                              AFX_PMSG pfn;
                              BOOL (AFX_MSG_CALL CWnd::*pfn_bD)( CDC* );
                        } mmf;
                        mmf.pfn = lpEntry->pfn;
                        LRESULT lResult = 
                              (this->*mmf.pfn_bD)( CDC::FromHandle( ( HDC ) wParam ) );
                        return lResult;
                  } // if( lpEntry != NULL )

                  HDC hDC = reinterpret_cast < HDC > (wParam);
                  ASSERT( hDC != NULL );
                  HWND hWnd = ::WindowFromDC( hDC );
                  if(         hWnd != NULL
                        &&    hWnd != m_hWnd
                        )
                        return CExtWSBase::WindowProc( message, wParam, lParam );

                  if(         (GetStyle() & WS_CLIPCHILDREN) != 0
                        &&    PmBridge_GetPM()->GetCb2DbTransparentMode(this)
                        )
                        return (!0L);

//                HDC hDC = reinterpret_cast < HDC > (wParam);
//                ASSERT( hDC != NULL );
                  CExtPaintManager::stat_ExcludeChildAreas(
                        hDC,
                        GetSafeHwnd(),
                        CExtPaintManager::stat_DefExcludeChildAreaCallback
                        );

                  return CExtWSBase::WindowProc( message, wParam, lParam );

            } // if( message == WM_ERASEBKGND )

            if( message >= WM_CTLCOLORMSGBOX && message <= WM_CTLCOLORSTATIC )
            {
                  HBRUSH hBrush = (HBRUSH)
                        CExtWSBase::WindowProc( message, wParam, lParam );
                  HDC hDC =
                        __EXT_GET_WM_CTLCOLOR_HDC(wParam,lParam,message);
                  HWND hWnd =
                        __EXT_GET_WM_CTLCOLOR_HWND(wParam,lParam,message);
                  ASSERT( hWnd != NULL );
                  INT nCtlColor =
                        __EXT_GET_WM_CTLCOLOR_TYPE(wParam,lParam,message);
                  if(         nCtlColor == CTLCOLOR_DLG
                        ||    nCtlColor == CTLCOLOR_STATIC
                        ||    nCtlColor == CTLCOLOR_MSGBOX
                        )
                  {
                        if( nCtlColor == CTLCOLOR_STATIC )
                        {
                              bool bDefaultProcessing = false;
                              if( hWnd == NULL || (! ::IsWindow(hWnd) ) )
                                    bDefaultProcessing = true;
                              else
                              {
                                    CExtSafeString sClassName;
                                    ::GetClassName(
                                          hWnd,
                                          LPTSTR( sClassName.GetBuffer( _MAX_PATH+1 ) ),
                                          _MAX_PATH
                                          );
                                    sClassName.ReleaseBuffer();
                                    sClassName.MakeLower();
                                    if( sClassName != LPCTSTR( _T("static") ) )
                                          bDefaultProcessing = true;
                                    //else
                                    //{
                                    //    CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
                                    //    if(         pWnd == NULL
                                    //          ||    (! pWnd->IsKindOf(RUNTIME_CLASS(CExtLabel)) )
                                    //          )
                                    //          bDefaultProcessing = true;
                                    //} // else from if( sClassName != LPCTSTR( _T("static") ) )
                                    if( bDefaultProcessing )
                                          return (LRESULT)hBrush;
                              } // else from if( hWnd == NULL || (! ::IsWindow(hWnd) ) )
                              ::SetBkMode( hDC, TRANSPARENT );
                              // (+ v.2.22) corrected by the Dmitry Yakovlev’s advice
                              if(         (GetStyle()&WS_CHILD) != 0
                                    &&    PmBridge_GetPM()->GetCb2DbTransparentMode(this)
                                    )
                                    return (LRESULT)::GetStockObject( NULL_BRUSH );
                        }
                        static CBrush brBackground;
                        static COLORREF clrLast = (COLORREF)(-1L);
                        COLORREF clrNew =
                              PmBridge_GetPM()->GetColor(
                                    CExtPaintManager::CLR_3DFACE_OUT,
                                    this
                                    );
                        if( clrLast != clrNew )
                        {
                              if( brBackground.GetSafeHandle() != NULL )
                                    brBackground.DeleteObject();
                        }
                        if( brBackground.GetSafeHandle() == NULL )
                        {
                              clrLast = clrNew;
                              VERIFY(
                                    brBackground.CreateSolidBrush( clrLast )
                                    );
                        } // if( brBackground.GetSafeHandle() == NULL )
                        return (LRESULT)brBackground.GetSafeHandle();
                  }
                  return (LRESULT)hBrush;
            } // if( message >= WM_CTLCOLORMSGBOX && message <= WM_CTLCOLORSTATIC )

            if( message == WM_TIMER )
            {
                  if( wParam == nIdTimerSysMenuTracking )
                  {
                        if( !CExtPopupMenuWnd::IsMenuTracking() )
                        {
                              m_bSysMenuTracking = false;
                              KillTimer( nIdTimerSysMenuTracking );
                        }
                        return 0;
                  }
                  return CExtWSBase::WindowProc( message, wParam, lParam );
            } // if( message == WM_TIMER )

            if( message == WM_DESTROY )
            {
                  if( m_bEnableSaveRestore )
                        SaveWindowRect();
                  return CExtWSBase::WindowProc( message, wParam, lParam );
            }

            if(         (message == WM_NCLBUTTONDOWN && wParam == HTSYSMENU)
                  ||    (message == WM_NCRBUTTONUP && (wParam == HTCAPTION || wParam == HTSYSMENU))
                  )
            {
                  if( wParam == HTCAPTION )
                  {
                        CPoint point;
                        if( ::GetCursorPos( &point ) )
                              _TrackWndSystemPopupMenu(
                                    &point,
                                    FALSE
                                    );
                  } // if( wParam == HTCAPTION )
                  else
                  {
                        _TrackWndSystemPopupMenu(
                              NULL,
                              FALSE
                              );
                  } // else if if( wParam == HTCAPTION )
                  return 0;
            }
            if( (message == WM_NCLBUTTONDOWN || message == WM_NCRBUTTONDOWN )
                  && wParam == HTSYSMENU
                  )
                  return 0;
            if( (message == WM_NCLBUTTONDBLCLK )
                  && wParam == HTSYSMENU
                  )
                  CExtPopupMenuWnd::CancelMenuTracking();
            if( message == WM_NCRBUTTONDOWN && wParam == HTCAPTION )
            {
                  CPoint point;
                  if( ::GetCursorPos( &point ) )
                        _TrackWndSystemPopupMenu(
                              &point,
                              FALSE
                              );
                  return 0;
            }

            return CExtWSBase::WindowProc( message, wParam, lParam );
      }