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 General Discussion » RepositionBars Windows XP x Windows Vista Collapse All
Subject Author Date
Luis Alberto Pereira Jan 1, 2010 - 8:00 AM

Hi all,


I´m using CView class where I put a CExtControlBar. It is working ok when I compile the project um VS2005/Windows XP, but when I compile in VS2008/Windows Vista, the CExtConttrolBar do not work and do not apper in top of the view.


One more detail is that I’m using VTK (www.vtk.org) standart for CView/MFC.


 


Is there some difference in code for this two enviromment ?


 


Thanks all,


 


 


The code is:


 


class CVTKViewAxial : public CView

{

public: // create from serialization only

  CVTKViewAxial();

  DECLARE_DYNCREATE(CVTKViewAxial)



  class CNavigationBar : public CExtToolControlBar

    {

    public:

        CNavigationBar()

        {

        }

        ~CNavigationBar()

        {

        }



    public: //Controls

        CExtComboBox m_cmbDistances;

        CExtComboBox m_cmbPoints;



    public: //methods

        virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam)

        {

            if( message == WM_CONTEXTMENU )

                return 0L;

            if(        message == WM_LBUTTONDOWN

                ||    message == WM_LBUTTONUP

                ||    message == WM_MBUTTONDOWN

                ||    message == WM_MBUTTONUP

                ||    message == WM_RBUTTONDOWN

                ||    message == WM_RBUTTONUP

                )

            {

                HWND hWndThis = GetSafeHwnd();

                ASSERT( hWndThis != NULL );

                ASSERT( ::IsWindow( hWndThis ) );

                HWND hWndParent = ::GetParent( hWndThis );

                ASSERT( hWndParent != NULL );

                ASSERT( ::IsWindow( hWndParent ) );

                HWND hWndFocus = ::GetFocus();

                if(        hWndFocus == NULL

                    ||    hWndFocus == hWndThis

                    ||    ::IsChild( hWndThis, hWndFocus )

                    )

                    ::SetFocus( hWndParent );

                else if( ! ::IsChild( hWndParent, hWndFocus ) )

                    ::SetFocus( hWndParent );

            }

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

        }



        bool InitNavigationBar()

        {

            m_bPresubclassDialogMode = true;

            LPCTSTR pn = AfxGetApp()->m_pszProfileName;



            if( !m_cmbDistances.Create(

                WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,  CRect( 0, 0, 150, 180 ),  this, //&m_wndToolBarMain,

                ID_TBAV_CMBDISTANCES)

               || !this->SetButtonCtrl(this->CommandToIndex(m_cmbDistances.GetDlgCtrlID()), &m_cmbDistances))

            {

                TRACE0("Failed to create help search combobox\n" );

                return -1;

            }

            

            m_cmbDistances.SetItemHeight( -1, 16 );

            

            m_cmbDistances.SetFont( &g_PaintManager->m_FontNormal );

            g_CmdManager->CmdGetPtr(pn, m_cmbDistances.GetDlgCtrlID())->m_sMenuText = _T( "Measures" );



            if( !m_cmbPoints.Create(

                WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,  CRect( 0, 0, 150, 180 ),  this, //&m_wndToolBarMain,

                ID_TBAV_CMBPOINTS)

               || !this->SetButtonCtrl(this->CommandToIndex(m_cmbPoints.GetDlgCtrlID()), &m_cmbPoints))

            {

                TRACE0("Failed to create help search combobox\n" );

                return -1;

            }

            

            m_cmbPoints.SetItemHeight( -1, 16 );

            

            m_cmbPoints.SetFont( &g_PaintManager->m_FontNormal );

            g_CmdManager->CmdGetPtr(pn, m_cmbPoints.GetDlgCtrlID())->m_sMenuText = _T( "Points" );



            return true;



        }

    }; // class CNavigationBar



  CNavigationBar m_wndToolbar;


In the file cpp (code) I create the code:


 


    if ((CView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext))==-1)

        return false;



    this->m_renWin->AddRenderer(this->m_ren);

    //this->m_renWin->SetParentId(this->m_hWnd);

    this->m_renWin->SetParentId(this->GetSafeHwnd());

    this->m_iren->SetRenderWindow(this->m_renWin);



    m_wndToolbar.m_bPresubclassDialogMode = true;

    if( !m_wndToolbar.Create(_T(""), this, AFX_IDW_DIALOGBAR,     WS_CHILD|WS_VISIBLE

                |CBRS_ALIGN_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC))

    {

        ASSERT( FALSE );

        return -1;

    }

    if( !m_wndToolbar.LoadToolBar(IDR_TOOLBAR_AXIALVIEW) )

    {

        ASSERT( FALSE );

        return -1;

    }

    if( !m_wndToolbar.InitNavigationBar() )

        return -1;



    RepositionBars( 0, 0xFFFF, nID );

    return true;

}


 


 

Technical Support Jan 3, 2010 - 8:53 AM

Please take at the end of the code snippet from your .cpp file. The following line is the most interesting:

RepositionBars( 0, 0xFFFF, nID );

The nID variable is the identifier of the window which should occupy the central space which is free of control bars occupying their paces near borders. If the nID variable is set to IDC_STATIC value, then the RepositionBars( 0, 0xFFFF, nID ); code will work well compiled with Visual Studio 2005 or earlier. It will position the central window correctly. But it will not work in Visual Studio 2008 or later. This is specific improvement introduced in Visual Studio 2008. That’s why Prof-UIS uses its own __EXT_MFC_IDC_STATIC value instead of MFC’s IDC_STATIC value.