📄 waitmessageu.pas
字号:
unit WaitMessageU;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{this function places the application into a message loop
that will break only when the left mouse button is clicked
on the client area of the form. the user will be unable to
resize or move the form until then.}
procedure TForm1.Button1Click(Sender: TObject);
var
TheMessage: TMSG; // holds message info
MouseClicked: boolean; // general loop control variable
begin
{initialize the loop control variable}
MouseClicked := FALSE;
{place the application into a loop until a mouse button is clicked}
while not MouseClicked do
begin
{empty the message queue}
while PeekMessage(TheMessage, Handle, 0, 0, PM_REMOVE) do;
{suspend the thread until a new message is placed in the queue}
WaitMessage();
{a new message has just dropped into the queue. retrieve it.}
PeekMessage(TheMessage, Handle, 0, 0, PM_REMOVE);
{if the new message was a mouse click, break out of the loop}
if TheMessage.Message=WM_LBUTTONDOWN then
begin
MouseClicked := TRUE;
{indicate that the message was a mouse click}
ShowMessage('A message was received, resume execution');
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -