如题,需要哪几个步骤啊,没有头绪,一般的书上都避而不谈
解决方案 »
- edit怎么样判断扫描枪扫描还是键盘输入。(100分相送)
- 客户端如何接收来自ftp服务器上某个运行程序x的句柄 当然程序x是自己开发的
- 如何设置 adoconnection1.ConnectionString:=???
- 请各位帮帮忙
- 关于ADO的注册
- 在delphi中 如何修改操作系统日期时间格式??
- 如何使程序在系统启动时自动运行
- 如何赋值?(method pointer)
- 在VB中如何进行“左或右移位”计算?
- 代码实现当前目录的备份,比如:d:\aa下执行程序bk.exe,则建目录d:\aa\backup,将d:\aa目录下所有内容copy 至d:\aa\backup下(包括程序bk.exe
- 如何使同级菜单的Checked属性互斥?
- 怎样控制在edit中输入小数????????????
unit treecode;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ADODB, ImgList, ComCtrls, DBTables, DB,
WinSkinData;type
TForm1 = class(TForm)
TVcode: TTreeView;
ImageList1: TImageList;
BitBtn1: TBitBtn;
ADOtbl: TADOTable;
SkinData1: TSkinData;
BitBtn2: TBitBtn; procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
function LoadCode(crTbl:TadoTable):Integer;
function GetLevel(sFormat,sCode:String):Integer;
public
{ Public declarations }
end;var
Form1: TForm1;
const
SCodeFormat ='322222'; //科目代码结构
SFirstNodeTxt ='科目代码'; //首节点显示的文字
implementationuses about;{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
close;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
adotbl.indexfieldnames:='acode';
loadcode(adotbl);
end;function Tform1.LoadCode(crTbl:TadoTable):Integer;
var
newid,showTxt:string;
level:integer;
MyNode:array[0..6]of TTreeNode;//保存各级节点,最长支持6级(重点)
begin
Screen.Cursor:=crHourGlass;
level:=0;
with crTbl do
begin
try
if not active then
open;
first;
tvcode.Items.Clear;
//以下增加第一项
mynode[level]:=tvcode.Items.Add(tvcode.TopItem,SFirstNodeTxt);
mynode[level].ImageIndex:=0;
mynode[level].SelectedIndex:=0;
//以上是增加第一项
while not eof do
begin
newid:=trim(fieldbyname('acode').AsString);
ShowTxt:=NewID+''+FieldByName('aName').AsString;
level:=getlevel(SCodeFormat,newid);//返回代码的级数
//以下是增加子项
//以下用上一级节点为父节点添加子节点
if level>0 then //确保代码符合标准
begin
mynode[level]:=tvcode.Items.AddChild(mynode[level-1],showtxt);
mynode[level].ImageIndex:=1;
mynode[level].SelectedIndex:=2;
end;
next;
end;
finally
close;
end;
end;
mynode[0].Expand(false);//将首节点展开
Screen.Cursor:=crDefault;
end;function Tform1.GetLevel(sFormat,sCode:String):Integer;
var
i,level,ilen:integer;
begin
level:=-1;
ilen:=0;
if (sFormat<>'') and (sCode<>'') then
begin
for i:=1 to length(sFormat) do
begin
ilen:=ilen+strtoint(sFormat[i]);
if length(sCode)=ilen then
begin
level:=i;
break;
end;
end;
end;
result:=level;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
form2.ShowModal;
end;end.
uses TypInfo;procedure TForm1.Button1Click(Sender: TObject);
begin
SetStrProp(Self, 'Caption', 'Hello');
SetOrdProp(Self, 'Color', clRed);
SetSetProp(Self, 'BorderIcons', '[biMinimize]');
end;
uses typinfo;
...procedure TForm1.Button2Click(Sender: TObject);
var
a:Variant;
PropName:String;
begin
PropName:=Edit1.Text;
a:=GetPropValue(Button1,PropName);
ShowMessage(a);end;
TC = class
private
FCaption: String;
public
destructor Destroy; override;
property Caption: String read FCaption write FCaption;
end;
这样就不行,是不是在用SetStrProp之前还需要对该属性进行类似于注册之类的操作?
借此机会进一步问各位:要是我想通过字符串得到一个类的实例,并且访问他的方法,我该怎么做呢?
通过字符串、指针访问一个过程或函数我该怎么做?
private
FCaption: String;
public
destructor Destroy; override;
published
property Caption: String read FCaption write FCaption;
end;//Classes中的函数~~
function GetClass(const AClassName: string): TPersistentClass;
begin
RegGroups.Lock;
try
Result := RegGroups.GetClass(AClassName);
finally
RegGroups.Unlock;
end;
end;function FindClass(const ClassName: string): TPersistentClass;
begin
Result := GetClass(ClassName);
if Result = nil then ClassNotFound(ClassName);
end;//自己去研究研究~~
procedure RegisterClass(AClass: TPersistentClass);
procedure RegisterClasses(AClasses: array of TPersistentClass);
procedure UnRegisterClass(AClass: TPersistentClass);
procedure UnRegisterClasses(AClasses: array of TPersistentClass);
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, TypInfo;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; TC = class
private
FCaption: String;
public
destructor Destroy; override;
published
property Caption: String read FCaption write FCaption;
end;var
Form1: TForm1;
C: TC;implementation{$R *.dfm}destructor TC.Destroy;
begin
inherited Destroy;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
C := TC.Create;
SetStrProp(C, 'Caption', 'AAA');
end;initialization
RegisterClass(TC); //怎样使用RegisterClass?end.
这句编译不过,提示类型不匹配 TPersistentClass and Class reference
我使用RegisterClass(TPersistentClass(TC));
能编译过,但已运行就提示经典的访问无效地址搞不明白,还请高手指教,在线等,运行成功马上给分,先谢谢
private
FCaption: String;
public
destructor Destroy; override;
published
property Caption: String read FCaption write FCaption;
end;
Syntax {$M+} or {$M-}
{$TYPEINFO ON} or {$TYPEINFO OFF}
Default {$M-}
{$TYPEINFO OFF}
Scope Local
The $M switch directive controls generation of runtime type information (RTTI). When a class is declared in the {$M+} state, or is derived from a class that was declared in the {$M+} state, the compiler generates runtime type information for fields, methods, and properties that are declared in a published section. If a class is declared in the {$M-} state, and is not derived from a class that was declared in the {$M+} state, published sections are not allowed in the class. Note that if a class is forward declared, the first declaration of the class must be declared with the $M switch.Note: The TPersistent class defined in the Classes unit of the VCL and CLX is declared in the {$M+} state, so any class derived from TPersistent will have RTTI generated for its published sections. The VCL/CLX uses the runtime type information generated for published sections to access the values of a component's properties when saving or loading form files. Furthermore, the IDE uses a component's runtime type information to determine the list of properties to show in the Object Inspector.There is seldom, if ever, any need for an application to directly use the $M compiler switch.//....{$M+}
TC = class
private
FCaption: String;
public
destructor Destroy; override;
published
property Caption: String read FCaption write FCaption;
end;
{$M-}var
Form1: TForm1;
C: TC;implementation{$R *.dfm}destructor TC.Destroy;
begin
inherited Destroy;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
C := TC.Create;
SetStrProp(C, 'Caption', 'AAA');
end;//....
大家又不是为蹭这点分来的~~
要是你闲麻烦就把分全部给俺吧~~
他们不会说什么的~~嘿嘿!(左手捂住FrameSniper的嘴,右手捂住halfdream的嘴)