Icon in Window

Okay, how exactly do I get an icon into a button in WinAPI? It won't cooperate with me when I use this to put the icon in the button:

const int icon_size=25;

                                           hMyIcon = LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(JAILBREAK_ICON), IMAGE_ICON,
                                           icon_size, icon_size, NULL);


And that pesky BG color. I want it to be a light creamy-white color like most Win32 applications. Why is it always the default grey EVEN WHEN I USE HBRUSH to change the BG color?

Last edited on
You forgot the handle to the dialog window:

SendDlgItemMessage([HWND to a dialog],GetDlgItem(hwnd,filterTimeOn),BM_SETIMAGE,(WPARAM)IMAGE_ICON,(LPARAM)hMyIcon);

And I don't know where your filterTimeOn comes from, but it has to be the identifier of the button.

As for the color: I like it! No, seriously I don't know whether it is possible using CreateDialog(), but this function uses CreateWindow, which is much more powerful, but that comes at the price of being more comlicated. You can create one window as the background of the Dialog and one window as the button that shows on top of it. Wrap is in a class or something and you can always use it again and customize it.
Last edited on
Topic archived. No new replies allowed.