tags:

views:

51

answers:

2

Hello friends,I had a problem in displaying icon in button along with the Text in MFC application.. after reading lot of arctilces I got a solution for that and it worked great.But when I tested my application in win xp(SP2)..it suprised me by not showing the icon..Check the below code which i used to display the icon along with a test in button..Please let me know if there are any fix for this issue..waiting for your replies

HICON addIcon = (HICON)LoadImage(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_ICON4),
      IMAGE_ICON,0,0,LR_DEFAULTCOLOR);    

 SendMessageA(::GetDlgItem(m_hWnd,IDC_ADD),BM_SETIMAGE,IMAGE_ICON,(LPARAM)(DWORD)addIcon);
A: 

I can confirm that i can't get it to work (on Win2003, my primary development machine) and a brief search on the web found many complaints but no viable answers.

My only suggestion would be to do an ownerdraw button - handling the WM_DRAWITEM message is not difficult and may resolve this issue for you across the board.

see "Native Win32 Theme aware Owner-draw Controls without MFC"

Ruddy
+1  A: 

If you're using VS2008 (you should), use CMFCButton from the Feature Pack. It has much better support for bitmapped buttons.

Roel