How to Load Image from Toolbar BMP resources for MenuItem icons ?
-
Hello Friends I am drawing Owner Draw Menu Icons. For that I want to use Toolbar bmp images as Menu Item icons. I used LoadImage to Find the Icons from Resources Like this
hIcon = (HICON)::LoadImage(::AfxGetResourceHandle(), resName, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_SHARED);
And it is working fine. But for this I need to Define All new Icons with same name as MenuItem in resources.
That's, why I want to Load it from Toolbar bmp resources inspite of Icon Resources.
How can I load Image in same manner by name from Toolbar bmp ?Any Help will be Appreciated. Regards Yogesh
-
Hello Friends I am drawing Owner Draw Menu Icons. For that I want to use Toolbar bmp images as Menu Item icons. I used LoadImage to Find the Icons from Resources Like this
hIcon = (HICON)::LoadImage(::AfxGetResourceHandle(), resName, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_SHARED);
And it is working fine. But for this I need to Define All new Icons with same name as MenuItem in resources.
That's, why I want to Load it from Toolbar bmp resources inspite of Icon Resources.
How can I load Image in same manner by name from Toolbar bmp ?Any Help will be Appreciated. Regards Yogesh
Basically, MFC is quit strong to handle all this things enternally, you only need to do is that give same ID to toolbar and menubar item. Like, If you have PQR.bmp on ID_CLICK_ME toolbar then give ID_CLICK_ME to menu bar item so it directly taken POR.bmp as menubar bitmap.
-
Basically, MFC is quit strong to handle all this things enternally, you only need to do is that give same ID to toolbar and menubar item. Like, If you have PQR.bmp on ID_CLICK_ME toolbar then give ID_CLICK_ME to menu bar item so it directly taken POR.bmp as menubar bitmap.
Thanks For your Reply. Actually , I am giving toolbar single bmp name to MenuItem. For Example. ToolBar name is IDR_TOOLBAR1 which consist of images whose names are ID_FILE_NEW,ID_FILE_OPEN. And Under Menu IDR_MENU1 have menuItems New,Open with ID ID_FILE_NEW and ID_FILE_OPEN same as in toolbar bmp. And Used same LoadImage function to load Icon but returning NULL. Or am I doing something Wrong? Regards y
-
Thanks For your Reply. Actually , I am giving toolbar single bmp name to MenuItem. For Example. ToolBar name is IDR_TOOLBAR1 which consist of images whose names are ID_FILE_NEW,ID_FILE_OPEN. And Under Menu IDR_MENU1 have menuItems New,Open with ID ID_FILE_NEW and ID_FILE_OPEN same as in toolbar bmp. And Used same LoadImage function to load Icon but returning NULL. Or am I doing something Wrong? Regards y
why are you not trying this??
CImage image;
image.Load(_T("C:\\image.png")); // just change extension to load jpg
CBitmap bitmap;
bitmap.Attach(image.Detach()); -
Hello Friends I am drawing Owner Draw Menu Icons. For that I want to use Toolbar bmp images as Menu Item icons. I used LoadImage to Find the Icons from Resources Like this
hIcon = (HICON)::LoadImage(::AfxGetResourceHandle(), resName, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_SHARED);
And it is working fine. But for this I need to Define All new Icons with same name as MenuItem in resources.
That's, why I want to Load it from Toolbar bmp resources inspite of Icon Resources.
How can I load Image in same manner by name from Toolbar bmp ?Any Help will be Appreciated. Regards Yogesh
The new
CMFCMenuBar
class already does this for you. To use this class you will need Visual Studio 2008 with Feature pack or VS 2010 and later.«_Superman_» _I love work. It gives me something to do between weekends.
-
Hello Friends I am drawing Owner Draw Menu Icons. For that I want to use Toolbar bmp images as Menu Item icons. I used LoadImage to Find the Icons from Resources Like this
hIcon = (HICON)::LoadImage(::AfxGetResourceHandle(), resName, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR | LR_SHARED);
And it is working fine. But for this I need to Define All new Icons with same name as MenuItem in resources.
That's, why I want to Load it from Toolbar bmp resources inspite of Icon Resources.
How can I load Image in same manner by name from Toolbar bmp ?Any Help will be Appreciated. Regards Yogesh
-
The new
CMFCMenuBar
class already does this for you. To use this class you will need Visual Studio 2008 with Feature pack or VS 2010 and later.«_Superman_» _I love work. It gives me something to do between weekends.
-
why are you not trying this??
CImage image;
image.Load(_T("C:\\image.png")); // just change extension to load jpg
CBitmap bitmap;
bitmap.Attach(image.Detach());If I try this way then I have to load each and every image for Menuitems again single by single. I am looking for a way to use from Toolbar bmp into MenuItems Icons. So,only I am accessing over resources by name to match with same menuitem Icon. Anyway,thanks For ideas. But ,better if I use from toolbar bmp. Y