将ProgressBar从正常切换到Marquee
Switch progressbar from normal to marquee
我有一个具有进度条的对话框。我不想在该对话框中添加一种方法,该对话框将进度栏设置为侯爵。我尝试以下内容:
void CDownloader::SetIntermediate(wstring info)
{
SetDlgItemText(IDC_DOWNLOADER_LABEL, info.c_str());
auto style = GetWindowLong(GWL_STYLE);
style &= ~( PBS_SMOOTH | PBS_SMOOTHREVERSE | PBS_VERTICAL);
style |= PBS_MARQUEE;
SetWindowLong(GWL_STYLE, style);
RECT windowRect;
GetWindowRect(&windowRect);
SetWindowPos(HWND_TOP, &windowRect,SWP_FRAMECHANGED);
HWND progress = GetDlgItem(IDC_DOWNLOADER_PROGRESS);
::SendMessage(progress, PBM_SETMARQUEE, TRUE, 100);
}
但是这不起作用:(
我使用setWindowpos更新样式并将进度设置为Marquee。
我可以将设计师中的进度栏设置为Marquee,但不能将BAC切换为正常。
对于所有正确的代码:
void CDownloader::SetPending(bool value)
{
if(value)
{
HWND progress = GetDlgItem(IDC_DOWNLOADER_PROGRESS);
auto style = ::GetWindowLong(progress, GWL_STYLE);
style |= PBS_MARQUEE;
::SetWindowLong(progress, GWL_STYLE, style);
::SendMessage(progress, PBM_SETMARQUEE, TRUE,0);
}
else
{
HWND progress = GetDlgItem(IDC_DOWNLOADER_PROGRESS);
auto style = ::GetWindowLong(progress, GWL_STYLE);
style &= ~PBS_MARQUEE;
::SetWindowLong(progress, GWL_STYLE, style);
::SendMessage(progress, PBM_SETMARQUEE, FALSE,0);
}
}
相关文章:
- 与互斥锁相比,旋转锁可以保证上下文切换
- 如何在运行中期切换GTK CSS style_context
- 线程,如果else语句,都是错误的上下文切换后,会发生什么
- 如何在cpp文件之间切换窗口?在Qt中
- 为什么常量词在重载运算符中不与 ostream 对象一起使用<<?
- C 和 C++ 中开关语句的案例标签的常量值,但显示不同的行为
- 如何切换整数的 N 位
- 切换大小写后如何阻止变量重置?
- 为什么我们将单个或多维数组的大小声明为常量值?
- C++ 程序菜单使用做同时和切换
- 数组类型 int[n][n] 不可赋值,因为表达式必须具有常量值
- 在线程中读取无符号整数时,c++ 位是否以原子方式切换?
- 在 C++ 中运行时调用模板时,是否可以切换模板的参数类型?
- const_cast静态数组以添加恒常性
- 为什么这个选择排序算法仍然切换一个元素,当它已经是其他元素中最小的元素时?
- 为什么切换 for 循环的顺序会显著改变执行时间?
- MFC:我们如何轻松地从CTreeCtrl切换到CTreeView?
- pthread_spinlock是否会导致从用户空间切换到内核空间
- GLFW 切换布尔切换
- 将ProgressBar从正常切换到Marquee