How to change the style of dialog box items to what appears in test mode?

When I test my dialog box in Visual Studio 2008 with CTRL + T, I can see the dialog box elements with neat borders. But when I compile the project and run it using the program itself, it looks "3d": each dialog box has a hue, like the old style of Windows 98.

I want to use transparent 1 pixel borders displayed in test mode. How to enable / disable these two styles?

Here is an example of how these two styles look, I want to use the top one:

enter image description here

+4
source share
2 answers

STEP1 add this code to your stdafx.h:

#ifdef _UNICODE #if defined _M_IX86 #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") #elif defined _M_X64 #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") #else #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") #endif #endif 

STEP2 by the InitInstance () method:

  BOOL Ctest_stylesApp::InitInstance() { INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); } 

I am using Visual Studio 2010 and it works.

+2
source

You need to enable ComCtl32 version 6 so that the appropriate style elements are applied to the controls. Microsoft provides complete instructions at this link: Enabling Visual Styles

+1
source

Source: https://habr.com/ru/post/1400998/


All Articles