|
-
July 19th, 2002, 04:18 AM
#1
Load Icon to bitmap
Hi!
Can anyone tell me how to load an Icon on to a Bitmap.
I have smiley Icon and I want it on a Button.
For that I used BS_PUSHBUTTON and BS_OWNERDRAW and created a button.
But how to get this smiley onto button.Can i load into a icon and set bitmap on button or any other way.
Thanks in advance,
Gupta.
-
July 19th, 2002, 04:25 AM
#2
I'd use:
HICON hMyIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
Then to display it on the button, use
DrawIcon(hDC, x_position, y_position, hMyIcon);
Hope this helps
Ben
-
July 19th, 2002, 04:39 AM
#3
With the following Article you can do that and a lot more:
http://www.codeproject.com/buttonctrl/cbuttonst.asp
Regards, Sonu Kapoor
-
July 19th, 2002, 05:39 AM
#4
By subclassing the Button we can do lot of things.But without doing that is there any way to do.
Thanks for spending your precious time.
Waiting for reply.
Gupta.
-
July 19th, 2002, 05:50 AM
#5
The only way I know of is either subclassing...e.g. inheriting your own class and doing your own drawing.
class CMyButton : public CButton
{
... etc etc
}
or setting a new proc...using setwindowlong api..
-
July 19th, 2002, 05:54 AM
#6
If you jsut want to change the image...there's a class called
CBitmapButton
with a member:
BOOL LoadBitmaps(
UINT nIDBitmapResource,
UINT nIDBitmapResourceSel = 0,
UINT nIDBitmapResourceFocus = 0,
UINT nIDBitmapResourceDisabled = 0
);
the 4 different parameters to the LoadBitmap member are the standard bitmap view, up bitmap, down bitmap etc.
Hope it helps
-
July 19th, 2002, 06:44 AM
#7
Hi Gupta,
I'm not sure exactly what you want, but if you want to get an icon on a button:
1) create the button with style BS_ICON
2) load the icon
3) call CButton::SetIcon()
Good luck,
John Flegert
-
July 19th, 2002, 08:18 AM
#8
this is what i wanted to do.
thanks a lot.
Gupta.
-
January 30th, 2003, 02:41 AM
#9
Originally posted by jflegert
Hi Gupta,
I'm not sure exactly what you want, but if you want to get an icon on a button:
1) create the button with style BS_ICON
2) load the icon
3) call CButton::SetIcon()
Good luck,
John Flegert
Hi,
Can you please teach me how you load the icon and call CButton::SetIcon ? I realise that there are available icons in the Microsoft Visual Studio\Common\Graphics\Icons, how do I make use of them? I want to displace them on the buttons in my application.
Thanks in advance
I am not smart, I am just very very curious!
----Albert Einstein
-
January 30th, 2003, 12:19 PM
#10
To load an icon, I use LoadIcon or LoadImage. I would suggest looking in MSDN.
Good luck,
John Flegert
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|