Moses
Moses

Reputation: 1273

Create text field with fancy thin border. Winapi

I'm very-very new to winapi and c++ but I need to make text field with thin border and rounded corners. I can't find this style in winapi reference: http://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx Neither in simple window styles nor in extended. The only adequate border which I've found is WS_EX_CLIENTEDGE but it's not what I need. Here is the pic to show current and desired look:

current and desired look

So what should I do to make this fancy border?

Upvotes: 2

Views: 430

Answers (1)

Cody Gray
Cody Gray

Reputation: 244843

This is not a per-window style problem. The "desired" window has all of its default styles set. The difference is that it is themed with visual styles. Your "current" window is using the "Classic" theme (in other words, not themed).

The standard fix for this is to include a manifest with your application that opts you into using version 6 of the Common Controls library—the one that supports theming. It is opt-in for safety reasons, so that only applications prepared to handle themed controls get them.

If you are using Visual Studio, you can request that the linker automatically embed the required manifest into your application. Place the following line of code in your precompiled header or equivalent:

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

Alternatively, you can create the manifest file in the proper format and include it in your build process manually. You can even enable theming programmatically, but that's unnecessary in this case. You want it on for the whole application, so just use a manifest.

More information can be found in the documentation: Enabling Visual Styles

(Sorry, I cannot tell you why, in the year 2014, this does not happen by default in modern versions of Visual Studio. I've heard that the appropriate manifest is supposed to be automatically included, but I've never seen it work, even when you use the included project templates. Another one of the many reasons to create your own skeleton template and use that instead.)

Upvotes: 7

Related Questions