请问如何在用MessageBox的同时使程序执行下去?(30分)

  • 主题发起人 主题发起人 Lonelysword
  • 开始时间 开始时间
L

Lonelysword

Unregistered / Unconfirmed
GUEST, unregistred user!
请问如何在用MessageBox的同时使程序执行下去?
 
自己做一个form+label. 窗口显示调用时使用show, 不要用shoemodal .
 
也可以用线程
 
看来,您只能用form的show方法来模拟一个messagebox消息了.<br>用线程比较麻烦.
 
有个好方法就是放个Timer,在那里调用MessgeBox,我试过,OK,当然有点龌龊了
 
&nbsp; &nbsp;用多线程就可以了。
 
自己做个MessageBox,这也不难.<br><br>
 
agree with Seasky
 
自己做一个窗口象messagebox的一样,调用它用show即可。
 
不过如果自己做个form,仲可唔可以好似MessageBox那样使用SystemModal来放在最顶层?
 
只要使它有stayontop的属性问题不是很大吧?
 
哪里有StayOnTop属性?
 
&nbsp; &nbsp;SDKhelp中说Dialog在闲时会发送WN_ENTERIDLE.请用过此消息的<br>富翁详细介绍一下,谢谢!
 
Lonelysword:<br>&nbsp; &nbsp;If MessageDlg('下面的提示对你有用吗?',mtConfirmation, [mbYes, bNo], <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0) = mrYes <br>&nbsp; &nbsp;then &nbsp;begin<br>&nbsp; &nbsp; &nbsp; showmessage(&lt;font color=red &gt;' 请给我加分'&lt;font&gt;&lt;/font&gt;&lt;/pre&gt;);<br>&nbsp; &nbsp;end;<br>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br>Make a form Showmodal by using Show<br><br>Sometime you have a form that you would like to act like a showmodal<br>form but you would like the calling form to control it. An example<br>of this is when you are displaying a progress dialog. The problem is<br>that if you use Showmodal then all your code to perform the operation<br>must exist in the showmodal form, this is not always the desired way<br>to coding. An easy way to do this is to use DisableTaskWindows and<br>EnableTaskWindows to make your dialog act like a showmodal form but<br>at the same time allow the calling form to control the dialog.<br><br>procedure TForm1.ShowProgressDlg;<br>var<br>WindowList: Pointer;<br>begin<br>{Disables all forms except Form2}<br>WindowList := DisableTaskWindows(Form2.Handle);<br>try<br><br>Form2.Show;<br><br>{Loop that performs a task}<br>Form2.ProgressBar1.Position := Form2.ProgressBar1.Position + 1;<br>{end loop}<br><br>finally<br>{enable all forms again}<br>EnableTaskWindows(WindowList);<br>Form2.Close;<br>end;<br>end;<br><br>
 
&nbsp;Sorry,Try again:<br><br>&nbsp; Make a form Showmodal by using Show<br><br>Sometime you have a form that you would like to act like a showmodal<br>form but you would like the calling form to control it. An example<br>of this is when you are displaying a progress dialog. The problem is<br>that if you use Showmodal then all your code to perform the operation<br>must exist in the showmodal form, this is not always the desired way<br>to coding. An easy way to do this is to use DisableTaskWindows and<br>EnableTaskWindows to make your dialog act like a showmodal form but<br>at the same time allow the calling form to control the dialog.<br><br>procedure TForm1.ShowProgressDlg;<br>var<br>WindowList: Pointer;<br>begin<br>&nbsp; {Disables all forms except Form2}<br>&nbsp; WindowList := DisableTaskWindows(Form2.Handle);<br>&nbsp; try<br>&nbsp; &nbsp; Form2.Show;<br>&nbsp; &nbsp; {Loop that performs a task}<br>&nbsp; &nbsp; Form2.ProgressBar1.Position := Form2.ProgressBar1.Position + 1;<br>&nbsp; &nbsp; {end loop}<br>&nbsp; finally<br>&nbsp; &nbsp; {enable all forms again}<br>&nbsp; &nbsp; EnableTaskWindows(WindowList);<br>&nbsp; &nbsp; Form2.Close;<br>&nbsp; end;<br>end;<br><br>
 
多人接受答案了。
 
后退
顶部