Application defined window call procedure | |||
| |||
** ** Application Title을 적어줄 경우 ** 절대로 메시지 교환이 되지 않는다. unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; const WM_WAKEUP = WM_USER + 1992; LP_READPARAM = -1; type TForm1 = class(TForm) Button1: TButton; Timer1: TTimer; Button2: TButton; procedure Button2Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } procedure WMWakeup(var Msg : TMessage); message WM_WAKEUP; end; var Form1: TForm1; AppDefWindowProc : function (h : HWND; uMsg : UINT; wp : WPARAM; lp : LPARAM): LRESULT; stdcall; implementation {$R *.dfm} //------------------------------------------------------------------------------ // AppWindowProc //------------------------------------------------------------------------------ function AppWindowProc(h : HWND; uMsg : UINT; wp : WPARAM; lp : LPARAM): LRESULT; stdcall; begin Result := AppDefWindowProc(h, uMsg, wp, lp); end; procedure TForm1.WMWakeup(var Msg : TMessage); begin // do something Color := clBlack; end; procedure TForm1.Button2Click(Sender: TObject); var h:HWND; begin h := FindWindow( THandle(nil), 'bb'); if (h=0) then begin ShowMessage( 'appliation not found'); end else begin // Make top most window SetWindowPos( h, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOZORDER or SWP_NOMOVE); // Wake up window to do something SendMessage( h, WM_WAKEUP, 0, LP_READPARAM); end; end; procedure TForm1.Button1Click(Sender: TObject); begin // Set Application Title Application.Title := 'bb'; Caption := 'bb'; // This will be used to find window end; procedure TForm1.FormCreate(Sender: TObject); begin // Application Defined Window Procedure Call Registration AppDefWindowProc := Pointer(SetWindowLong(Application.Handle, GWL_WNDPROC, Integer(@AppWindowProc))); end; end. Tags: 윈도우즈 | |||
| |||
| |||
로그인을 하시면 댓글을 등록 할 수 있습니다. |