【发布时间】:2023-03-26 13:30:02
【问题描述】:
我开发了一些 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
【问题讨论】:
-
您尚未提供有关如何实现此对话框窗口的任何详细信息。因此,如果没有源代码,很难帮助您。
-
@AndrewKomiagin 我添加了新的空对话框并将进度条项和一个标签放在那里。在标签的属性中,我设置了应该显示的静态文本...在我的实现中只有按钮按下的处理程序...如果需要,我可以显示与此对话框相关的类的头文件和 cpp 文件的源代码形式。
-
@storojs72:源代码会很好 - 最好删除无关的细节(但检查简化版本是否仍然存在问题)。也不要忘记 .rc 文件的相关部分。
-
@MartinBonner 源代码添加