为什么我的消息框看起来与Windows 10显示的不同?

问题描述 投票:0回答:1

我在想一致性。我在Visual Studio 2017构建的Windows子系统C / C ++应用程序中使用MessageBox Windows API函数,如下所示:

MessageBox(NULL, "Error opening log file for writing, aborting.", NULL, MB_ICONERROR);

这让我:

My message box

我在例如Windows时显示的消息框尝试使用“开始”菜单中的“运行”对话框运行无效程序,如下所示:

System message box

它显然不是一个显示限制器,但我很好奇,并且在Windows的所有版本经历之后,对这种缺乏一致性的程度感到惊讶。是的,我知道有一个向后兼容的老鼠窝,他们必须不断地解决,但仍然。

这是否与我在清单文件中未指定的某些设置有关,我没有明确要求的一些常见控件样式?我的项目和解决方案设置不受影响,除了将DPI Awareness指定为“Per Monitor DPI aware”。关闭后者仍然显示相同的消息框(尽管文本模糊,因为系统缩放渲染的位图,如文档所述)。

The manifest embedded by VS in the built program

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
        <security>
            <requestedPrivileges>
                <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
            </requestedPrivileges>
        </security>
    </trustInfo>
    <asmv3:application>
        <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
            <dpiAware>true</dpiAware>
            <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
        </asmv3:windowsSettings>
    </asmv3:application>
</assembly>
windows windows-10 messagebox user-experience
1个回答
-1
投票

我不确定“无效程序”场景中的窗口显示的消息框是使用MessageBox函数还是自定义对话框。 但是,为了达到一致性,你可以在这里找到答案:https://www.codeguru.com/cpp/w-p/win32/messagebox/article.php/c14605/Fancy-Custom-MessageBox.htm#page-2

此外,在这里https://referencesource.microsoft.com/#system.windows.forms/winforms/managed/system/winforms/MessageBox.cs,e426fc24b95c791e你会发现它是如何实现的 - 以及为什么消息框上的按钮与C ++调用中的按钮不同。

© www.soinside.com 2019 - 2024. All rights reserved.