Win7 style interface with WinAPI

Hello Everyone!

I was looking at some code in Charles Petzold's Programming Windows when I realized that the buttons, text boxes, etc. do not look like the default "ones" on WinXP or Win7. Okay, I mean that, I thought the typical procedure to call a button or a text field calls some file somewhere that loads the same button "shape" that the version of Windows the program is running on has (that was ugly).

So, how do I resolve this issue? And should I always account for the version of Windows my program is running on?

Thanks!
You need to add a manifest to your resources (or a #pragma directive if you use Visual Studio) to force loading comctl32.dll version 6 or higher, which is present only on windows xp or later, but is not enabled by default.

http://msdn.microsoft.com/en-us/library/windows/desktop/bb773175(v=vs.85).aspx
Last edited on
They say I should call InitCommonControls, as:

InitCommonControls();

But the function's documentation says this functions is obsolete and we should use InitCommonControlsEx instead, but it is of type bool and takes an argument, so how should I call it in main?
Is C++ code, I call it as follows:

1
2
3
4
5
6
    INITCOMMONCONTROLSEX iccx;
    iccx.dwSize = sizeof(iccx);
    iccx.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES | ICC_TREEVIEW_CLASSES;
    BOOL bRet = ::InitCommonControlsEx(&iccx);
    bRet; // shut up Release warning
    _ASSERTE(bRet); // from crtcbg.h 


See MSDN for the other bit-flag values which can be used with dwICC

Andy

P.S. Init-ing the common controls is required whatever their style. For modern looking controls, you need to follow modoran's advice.
Last edited on
Topic archived. No new replies allowed.