简单问题,需要解决

wangxd 2001-06-14 08:08:00
我想在执行一段操作前,鼠标变成漏斗,执行完后,再变回箭头,可下面代码没用
this->Cursor=crHourGlass;
for(...)
{
...
...
}
this->Cursor=crDefault;
我知道是因为消息没有分发的原因,所以这样可以解决
this->Cursor=crHourGlass;
for(...)
{
...
...
Application->ProcessMessages()
}
this->Cursor=crDefault;
可这样效率太低,速度降了许多
最好的方法应该是用线程了,但我就是不想用它:) 感到有些牛刀小试了
各位有没有什么别的好办法?
...全文
67 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangxd 2001-07-03
  • 打赏
  • 举报
回复
纷纷
wangxd 2001-06-17
  • 打赏
  • 举报
回复
wangxd 2001-06-17
  • 打赏
  • 举报
回复
看来知识的掌握还是不全面啊,结束
猛禽 2001-06-15
  • 打赏
  • 举报
回复
ALNG(至饶远势波千倾,渐满清辉月上弦)兄:我想他可能也是要这种效果,但我同意你的看法,这样没什么意义,如你所说:“还要费劲disable一些菜单项和Buttons以避免不希望的重入。 ”,多麻烦
Sephil 2001-06-15
  • 打赏
  • 举报
回复
是啊
应该是 Screen->Cursor 把
孩皮妞野 2001-06-15
  • 打赏
  • 举报
回复
Screen是可以, 但是Wangxd可能要的是另一种效果;

****Form1*****

#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form2->Show();
}
//---------------------------------------------------------------------------


****Form2*********************
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm2::Button1Click(TObject *Sender)
{
Cursor = crHourGlass;

for(int i=0; i<4; i++){
Sleep(1000);
Application->ProcessMessages();
}

Cursor = crDefault;
Close();
}
//---------------------------------------------------------------------------

执行一下, 可以发现, Form2->Button1Click执行过程中, 移到Form1上,
Cursor会变成crDefault, 与
Screen->Cursor = crHourGlass;
的效果有细微差别。

但是确实不知道更好的办法, 我觉得如果不用线程, 应该使用
Screen->Cursor = crHourGlass;
或者说在不使用线程的情况下,追求前面的效果无大意义, 可能你还要费劲
disable一些菜单项和Buttons以避免不希望的重入。
「已注销」 2001-06-15
  • 打赏
  • 举报
回复
都用这个吧

我也想听听谁还有啥好主意

对了 小东

最近有啥新东东么

@_@
猛禽 2001-06-14
  • 打赏
  • 举报
回复
不会吧,用Screen->Cursor=crHourGlass;应该可以吧
windindance 2001-06-14
  • 打赏
  • 举报
回复
this->Cursor ?

use Screen->Cursor = ...
Application->ProcessMessages();

for (...)

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧