易截截图软件、单文件、免安装、纯绿色、仅160KB

Delphi 使用自定义消息

1、先用Const 定义一个常量,例如 const WM_MyMessage=WM_USER+$200;
2、在要实现的unit中定义一个私有方法
   procedure doMyMessage(var msg:TMessage);message WM_MyMessage;
3、实现这个私有方法
    procedure TForm1.doMyMessage(var msg:TMessage);
begin
  //
  if msg.Msg= WM_MyMessage then
    showmessage('好啊')
  else
    showmessage('不好');
 
end;
 
 
4、最重要 把这个消息广播出去 Form1.Perform(WM_MyMessage,0,0);
 
下面是实现的代码
 
 
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
const WM_MyMessage=WM_USER+$200;
 
type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    procedure doMyMessage(var msg:TMessage);message WM_MyMessage;
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.doMyMessage(var msg:TMessage);
begin
  //
  if msg.Msg= WM_MyMessage then
    showmessage('好啊')
  else
    showmessage('不好');
 
end;
 
procedure TForm1.Button1Click(Sender: TObject);
 
begin
   Form1.Perform(WM_MyMessage,0,0);
 
end;
 
end.


相关文档:

怎样用DELPHI接收摄像头的图象

community.csdn.net/Expert/topic/3423/3423580.xml?temp=.7675897
主  题:  怎样用DELPHI接收摄像头的图象 
作  者:  benbenpear (笨笨) 
等  级:   
信 誉 值:  100 
所属社区:  Delphi GAME,图形处理/多媒体 
问题点数:  0  ......

Delphi Copy函数效率的问题

技术交流,DH讲解. 最近和肥鸟交流了下关于字符串方面的知识,而这篇文章是很久以前写的,现在发出来吧. 我们写两段代码来对比下:
第一个用Copy函数:
procedure TForm1.Button1Click(Sender: TObject);
var
a,c:Cardinal;
n:Integer;
D:Double;
i:Integer;
b:string;
begin
c:=0; ......

Delphi Enum

枚举类型
  Pascal程序不仅用于数值处理,还更广泛地用于处理非数值的数据。例如,性别、月份、星期几、颜色、单位名、学历、职业等。
1、枚举类型的定义
格式: type 枚举类型标识符=(标识符1,标识符2,…,标识符n)
2、枚举类型数据特点
① 枚举元素只能是标识符;
例如,下列类型定义是合法的:
   type ......

Delphi字符串加密解密函数


Delphi字符串加密解密函数
功能:字符串加密和解密
首先定义一个常量数组
const
      XorKey:array[0..7] of Byte=($B2,$09,$AA,$55,$93,$6D,$84,$47); //字符串加密用
在程序里加入以下两个函数,
function Enc(Str:String):String;//字符加密函數 這是用的一個&# ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号