Smarter Records in Turbo Delphi / Delphi 2006
type
TTurboRecord = record
strict private
fNameValue : integer;
function GetName: string;
public
NamePrefix : string;
constructor Create(const initNameValue : integer) ;
property Name : string read GetName;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor TTurboRecord.Create(const initNameValue : integer) ;
begin
fNameValue := initNameValue;
NamePrefix := '"record constructor"';
end;
function TTurboRecord.GetName: string;
begin
Inc(fNameValue) ;
result := Format('%s %d',[NamePrefix, fNameValue]) ;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
turboRecord : TTurboRecord;
anotherTurboRecord : TTurboRecord;
begin
//no Constructor needed - fNameValue = 0 by default
turboRecord.NamePrefix := 'turboRecord';
Memo1.Lines.Add(turboRecord.Name) ;
Memo1.Lines.Add(turboRecord.Name) ;
//constructor used
turboRecord := TTurboRecord.Create(2006) ;
Memo1.Lines.Add(turboRecord.Name) ;
Memo1.Lines.Add(turboRecord.Name) ;
anotherTurboRecord := turboRecord;
anotherTurboRecord.NamePrefix := 'anotherTurboRecord';
Memo1.Lines.Add(anotherTurboRecord.Name) ;
Memo1.Lines.Add(anotherTurboRecord.Name) ;
Memo1.Lines.Add(turboRecord.Name) ;
Memo1.Lines.Add(turboRecord.Name) ;
//NO need to FREE record types
end;
Records can have constructor, with at least one parameter.
Records support properties and static methods.
Records support operator overloading.
Records can have methods (functions, procedures).
Records do NOT support virtual methods ("virtual", "dynamic", and "message")
Records do NOT support destructors.
相关文档:
屏幕的分辨率用这个
x=GetSystemMetrics(SM_CXSCREEN)
y=GetSystemMetrics(SM_CYSCREEN)
同上。
.而且获得屏幕上的像素好像应该使用
screen.pixelsperinch函数
int GetDeviceCaps(
  ......
TDXDraw DirectDraw 和 Direct3D 组件
TDXDIB 容纳DIB(设备无关位图,Device Independent Bitmap)的组件
TDXImageList 图片列表组件
TDX3D Direct3D 组件 (和TDXDraw一起使用)
TDXSound DirectSound 组件
TDXWave 容纳 Wave(波形音频 ......
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
......
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. ......
设置字体的过程
Procedure TForm1.FontDlgApply(Sender:Tobject);
begin
Button1.Font:= FontDialog1.Font;
end;
该程序只有当用户按动About框的按钮或被About窗控制图标关闭窗口后,才会回到主窗体中,而不能与第一个窗体发生交互行为。这就是方法Show和ShowModal的主要不同之处
集合类型是一群相同类型元素的组合 ......