自建Edit後,用不到FindClass?? |
尚未結案
|
GDMichael
一般會員 發表:27 回覆:36 積分:12 註冊:2004-10-13 發送簡訊給我 |
Procedure TFCusForm.ProcCreateMDIChildForm(StrClassName : String); Var MDIFormClass : TFormClass; MDIForm : TForm; IntX : Integer; Begin Try MDIFormClass := TFormClass(FindClass(StrClassName)); MDIForm := Nil; // -------------------------------------------------- // ´M§a MDI Form Class // -------------------------------------------------- For IntX := 0 To Screen.FormCount - 1 Do Begin If (Screen.Forms[IntX] Is MDIFormClass) Then Begin MDIForm := Screen.Forms[IntX]; If (MDIForm.WindowState = wsMinimized) Then MDIForm.WindowState := wsNormal; MDIForm.BringToFront; Break; End; End; // -------------------------------------------------- // Find MDI Form Class // -------------------------------------------------- If Not (Assigned(MDIForm)) Then Begin MDIForm := MDIFormClass.Create(Application); MDIForm.Show; End; Except //FunDisplayMessage('«O¥s?lµ?µ!??»~!', 'Error'); End;這個是我寫作用來在main mdi form到create mdi child form,每張child form都有registerclass,但當我發覺,如果加上自己建立的control,如有一個叫fedit,那麼我在uses時便會自動加上fedit,當我run上面那段code後會說找不到class...如果沒有uses 那個fedit就會沒有事... 註: fedit是inherited tedit.... 請問為何呢? thx 發表人 - qoo1234 於 2004/11/19 18:25:42 |
GDMichael
一般會員 發表:27 回覆:36 積分:12 註冊:2004-10-13 發送簡訊給我 |
unit FEdit; interface uses
Windows, Messages, SysUtils, Classes, QControls, QStdCtrls, ExtCtrls,
StdCtrls, Controls, Forms, Graphics, UCrpeUtl, StrUtils; type
TFValidationType = (Null, Alpha, AlphaNumeric, Numeric);
TFColorType = (Default, Disable, Mandatory, Either, ReadOnly);
TFEdit = class(TEdit)
private
{ Private declarations }
protected
{ Protected declarations }
FControlCaption : String;
FFieldName : String;
FTableName : String;
FIsRequired : Boolean;
FActionColor : TFColorType;
FValidationType : TFValidationType;
FDefaultValue : String;
FFieldValue : String; procedure SetControlCaption(Value: String);
procedure SetFieldName(Value: String);
procedure SetTableName(Value: String);
procedure SetIsRequired(Value: Boolean);
procedure SetDefaultValue(Value: String);
procedure SetFieldValue(Value: String);
Function CheckRequired: Boolean;
Function CheckNumeric: Boolean;
Function CheckAlpha: Boolean;
Function CheckAlphaNumeric: Boolean;
Function GetValType(): TFValidationType;
Function GetColorType(): TFColorType;
public
{ Public declarations }
Function CheckValidation: Boolean;
constructor Create(AOwner : TComponent); override;
published
{ Published declarations }
property AddControlCaption: String read FControlCaption write SetControlCaption;
property AddFieldName: String read FFieldName write SetFieldName;
property AddTableName: String read FTableName write SetTableName;
property AddIsRequired: Boolean read FIsRequired write SetIsRequired;
property AddActionColor: TFColorType read FActionColor write FActionColor;
property AddValidationType: TFValidationType read FValidationType write FValidationType;
property AddDefaultValue: String read FDefaultValue write SetDefaultValue;
property AddFieldValue: String read FFieldValue write SetFieldValue;
end; procedure Register; implementation procedure Register;
begin
RegisterComponents('Faclym', [TFEdit]);
end; { TFEdit } constructor TFEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FControlCaption := '';
FFieldName := '';
FTableName := '';
FIsRequired := False;
FDefaultValue := '';
FFieldValue := '';
end; procedure TFEdit.SetControlCaption(Value: String);
begin
FControlCaption := Value;
end; procedure TFEdit.SetDefaultValue(Value: String);
begin
FDefaultValue := Value;
end; procedure TFEdit.SetFieldName(Value: String);
begin
FFieldName := Value;
end; procedure TFEdit.SetFieldValue(Value: String);
begin
FFieldValue := Value;
end; procedure TFEdit.SetIsRequired(Value: Boolean);
begin
FIsRequired := Value;
end; procedure TFEdit.SetTableName(Value: String);
begin
FTableName := Value;
end; Function TFEdit.GetValType(): TFValidationType;
begin
Result := FValidationType;
end; function TFEdit.GetColorType: TFColorType;
begin
Result := FActionColor;
end; //=======================================
// Check Is Null
//=======================================
function TFEdit.CheckRequired: Boolean;
begin
Result:= False;
If Length(self.Text) = 0 Then
Begin
Application.MessageBox(PChar(Self.AddControlCaption '¥²¶·¿?¤J¸?®Æ'),'¿?¤J¿?»~' , MB_OK);
Exit;
End;
Result:= True;
end; //=======================================
// Check Numeric
//=======================================
function TFEdit.CheckNumeric: Boolean;
begin
Result:= False;
If (isfloating(self.Text)=False) Then
Begin
Application.MessageBox(PChar(Self.AddControlCaption '¥²¶·¿?¤JNumeric'),'¿?¤J¿?»~' , MB_OK);
Exit;
End;
Result:= True;
end; //=======================================
// Check Alpha
//=======================================
function TFEdit.CheckAlpha: Boolean;
var
tmp: integer;
i: integer;
checkText: string;
begin
Result:= False;
checkText:= UpperCase(self.Text); For i:=1 To length(checkText) Do
Begin
tmp:=Ord(checkText[i]);
If Not((tmp>=65) And (tmp<=90)) Then
Begin
Application.MessageBox(PChar(Self.AddControlCaption '¥²¶·¿?¤JAlpha'),'¿?¤J¿?»~' , MB_OK);
Exit;
End;
End;
Result:= True;
end; //=======================================
// Check AlphaNumeric
//=======================================
function TFEdit.CheckAlphaNumeric: Boolean;
var
tmp: integer;
i: integer;
checkText: string;
begin
Result:= False;
checkText:= UpperCase(self.Text); For i:=1 To length(checkText) Do
Begin
tmp:=Ord(checkText[i]);
If Not(((tmp>=65) And (tmp<=90)) or ((tmp>=48) And (tmp<=57)))Then
Begin
Application.MessageBox(PChar(Self.AddControlCaption '¥²¶·¿?¤JAlphaNumeric'),'¿?¤J¿?»~' , MB_OK);
Exit;
End;
End;
Result:= True;
end; //=======================================
// Main Validation
//=======================================
function TFEdit.CheckValidation: Boolean;
var
ans: Boolean;
begin
Result:= False;
If (self.AddIsRequired=True) Then
Begin
ans:= CheckRequired;
If (ans=False) Then
Exit;
End; If (self.GetValType=Alpha) Then
Begin
ans:= CheckAlpha;
If (ans=False) Then
Exit;
End; If (self.GetValType=AlphaNumeric) Then
Begin
ans:= CheckAlphaNumeric;
If (ans=False) Then
Exit;
End; If (self.GetValType=Numeric) Then
Begin
ans:= CheckNumeric;
If (ans=False) Then
Exit;
End;
Result:= True;
end; end. 這個是我自建的control...請問有沒有什麼問題,所以導致用不到findclass呢?
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |