Buttons with rounded edges

I cant figure out how to make buttons have rounded edges like the buttons in the message box or in OPENFILENAME. Cause when I use BS_PUSHBUTTON or BS_FLAT they have sharp edges. I've been looking throughout the msdn but i couldnt find the matching style... Does anyone know what it takes?
Are you talking about XP style buttons?
If you mean custom buttons or widgets look here http://www.rohitab.com/discuss/topic/27876-how-to-skin-your-guis-in-cc-part-1/. If you mean making your GUI look like its native theme look here http://www.cplusplus.com/forum/windows/31552/
Yes XP style buttons, would you know any tutorial on how to do it cause I don't even know whats a manifest file... :/
Put this EXACTLY as it is written here near the very top of your main header file --

#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' " "version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

And notice that there is NOT a semicolon after it. The best thing to do is just copy and paste it in, right after your #include(s), if you have any other #include(s) in your main header file.

In fact, in your main header file you should #include Commctrl.h and then after that and any other includes, then paste in the manifest above.

Now, in your WinMain() function do this --

1
2
3
4
5
6
INITCOMMONCONTROLSEX icex;

icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_STANDARD_CLASSES | ICC_COOL_CLASSES;

InitCommonControlsEx(&icex);


Finally, you will have to add this library to your Linker | Input | Additional Dependencies --

comctl32.lib

Now your buttons will be XP style. In the last statement, i.e., icex.dwICC = etc. you can use a number of different flags.

Look up INITCOMMONCONTROLSEX in MSDN.
Last edited on
Although I'm not contesting Lamblion's code (the guy knows his stuff) I would like to point out that this IS a hack. Weither the buttons on a users interface are "classic" or "XP style" is determined by the user settings making it a preference. I cannot for the life of me think of a need to force the user to use a GUI that would clash with the rest of their desktop.
Using manifest will still render classic style if the user sets his/her theme in classic right?? So what's the problem with manifest?
I didn't actually try lamblion's code, I just assumed that it forced the users settings to the Windows XP theme for that instance since that's what the OP was asking and that appears to be what the code is doing. I just wanted to point out the bad edicat if indeed the code did work.
It has nothing whatsoever to do with the XP Theme. It for the common controls that were introduced with XP, and it is exactly what MicroSoft recommends. Here is the first line from the MSDN on InitCommonControlsEx() --

Ensures that the common control DLL (Comctl32.dll) is loaded, and registers specific common control classes from the DLL. An application must call this function before creating a common control.


http://msdn.microsoft.com/en-us/library/bb775697(VS.85).aspx
I was refering to the preprocessor command. You appear to be force loading a specific version of the windows common controls, is that not what that is?
Read the statement above. If you want to use the XP style common controls then, exactly as the quotation above states, you MUST call this function, and the ONLY way you can make the function work is to use the manfest and other code I posted above.

Just try to program in the XP style common controls without doing this.
Last edited on
@Computergeek01
Lamblion's preprocessor command is exactly the same with adding xml manifest to the resource just like my second link. IIRC that is a Visual Studio specific preprocessor, so the better choice I think would be to use xml for it to work with most IDE's.

Also if I am not mistaken, windows xp and later refer to the manifest file to enable themes.

[edit]
BTW, it does not force you to use themes if you want classic look. Just to be clear.
Last edited on
I got it working. Thanks to everyone for the great help!
I think blackcoder41 is correct about the xml manifest in the resource file, but if you don't have a resource file, which a plain windows app may not, then you obviously can't go that way.

The guys ast Microsoft gave me the way I have demonstrated above and recommedede that I do it that way. I still do not believe it has anything to do with themes other than to make the XP enhancements available for enabling certain function calls to make use of them, if desired.

@pcultras - would you mind telling us how you got it working??? Since you brought it up, it would be nice to know.
Last edited on
I've go it working the way Lamblion told me to do it above. :)
Topic archived. No new replies allowed.