我开发了一些C++ MFC应用程序。在我的对话框中有一个进度条和一个带有常量文本(西里尔符号)的标签。
此文本在Windows 7、XP上显示良好,但在Windows 8、10上以简化形式显示。
为什么?
这是在Windows 7上:

这是在Windows 8上:

这是与此对话框窗体相关的类的源代码。*.cpp文件:
// Progress.cpp : implementation file
//
#include "stdafx.h"
#include "LybidLoader.h"
#include "Progress.h"
#include "afxdialogex.h"
// Progress dialog
IMPLEMENT_DYNAMIC(Progress, CDialogEx)
Progress::Progress(CWnd* pParent /*=NULL*/)
: CDialogEx(Progress::IDD, pParent)
{
}
Progress::~Progress()
{
}
void Progress::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_PROGRESS1, m_ProgressBar);
}
BEGIN_MESSAGE_MAP(Progress, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON1, &Progress::OnBnClickedForceExit)
END_MESSAGE_MAP()
// Progress message handlers
BOOL Progress::OnInitDialog()
{
CDialogEx::OnInitDialog();
ModifyStyle( WS_SYSMENU, 0);
m_ProgressBar.SetMarquee(TRUE, 10);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void Progress::OnBnClickedForceExit()
{
if (::MessageBoxW(this->m_hWnd, (LPCWSTR)_T("Ви впевнені? Буде здійснено аварійний вихід"), (LPCWSTR)_T("Підтвердіть дію"), MB_ICONEXCLAMATION | MB_YESNO) == IDYES)
{
PostQuitMessage(0);
}
}
BOOL Progress::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if( pMsg->message == WM_KEYDOWN )
{
if(pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE)
{
return TRUE; // Do not process further
}
}
return CDialogEx::PreTranslateMessage(pMsg);
}和*.h文件:
#pragma once
#include "afxcmn.h"
// Progress dialog
class Progress : public CDialogEx
{
DECLARE_DYNAMIC(Progress)
public:
Progress(CWnd* pParent = NULL); // standard constructor
virtual ~Progress();
// Dialog Data
enum { IDD = IDD_PROGRESSBAR };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
CProgressCtrl m_ProgressBar;
afx_msg void OnBnClickedForceExit();
virtual BOOL PreTranslateMessage(MSG* pMsg);
};这是资源文件的一部分:
IDD_PROGRESSBAR DIALOGEX 0, 0, 369, 105
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Будь-ласка, зачекайте!"
FONT 8, "Microsoft Sans Serif", 400, 0, 0x1
BEGIN
CONTROL "",IDC_PROGRESS1,"msctls_progress32",PBS_MARQUEE | WS_BORDER,7,47,355,14
LTEXT "Триває обмін даними з опціональною платою! НЕ ВИМИКАЙТЕ РАДІОСТАНЦІЮ",IDC_STATIC,25,19,267,8
PUSHBUTTON "Примусово завершити роботу",IDC_BUTTON1,101,84,118,14
END发布于 2016-10-14 17:12:40
忽略下图中的垃圾字符,这只是一个代码页问题。
为静态文本控件提供的空间太小:
第一个对话框是您的,修改它使其看起来像第二个对话框。

发布于 2016-10-14 22:08:36
它可以是字体DPI,也可以是字体本身。它可能是"Microsoft Sans Serif“映射到不同的字体。我已经做了足够的本地化工作,知道有些字体并不是在所有系统上都可用。我认为"Microsoft Sans Serif“可能是,但我在远东的系统中见过没有"Arial”的系统。
如果我是你,我会在你的对话资源中把"Microsoft Sans Serif“改成"MS Shell Dlg”。"MS Shell Dlg“是一种虚拟字体,大致映射到默认的GUI字体。
https://stackoverflow.com/questions/40038512
复制相似问题