المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Trying to create a Tool bar using the class CToolBar



C++ Programming
06-20-2009, 09:31 PM
I am attempting to understand how to use the class CToolBar. Therefore, I wrote some sample
code that is suppose to create a tool bar. However, the tool bar is not being displayed. The
definition of the tool bar is in my class CMainWindow and is defined as follows:
CToolBar toolBar;

Here is the code that I use to create the tool bar:


BOOL status1 = toolBar.Create( this );
BOOL status2 = toolBar.LoadToolBar( IDR_TOOLBAR );
toolBar.SetButtonStyle( 0, TBBS_CHECKBOX );
toolBar.SetButtonStyle( 1, TBBS_CHECKBOX );
toolBar.SetButtonStyle( 2, TBBS_CHECKBOX );
toolBar.SetButtonStyle( 3, TBBS_CHECKBOX );
toolBar.SetButtonStyle( 4, TBBS_CHECKBOX );
toolBar.SetButtonStyle( 5, TBBS_CHECKBOX );

const UINT idArray[] = {
IDM_LINES, IDM_RECTANGLES, IDM_ELLIPSES,
IDM_ENLARGE, IDM_ORG, IDM_RESET
};

toolBar.SetButtons( idArray, 6 );
toolBar.ShowWindow( SW_SHOW );
toolBar.SetSizes( CSize(48,42 ), CSize( 40, 19 ) );

The return value from Create is 1 and the return value from LoadToolBar is 1. The return value from SetButtons is 1. The return value from ShowWindow is 16. I am interpreting these return values to mean that all went well. However, the tool bar is not being displayed. I am hoping that somebody out there can tell me what I am doing wrong.

Thanks

Bob