델피의 클래스 이해(11) - 클래스에 깊이 들어가는 방법[12] - 메시지 방법

2410 단어 Delphi


//      :



{    Win32   ,       OnKeyDown   }

procedure Tbu.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);

begin

  Self.Text := Char(Key);

end;



{  :         ,            }


 
   
// unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure KeyDown(var msg: TWMKeyDown); message WM_KEYDOWN; end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.KeyDown(var msg: TWMKeyDown); begin Self.Text := Char(msg.CharCode); end;
// : procedure KeyDown(var msg: TWMKeyDown); message WM_KEYDOWN; { 1、 : message ; 2、 : WM_KEYDOWN; 3、 , KeyDown ; 4、 , TWMKeyDown TWMKey , TWMKey; 5、 msg ; 6、 var; 7、 . }
// , ? ? { } unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) { OnKeyDown } procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); {WM_KEYDOWN } procedure KeyDown(var msg: TWMKeyDown); message WM_KEYDOWN; end; var Form1: TForm1; implementation {$R *.dfm} { OnKeyDown } procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin ShowMessage(' : ' + Char(Key)); end; {WM_KEYDOWN } procedure TForm1.KeyDown(var msg: TWMKeyDown); begin ShowMessage(' : ' + Char(msg.CharCode)); end; end. { : , , }
// ? ! { :} procedure TForm1.KeyDown(var msg: TWMKeyDown); begin ShowMessage(' : ' + Char(msg.CharCode)); inherited; end; { , } { :} procedure TForm1.KeyDown(var msg: TWMKeyDown); begin inherited; ShowMessage(' : ' + Char(msg.CharCode)); end; { , }
{ , , WM_KEYDOWN , Windows ; , , ; Delphi TWMKey , ... . , ; . }

좋은 웹페이지 즐겨찾기