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 » Mis-aligned toolbar icons Collapse All
Subject Author Date
Clive Minnican Nov 2, 2004 - 4:19 PM


I am using v2.26 freeware and have created a 256 colour bitmap for use as a toolbar:


http://www.lightwave-design.com/toolbar/toolbaricons.bmp


 


I am attempting to display the toolbar with the following code:


int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)


{


CWinApp * pApp = ::AfxGetApp();


//


ASSERT( pApp != NULL );


ASSERT( pApp->m_pszRegistryKey != NULL );


ASSERT( pApp->m_pszRegistryKey[0] != _T(’\0’) );


ASSERT( pApp->m_pszProfileName != NULL );


ASSERT( pApp->m_pszProfileName[0] != _T(’\0’) );


//


if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)


return -1;


//


ASSERT( pApp->m_pszProfileName != NULL );


g_CmdManager->ProfileSetup(


pApp->m_pszProfileName,


GetSafeHwnd()


);


VERIFY(


g_CmdManager->ProfileWndAdd(


pApp->m_pszProfileName,


GetSafeHwnd()


)


);


// ------ Add MenuBar/Toolbars to Command Manager


VERIFY(


g_CmdManager->UpdateFromMenu(


pApp->m_pszProfileName,


IDR_MAINFRAME


)


);


VERIFY(


g_CmdManager->UpdateFromMenu(


pApp->m_pszProfileName,


IDR_SHAREDMENU


)


);


VERIFY(


g_CmdManager->UpdateFromToolBar(


pApp->m_pszProfileName,


IDR_MAINFRAME


)


);



// ------ Create MenuBar


m_wndMenuBar.SetMdiWindowPopupName( _T("Window") );


if( !m_wndMenuBar.Create(


_T( "MenuBar" ),


this,


NULL


)


)


{


TRACE0("Failed to create menubar\n");


return -1; // failed to create


}


// ------ Create ToolBars


if( !m_wndToolBar.Create(


_T( "Main Toolbar" ),


this,


ID_VIEW_TOOLBAR


)


||


!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)


)


{


TRACE0("Failed to create toolbar\n");


return -1; // fail to create


}


// ------ Create Status Bar



if (!m_wndStatusBar.Create(this) ||


!m_wndStatusBar.SetIndicators(indicators,


sizeof(indicators)/sizeof(UINT)))


{


TRACE0("Failed to create status bar\n");


return -1; // fail to create


}


// ------


m_wndMenuBar.EnableDocking( CBRS_ALIGN_ANY );


m_wndToolBar.EnableDocking( CBRS_ALIGN_ANY );


//


// Prof-UIS advanced docking windows feature:


// Show content of control bars when docking / resizing


//


if( !CExtControlBar::FrameEnableDocking(this) )


{


ASSERT( FALSE );


return -1;


}


#if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)


if( !CExtControlBar::FrameInjectAutoHideAreas(this) )


{


ASSERT( FALSE );


return -1;


}


#endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)


// --- Load Prof-UIS saved profile bar state


/*


if( !CExtControlBar::ProfileBarStateLoad(


this,


pApp->m_pszRegistryKey,


pApp->m_pszProfileName,


pApp->m_pszProfileName,


&m_dataFrameWP


)


)


*/


// ------


DockControlBar( &m_wndMenuBar, AFX_IDW_DOCKBAR_TOP );


DockControlBar( &m_wndToolBar, AFX_IDW_DOCKBAR_TOP );


RecalcLayout();


 


For some reason the icons are all mis-aligned:


http://www.lightwave-design.com/toolbar/toolbar.bmp


 


Any ideas what is causing this?


Cheers,


Clive.

Technical Support Nov 4, 2004 - 1:41 AM

Prof-UIS can load 16/24/32 bit color toolbar images as well as 4/8 bit color images generated by Visual Studio. If you need to use high color images, keep the following steps:

  • Create a low-color toolbar resource in Visual Studio

  • Change the image-size property of this resource

  • Add a required number of toolbar buttons

  • Finally, replace the bitmap file in the RES folder with your high color bitmap that has the same size
By default, Visual Studio creates a new toolbar resource with 16x15 button images. If you need larger or smaller images, do not forget to change the image-size property of the toolbar resource.

Wang Yang Nov 2, 2004 - 11:59 PM

Make sure that your icons for the toolbar is 16*16 unless you use double-sized icons by setting g_bMenuLargeIcons=TRUE.

Wang Yang Nov 3, 2004 - 12:23 AM


    I know that large icons(32*32) can be shown on toolbars. But I wonder how can I display large icons on menu items ? I need to do so because when I use large icons on my toolbar there is no enough room to display the double-sized icons for the menu items which are associated with the toolbar buttons. I even tried to set m_wndMenuBar.g_bMenuLargeIcons=TRUE, but it didn’t work. Can you help me?


Good Luck!


Wang Yang,


Beijing, China

Technical Support Nov 4, 2004 - 3:04 AM

Both toolbars and popup menus may use icons of any size. In the FunnyBars sample you may see the popup menu with items that have even icons of different size. Both the toolbar and popup menu does not keep icons for their items. They work only with command identifiers. That is enough to get the CExtCmdIcon object (from the command manager) corresponding to the item’s command identifier. So, if some command is assigned a 64x64 icon, then you will automatically have this large icon both in toolbars and popup menus.

The static CExtPopupMenuWnd::g_bMenuLargeIcons flag forces the popup menu to use the icons of double size. So, if you set it to true, the 64x64 icons will be stretched to those of the 128x128 size.

You may use the toolbar resource with large buttons and then update the command manager from it. You may also add icon resources, load them manually and assign to each command separately by invoking the g_CmdManager->CmdSetIcon() methods. Please note, the command manager keeps only one icon for each command. So, if you assign a 32x32 icon to some command, you will see exactly this 32x32 icon for the command both in toolbars and menus.

Wang Yang Nov 4, 2004 - 7:35 PM

Thank you!