I have it TTimer
turned on and should start without stops forever until the user stops it. However, this does not work. In an event, OnTimer
it processes window messages over and over in milliseconds.
For example, here is a snippet of code.
procedure TDXCommDlg.Timer2Timer(Sender: TObject);
begin
inherited;
if Scanning then
begin
Timer1.Enabled := false;
Timer2.Enabled := false;
while not PostMessage(Handle,WM_USER + 10,1234,5678) do;
Timer1.Enabled := true;
end;
end;
What happens is this. While TTimer is turned on and running, you drag all the windows of the application or click on the drop-down menu, the TTimer event completely stops working, although I took precautions in another part of the code to prevent this from happening. However, this does not seem to help.
The only way to restart the event OnTimer
is to stop and restart the timer by the user through the TButton event.
Windows XP, Delphi 7. Windows 7 Delphi 2010 .
. , .
HandleMsg. . HandleMsg onMessage;
Application.OnMessage: = HandleMsg();
PostMessage onMessage .
PostMessage, onMessage, HandleMsg().
:
procedure TDXCommDlg.HandleMsg(var
Msg: TMsg; var Handled: Boolean);
begin
Handled := false;
case Msg.message of
WM_USER + 10:
begin
if (Msg.wParam = 1111) and (Msg.lParam = 2222) then
begin
SendLanMessage;
Handled := true;
end
else if (Msg.wParam = 1234) and (Msg.lParam = 5678) then
begin
SendMessage;
Handled := true;
end
else
begin
if (Msg.wParam = 4321) then
begin
MainFrm.CloseWindow(TViewFrm(Msg.lParam).WinCap);
end;
end;
end;
end; { case } end;
HandleMsg() PostMessage. , .