代码之家  ›  专栏  ›  技术社区  ›  Liga

按钮在Windows GUI应用程序上看起来很难看(而不是Windows本机)

  •  1
  • Liga  · 技术社区  · 6 年前

    我正在使用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;
    }
    

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

    enter image description here

    0 回复  |  直到 6 年前
        1
  •  2
  •   Liga    6 年前

    感谢您的评论,并为我指明了正确的方向,我通过添加一个 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>