gpt4 book ai didi

c++ - 不确定的进度条?

转载 作者:太空狗 更新时间:2023-10-29 21:44:50 26 4
gpt4 key购买 nike

如何在MFC应用程序中制作无限不确定的进度条?

有我的来源,但它不是我想要的无限。

WaitProcessDlg::WaitProcessDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(WaitProcessDlg::IDD, pParent)
{

}

void WaitProcessDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_PROGRESS1, m_Progress);
}


BEGIN_MESSAGE_MAP(WaitProcessDlg, CDialogEx)
ON_WM_TIMER()
END_MESSAGE_MAP()

BOOL WaitProcessDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();

str = pApp->GetProfileString(_T("Process"), _T("Process"));
if(tempHWND = ::FindWindow(NULL, str)){
EndDialog( 0 );
}else{
CMFCRibbonProgressBar* pProgressBar = new CMFCRibbonProgressBar(IDC_PROGRESS1, pProgressBar);

pProgressBar->SetInfiniteMode(m_bInfiniteProgressMode);
pProgressBar->SetRange(0, 200);
pProgressBar->SetPos(200, true);

m_Progress.SetInfiniteMode(m_bInfiniteProgressMode);
m_Progress.SetRange(0, 100);
SetTimer(IDC_PROGRESS1, 0, NULL);
}

return TRUE;

}
void WaitProcessDlg::OnTimer(UINT nIDEvent)
{

while (m_Progress.GetPos() != 100){
if (tempHWND = ::FindWindow(NULL, str)){
EndDialog(0);
KillTimer(IDC_PROGRESS1);
}
m_Progress.OffsetPos(1);
}
while (m_Progress.GetPos() != 0){
if (tempHWND = ::FindWindow(NULL, str)){
EndDialog(0);
KillTimer(IDC_PROGRESS1);
}
m_Progress.OffsetPos(-1);
}
CDialog::OnTimer(nIDEvent);
}

我需要一些示例或如何在 MFC 上创建不确定的进度条,如下所示: Progress bar

最佳答案

为了创建不确定的进度条(称为 Marquee),您需要在对话框编辑器中将进度条的 Marquee 属性设置为 True

Set Marquee to True

然后,在你的InitDialog方法中,你需要调用进度条上的SetMarquee方法:

BOOL CMFCApplication1Dlg::OnInitDialog()
{
CDialogEx::OnInitDialog();

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

m_Progress.SetMarquee(TRUE, 1); // Start the marquee

return TRUE; // return TRUE unless you set the focus to a control
}

结果如下:

Marquee result

关于c++ - 不确定的进度条?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19192465/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com