⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 罗小平<<delphi精要>>一书源码
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

const MY_MESSAGE = WM_USER + 1;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    FOneProperty: Integer;
    procedure DoMY_MESSAGE(var Msg: TMessage); message MY_MESSAGE;
    procedure SetOneProperty(Value: Integer);
  published
    property OneProperty: Integer read FOneProperty write SetOneProperty;
  end;
  function SetOneProp(Handle: HWND; PropName: String; PropValue: Integer): Boolean;

var
  Form1: TForm1;

implementation

uses TypInfo;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  P: PChar;
begin
  GetMem(P, MAXBYTE);
  SendMessage(Edit1.Handle, WM_GETTEXT, MAXBYTE, PInteger(@P)^);
  ShowMessage(P);
  FreeMem(P);
end;

procedure TForm1.DoMY_MESSAGE(var Msg: TMessage);
begin
  ShowMessage(Name);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  SendMessage(Handle, MY_MESSAGE, 0, 0);
end;

function SetOneProp(Handle: HWND; PropName: String; PropValue: Integer): Boolean;
var
  tfContrl: TWinControl;
begin
  tfContrl := FindControl(Handle);
  Result := (tfContrl <> nil) and (GetPropInfo(tfContrl, PropName) <> nil);
  if Result then
    SetOrdProp(tfContrl, PropName, PropValue);
end;

procedure TForm1.SetOneProperty(Value: Integer);
begin
  FOneProperty := Value;
  case FOneProperty of
    0:
      ShowMessage(Name);
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  SetOneProp(Handle, 'OneProperty', 0);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -