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 » adding CExtToolControlBar in resizable dialog Collapse All
Subject Author Date
Alexey Zbritsky Jan 28, 2005 - 5:10 AM

I want to use toolbar in resizable dialog, as it done in standard file open/save dialog.


What should I do for add toolbar to dialog (use create, use dialog editor and so on)


And how a can handle messages from buttons.


Thanks,


Sorry for my bad english


 


 

Technical Support Jan 28, 2005 - 11:53 AM

This can be done very easily. We will provide you with the solution based on a dialog resource. Please add a custom control to your dialog. The location of the control is not important. Open its property dialog and fill in all the parameters like in any other custom control in the IDD_PAGE_TOOLBARS dialog resource of the ProfUIS_Controls sample application. Then add:

  • CExtToolControlBar m_wndToolbar; the property to your dialog class.
  • DDX_Control(pDX, IDC_CUSTOM1, m_wndToolBar); the line to the DoDataExchange() method of your dialog class.

You can take a look at the CPageToolbars class of the ProfUIS_Controls sample application to see how it can be done.

To load your toolbar, add the following lines to the CYourDialog::OnInitDialog() method:
ASSERT( m_wndToolBar.GetSafeHwnd() != NULL );
 if( !m_wndToolBar.LoadToolBar( IDR_YOUR_TOOLBAR_RESOURCE ) ){
  ASSERT( FALSE );
  return FALSE;
 }
To stick your toolbar to the dialog window side, do the following:

1) put this line near at the end
CYourDialog::OnInitDialog():
 CWnd::RepositionBars(0,0xFFFF,0); 

2) handle the WM_SIZE windows message:
void CYourDialog::OnSize(UINT nType, int cx, int cy) 
{
 CPageBase::OnSize(nType, cx, cy);
 if( nType != SIZE_MINIMIZED )
  CWnd::RepositionBars(0,0xFFFF,0);
}
The toolbar is now completely initialized and you can handle the WM_COMMAND messages sent from its buttons. Just work with your toolbar commands absolutely like in a CFrameWnd-based application.

Here is the sample of a command handler (the declaration, dialog message map entry, and implementation):
afx_msg void OnLook2005();
ON_COMMAND(IDC_THEME_STUDIO_2005, OnLook2005)
void CYourDialog::OnLook2005() 
{
}
Here is the sample of a command updating handler (the declaration, dialog message map entry, and implementation):
afx_msg void OnUpdateLook2005(CCmdUI* pCmdUI);
ON_UPDATE_COMMAND_UI(IDC_THEME_STUDIO_2005, OnUpdateLook2005)
void CYourDialog::OnUpdateLook2005(CCmdUI* pCmdUI) 
{
 pCmdUI->Enable();
}

That’s all.

Alexey Zbritsky Jan 28, 2005 - 12:21 PM

Thanks, i will try it