Click here to Skip to main content
15,883,818 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys
I want to show Icon and text on a single button.
I create a button as this:
C++
int iStyle = BS_TEXT | BS_NOTIFY | BS_VCENTER | WS_GROUP | WS_CHILD | WS_VISIBLE | WS_TABSTOP;
HWND hWnd = CreateWindowExW(0, L"BUTTON", L"MyText", iStyle, x, y, cx, cy, hwndDlg, nullptr, hInst, nullptr);
const wchar_t * wszIconId = MAKEINTRESOURCEW(IDI_MYICON);
int cpImageSize = cy - 4;
HICON hIcon = (HICON)LoadImage(hInstance, wszIconId, IMAGE_ICON, cpImageSize, cpImageSize, LR_SHARED);
SendMessage(hWnd, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)hIcon);
This code works fine on Windows 7 and 8, But on windows XP only text is displayed. If I use BS_ICON style, then icon only is displayed fine on Win XP.
I found many similiar posts in google, but no solution.
Is this a Problem with Windows XP? Is any way to solve this problem?
any suggestions appretiated.
mr.abzadeh
Posted
Comments
KarstenK 2-Mar-15 5:11am    
Maybe it is a bug. Check the OS and mplement it for both ways. And you're done.

1 solution

You can try diffierent combinations of settings as described in https://msdn.microsoft.com/en-us/library/windows/desktop/bb775951%28v=vs.85%29.aspx[^]. However, if I recall correctly from my own experience, this does not work on Windows XP.
 
Share this answer
 
Comments
mr.abzadeh 2-Mar-15 9:43am    
Thanks a lot. I had studied the link once again, and I didn't find any other idea.
I think this doesn't work in Windows XP

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900