首页 > 解决方案 > 按钮在 Windows GUI 应用程序上看起来很丑(而不是 Windows 本机)

问题描述

我正在使用 C 制作一个简单的 Windows GUI 应用程序。但是 UI 元素看起来非常丑陋(就像 1990 年一样),而不是我通常期望的原生 Windows 7 控件。这是为什么?我需要做什么才能获得本机 Windows 7 控件?(我使用的是 Windows 7)

我也想知道

  1. 为什么标题栏看起来像 Windows 7 原生(具有透明度)而不是旧样式?
  2. 但是其余的控件看起来很旧?

这是我的 C 程序

#include <windows.h>

int STDCALL;

WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
{
    MessageBox (NULL, "Hello, Windows!", "Hello", MB_OK);
    return 0;
}

结果看起来像顶部的 2 个窗口。但我希望它看起来像底部的那个。

在此处输入图像描述

标签: cwindowswin32gui

解决方案


感谢您的评论并为我指明了正确的方向,我通过添加一个appname.exe.manifest文件然后重新编译我的程序来解决它,它现在具有 Windows 7 原生样式而不是经典样式。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <assemblyIdentity version="1.0.0.0" processorArchitecture="*"
        name="CompanyName.ProductName.YourApplication" type="win32"/>
    <description>Your application description here.</description>
    <dependency>
        <dependentAssembly>
            <assemblyIdentity name="Microsoft.Windows.Common-Controls"
                version="6.0.0.0" type="win32" processorArchitecture="*"
                publicKeyToken="6595b64144ccf1df" language="*"/>
        </dependentAssembly>
    </dependency>
</assembly>

推荐阅读