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 Tech Support » Assigning an HBITMAP to menuitems Collapse All
Subject Author Date
Guillaume Provost Aug 18, 2003 - 4:35 AM

Is the only implementation path to assign an HBITMAP to a command through replacement? (see attached code snippet). I notice there does’nt seem to be any internal support for grabbing the new (winver > 0x500) MENUITEMINFO bitmap holder members.

// Assign a dummy icon
HICON hIcon = CExtPaintManager::stat_GenerateColorIconBox(COLORREF(0)) ;
ASSERT( hIcon != NULL );

VERIFY(g_CmdManager->CmdSetIcon(
g_CmdManager->ProfileNameFromWnd(
pFrame->GetSafeHwnd()),a_ID, hIcon,false));

CExtCmdIcon *cmdIcon =
g_CmdManager->CmdGetIconPtr(
g_CmdManager->ProfileNameFromWnd(
pFrame->GetSafeHwnd()), a_ID);

RECT targetSize;
targetSize.top = 0;
targetSize.bottom = 16;
targetSize.left = 0;
targetSize.right = 16;
        
// Replace the icon with the bitmap
cmdIcon->AssignFromHBITMAP(a_bitmap, COLORREF(0));//, &targetSize);

Technical Support Aug 18, 2003 - 7:33 AM

Yes. Prof-UIS is configured to be compatible with any version of Windows OS, not only 5.0 and higher. If we compile the code with winver >= 0x500 - it will crash inside GetMenuItemInfo() Win32 API function under Win NT 4.0. Strange thing, but this function requires the MENUITEMINFO structure with the size specific for current version of Windows. So, the single way to use the bitmap-based icons is to initialize them explicitly like in your source code.