I was wondering how one can add a bitmap and string together in a menu. I
have seen examples
where the bitmap is used for the menu instead of the string, but how can I
add a
menu item that has both a bitmap, and a string? The AppendMenu() only allows
one
or the other as far as I can see. An example would be C++ Visual Studio,
when you click the menu,
look on the left hand side and there is a bitmap on the left handside of the
string.
Any suggestions would be much appreciated.
Kind regards
> I was wondering how one can add a bitmap and string together in a menu. I
> have seen examples
> where the bitmap is used for the menu instead of the string, but how can I
> add a menu item that has both a bitmap, and a string? The AppendMenu() only allows
> one or the other as far as I can see. An example would be C++ Visual Studio,
> when you click the menu, look on the left hand side and there is a bitmap on the left handside of the
> string.
With owner-draw menus like you did (or SetMenuItemBitmaps() for
checked/unchecked)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Hello again,
You mentioned about the checked/unchecked like the MSDN example.
Do I need that code? or is there away I could set the bitmap like this?
I get the feeling I am missing alot of code somewhere.
What I have currently. . . .
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
switch(iMsg)
{
case WM_CREATE:
hBmp1 = LoadBitmap(g_hInst, (LPSTR)IDB_BITMAP1);
SetMenuItemBitmaps(hMenu, ID_FILE_EXIT, MF_BYCOMMAND, hBmp1, hBmp1);
return 0;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_FILE_EXIT:
PostQuitMessage(0);
}
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,iMsg,wParam,lParam);
}
> case WM_CREATE:
>
> hBmp1 = LoadBitmap(g_hInst, (LPSTR)IDB_BITMAP1);
> SetMenuItemBitmaps(hMenu, ID_FILE_EXIT, MF_BYCOMMAND, hBmp1, hBmp1);
What is hMenu?
Owner drawing is the usual method (any color, size, ..)
//------------------------------------------------------------------------------------------------------
I have found out what my problem was, that is the reason why my menu was not
displaying the bitmap next to my menu string.
I loaded the menu in winMain using the loadMenu() & SetMenu(). Well, there
was a scope problem in the callback function.
I have now loaded the menu in the window properties and used the function
GetMenu() in WM_CERATE:
Oh yes, hMenu is a global varible in my example.
// NOT WORKING // Menu loaded in winMain using LoadMenu() & SetMenu().
case WM_CREATE:
hBmp1 = LoadBitmap(g_hInst, (LPSTR)IDB_BITMAP1);
SetMenuItemBitmaps(hMenu, ID_FILE_EXIT, MF_BYCOMMAND, hBmp1, hBmp1);
**********************************************************************************************
// WORKING // Menu loaded in winMain with using. . . ."wnclass.lpszMenuName
= (LPSTR)ID_MENU;"
case WM_CREATE:
hMenu = GetMenu(hwnd);
hBmp1 = LoadBitmap(g_hInst, (LPSTR)IDB_BITMAP1);
SetMenuItemBitmaps(hMenu, ID_FILE_EXIT, MF_BYCOMMAND, hBmp1, hBmp1);
Kind regards