Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

winapi CreateWindowEx -> create button with user system styles?

I want to make a button that looks just like the OK button when you go My Computer -> Help -> About Windows.

I am creating a button like this:

hButton = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("BUTTON"), TEXT("Text"), WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 10, 10, 30, 30, hwnd, (HMENU)IDC_MAIN_BUTTON, GetModuleHandle(NULL), NULL);

But it looks like a rough square and does not use the windows styles that the user has selected. I guess I should be using some sort of window class but I am unsure what class?

like image 741
myforwik Avatar asked May 31 '26 21:05

myforwik


2 Answers

You want to use version 6 of the common controls library. To do this you need to add an application manifest to your executable. See this MSDN article on how to do that.

like image 158
shf301 Avatar answered Jun 02 '26 14:06

shf301


Try running ControlSpy which will allow you to try out different styles quickly.

like image 41
the_mandrill Avatar answered Jun 02 '26 15:06

the_mandrill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!