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;
}