Click to See Complete Forum and Search --> : Bitmap Button With Text,not use MFC
xpman
March 29th, 2004, 08:24 AM
Hi Everyone,
I use this method to make Bitmap Button,it is successful.
But I can't add any text to Bitmap Button,who can tell me
How to add text and bitmap to button?
Thanks a lot!
HANDLE hPic;
hPic=LoadImage(GetModuleHandle(0),MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON, 0,0, 0);
SendMessage(GetDlgItem(hwndDlg,IDC_BUTTON1),BM_SETIMAGE,(WPARAM)IMAGE_ICON,(LPARAM)hPic);
NoHero
March 29th, 2004, 08:34 AM
HWND hdc;
hdc = GetDC(GetDlg(...));
DrawText(hdc, ...);
// ...
ReleaseDC(hdc);
retrieve the device context of the button and draw a text in it ...
but don't forget to release the dc
see msdn for further information ;)
ng
xpman
March 29th, 2004, 08:56 AM
Hi NoHero,
I try to use your suggestion,
It can work,but button only display 'bitmap'.not
display text+bitmap.
How to display both text and bitmap on button?
Any samples, links, suggestions very much appreciated.
-------------------------------------------------------
HANDLE hPic;
HDC hdc;
RECT rc;
char *szStr="OK";
hPic=LoadImage(GetModuleHandle(0),MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON, 0,0, 0);
SendMessage(GetDlgItem(hwndDlg,IDC_BUTTON1),BM_SETIMAGE,(WPARAM)IMAGE_ICON,(LPARAM)hPic);
GetClientRect(GetDlgItem(hwndDlg,IDC_BUTTON1),&rc);
hdc=GetDC(GetDlgItem(hwndDlg,IDC_BUTTON1));
DrawText(hdc,(LPCTSTR)szStr,-1,&rc,DT_CENTER|DT_WORDBREAK);
ReleaseDC(hwndDlg,hdc);
pengch
March 29th, 2004, 08:06 PM
Use WTL, it will be very simple. WTL didn't depends MFC.
xpman
March 30th, 2004, 07:19 AM
What is WTL? Can you tell me some information for WTL? Thanks!
ps : I still hope that someone can help me for this issue (Button with text and bitmap) using API function. Thanks a lot!
pengch
March 30th, 2004, 07:51 AM
search google or codeguru.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.