Показать сообщение отдельно
  #3  
Старый 13.01.2011, 13:21
Аватар для NumLock
NumLock NumLock вне форума
Let Me Show You
 
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
По умолчанию

таймер без привязки к TForm:
Код:
program Project1;

uses
  Windows,
  Messages,
  Forms,
  Classes,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

type
  TWndTimer = class
  private
    FWindowHandle: HWND;
    procedure WndProc(var Msg: TMessage);
  public
    constructor Create;
    destructor Destroy; override;
  end;

var
  FWndTimer: TWndTimer;

{ TWndTimer }

constructor TWndTimer.Create;
begin
  inherited Create;
  FWindowHandle:=AllocateHWnd(WndProc);
  SetTimer(FWindowHandle, 1, 500, nil);
end;

destructor TWndTimer.Destroy;
begin
  KillTimer(FWindowHandle, 1);
  DeallocateHWnd(FWindowHandle);
  inherited Destroy;
end;

procedure TWndTimer.WndProc(var Msg: TMessage);
begin
  if Msg.Msg=WM_TIMER then
  begin
    { do it }
    Windows.Beep(1000, 100);
  end else Msg.Result:=DefWindowProc(FWindowHandle, Msg.Msg, Msg.WParam, Msg.LParam);
end;

begin
  FWndTimer:=TWndTimer.Create;
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
  FWndTimer.Free;
end.
__________________
Пишу программы за еду.
__________________
Ответить с цитированием