onlyou13

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
unit Unit1;

interface

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

const
  MW_MYMSG = WM_USER + 1;

type
  TFormFF = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure WmMyMsg(var Msg: TMessage); message MW_MYMSG;
  end;

var
  FormFF: TFormFF;

implementation

{$R *.dfm}

procedure TFormFF.Button1Click(Sender: TObject);
var
  wParam: Word;
begin
  //创建原子
  wParam := GlobalAddAtom('eng汉字');
  //发送
  PostMessage(Handle, MW_MYMSG, wParam, 0)
end;

procedure TFormFF.WmMyMsg(var Msg: TMessage);
var
  a: array[0..254] of Char;
  wa: Word;
  cmd: string;
begin
  //获取原子名称
  GlobalGetAtomName(Msg.WParam, @a, 255);
  //释放系统资源
  DeleteAtom(wa);
  Edit1.Text := a;
end;

end.

 

posted on 2019-06-02 10:06  onlyou13  阅读(606)  评论(0编辑  收藏  举报