c - 按钮在 Windows GUI 应用程序上看起来很丑(而不是 Windows 本机)
问题描述
我正在使用 C 制作一个简单的 Windows GUI 应用程序。但是 UI 元素看起来非常丑陋(就像 1990 年一样),而不是我通常期望的原生 Windows 7 控件。这是为什么?我需要做什么才能获得本机 Windows 7 控件?(我使用的是 Windows 7)
我也想知道
- 为什么标题栏看起来像 Windows 7 原生(具有透明度)而不是旧样式?
- 但是其余的控件看起来很旧?
这是我的 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 个窗口。但我希望它看起来像底部的那个。
解决方案
感谢您的评论并为我指明了正确的方向,我通过添加一个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>
推荐阅读
- node.js - 使用 passport-google-oauth20,尝试为图片 URL 创建项目 mongo
- c - 用多个字符替换一个字符
- javascript - 解构 ecmascript es7
- regex - Python 字符串捕获
- ruby-on-rails - 设计 - 如何检查重置密码是否是令牌有效
- forms - Symfony - 在原型树枝模板中使用 collectionType 长度作为计数器不起作用
- godot - 如何使运动体(3d)跟随玩家
- java - 使用 Apache Beam (KafkaIO.write) 序列化 avro 数据
- php - 如何使用 PHP 数组更新 SQL 数据库?
- sql - 用于生成分层数据的复杂递归 SQL