I have been trying to get my buttons to look like the standard buttons shown on the Microsoft page
Button Types - Win32 apps | Microsoft Docs[
^], but everything I've tried has resulted in 'flat' style buttons. The things I remember doing:
Adding a manifest like the following to my program:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Supports Windows Vista / Server 2008 -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Supports Windows 7 / Server 2008 R2 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Supports Windows 8 / Server 2012 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Supports Windows 8.1 / Server 2012 R2 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Supports Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type="Win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
</assembly>
I've done this both by adding the '{MyApp}.exe.manifest' to the executable directory and by embedding it in Visual Studio 2019.
I've also tried adding the following pragma to the program:
#pragma comment(linker,"\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' \
publicKeyToken='6595b64144ccf1df' language='*'\"")
My button creation function is:
void Button::instantiate(int left, int top, int width, int height, const wString & str) {
CREATESTRUCT cs = { 0 };
cs.dwExStyle = 0;
cs.lpszClass = _T("BUTTON");
cs.lpszName = c_cast<TCHAR*>(str.c_str());
cs.style = BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP;
cs.x = left;
cs.y = top;
cs.cx = width;
cs.cy = height;
cs.hwndParent = 0; cs.hMenu = (HMENU) idC.id();
cs.hInstance = gDwlGlobals->dwlApp->instance();
cs.lpCreateParams = NULL;
ControlWin::instantiate(cs, gDwlGlobals->errors()[(int)Error::Button_CreationFailure]);
if (!hwndC) throw dwl::Exception(_T("Unable to create dwl::Button"));
SendMessage(hwndC, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT),
MAKELPARAM(false, 0));
ShowWindow(hwndC, SW_SHOW);
}
I've set up Visual Studio to use the latest files (10.0 / v142), but still get flat buttons, although they look better than the buttons that appeared when my settings were WinXP. My current preprocessor defines for the project include:
#pragma comment(lib, "comctl32.lib")
...
#define _WIN32_WINNT 0x0600
Any ideas?
Thanks,
David
What I have tried:
See above. And since this has to be at least 30 characters, see above.