Simple Menus That Display Icons in Win32 API (No MFC)
-
Hello Friends my task is to append icons to menu (ie .ico), it is very easy to add bmp file to menu, but in order to need transparency i have to use icons only not bmps. There are lots of programs for this in MFC , but i need to do it in Win32 API using VC++ Any help is greatly appreciated
-
Hello Friends my task is to append icons to menu (ie .ico), it is very easy to add bmp file to menu, but in order to need transparency i have to use icons only not bmps. There are lots of programs for this in MFC , but i need to do it in Win32 API using VC++ Any help is greatly appreciated
Aabid wrote:
There are lots of programs for this in MFC , but i need to do it in Win32 API
Knowing that MFC is just a thin wrapper around the Win32 API, you should be able to look at the MFC code to tell what MFC is doing, and pick out the relevant parts.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Aabid wrote:
There are lots of programs for this in MFC , but i need to do it in Win32 API
Knowing that MFC is just a thin wrapper around the Win32 API, you should be able to look at the MFC code to tell what MFC is doing, and pick out the relevant parts.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
Hi david can u guide me how to convert this function to Win32 API, ie how can i handle this function as message void CMainFrame::OnInitMenu(CMenu* pMenu) { #if _MFC_VER < 0x0800 #undef __FUNCTION__ #define __FUNCTION__ "OnInitMenu()" #endif // _MFC_VER < 0x0800 AfxTrace(_T(__FUNCTION__) _T(": %#0x\n"), pMenu->GetSafeHmenu()); MENUITEMINFO minfo; minfo.cbSize = sizeof(minfo); for (UINT pos=0; pos<pMenu->GetMenuItemCount(); pos++) { minfo.fMask = MIIM_FTYPE | MIIM_ID; pMenu->GetMenuItemInfo(pos, &minfo, TRUE); HICON hIcon = GetIconForItem(minfo.wID); if (hIcon && !(minfo.fType & MFT_OWNERDRAW)) { AfxTrace(_T("replace for id=%#0x\n"), minfo.wID); minfo.fMask = MIIM_FTYPE | MIIM_BITMAP; minfo.hbmpItem = HBMMENU_CALLBACK; minfo.fType = MFT_STRING; ::SetMenuItemInfo(pMenu->GetSafeHmenu(), pos, TRUE, &minfo); } else AfxTrace(_T("keep for id=%#0x\n"), minfo.wID); // ::DestroyIcon(hIcon); // we use LR_SHARED instead } } We Have To Conert it into case WM_INITMENU:
-
Hi david can u guide me how to convert this function to Win32 API, ie how can i handle this function as message void CMainFrame::OnInitMenu(CMenu* pMenu) { #if _MFC_VER < 0x0800 #undef __FUNCTION__ #define __FUNCTION__ "OnInitMenu()" #endif // _MFC_VER < 0x0800 AfxTrace(_T(__FUNCTION__) _T(": %#0x\n"), pMenu->GetSafeHmenu()); MENUITEMINFO minfo; minfo.cbSize = sizeof(minfo); for (UINT pos=0; pos<pMenu->GetMenuItemCount(); pos++) { minfo.fMask = MIIM_FTYPE | MIIM_ID; pMenu->GetMenuItemInfo(pos, &minfo, TRUE); HICON hIcon = GetIconForItem(minfo.wID); if (hIcon && !(minfo.fType & MFT_OWNERDRAW)) { AfxTrace(_T("replace for id=%#0x\n"), minfo.wID); minfo.fMask = MIIM_FTYPE | MIIM_BITMAP; minfo.hbmpItem = HBMMENU_CALLBACK; minfo.fType = MFT_STRING; ::SetMenuItemInfo(pMenu->GetSafeHmenu(), pos, TRUE, &minfo); } else AfxTrace(_T("keep for id=%#0x\n"), minfo.wID); // ::DestroyIcon(hIcon); // we use LR_SHARED instead } } We Have To Conert it into case WM_INITMENU:
See here. Googling for such will also turn up dozens of examples.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons