 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
chnlog Guest
|
Posted: Fri Feb 20, 2004 12:19 pm Post subject: GetMehods procedure |
|
|
Hi,
i write a form designer inherted from iFormDesigner,and now it can
work,but i don't select method ,because i don't know how to get event method
in the GetMethods method.
procedure TMyFormDesigner.GetMethods(TypeData: PTypeData;Proc: TGetStrProc);
begin
end;
can any one tell me how write the method code to get designered form's event
method.
thanks
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Feb 20, 2004 9:00 pm Post subject: Re: GetMehods procedure |
|
|
"chnlog" <chnlog (AT) 163 (DOT) com> wrote
| Quote: | i write a form designer inherted from iFormDesigner
|
Why are you implementing your own designer? What is wrong with using the
native one? What exactly are you trying to accomplish in general?
Gambit
|
|
| Back to top |
|
 |
chnlog Guest
|
Posted: Sat Feb 21, 2004 1:15 am Post subject: Re: GetMehods procedure |
|
|
No wrong message,because i want write a formdesigner that can be used at
runtime,and now it can work,and can design form at runtime ,but it couldn't
modify the event methods,because i donn't get methods of exists method
event.
for example :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage (TControl(Sender).Name);
end;
end.
i put a button1,button2 on the form ,and write button1' onclick event ,and
at runtime i want Button2's onclick event pointer Button1' onclick event ,
if at design time,the active designer can get the button1click method and
put it in button2' onclick event drop-down window ,because it can get the
method,and now my designer couldn't get the method and the button2's onclick
event drop-down window is empty.
how could i get the methods
thanks.
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sat Feb 21, 2004 3:19 am Post subject: Re: GetMehods procedure |
|
|
"chnlog" <chnlog (AT) 163 (DOT) com> wrote
Why are you asking about Delphi code in a C++ newsgroup anyway?
| Quote: | how could i get the methods
|
For example (untested):
uses TypInfo;
procedure TMyFormDesigner.GetMethods(TypeData: PTypeData; Proc:
TGetStrProc);
var
Props: PPropList;
PropTypeData: PTypeData;
PParamList: Pointer;
PropCount, I: Integer;
function MethodMatches(MethodData: PTypeData): Boolean;
var
J: Integer;
P1, P2: Pointer;
begin
Result := False;
if (MethodData^.MethodKind = TypeData^.MethodKind) and
(MethodData^.ParamCount = TypeData^.ParamCount) then
begin
P1 := @(MethodData^.ParamList);
P2 := @(TypeData^.ParamList);
for J := 0 to (MethodData^.ParamCount -1) do
begin
if not (TParamFlags(P1^) = TParamFlags(P1^)) then Exit;
P1: = Pointer(Integer(P1)+1);
P2: = Pointer(Integer(P2)+1);
P1: = Pointer(Integer(P1)+Length(PShortString(P1)^)+1);
P2: = Pointer(Integer(P2)+Length(PShortString(P2)^)+1);
if not (PShortString(P1)^ = PShortString(P2)^) then
Exit;
P1 := Pointer(Integer(P1)+Length(PShortString(P1)^)+1);
P2 := Pointer(Integer(P2)+Length(PShortString(P2)^)+1);
end;
Result := True;
end;
end;
begin
if Form = nil then Exit;
PropCount := GetPropList(Form.ClassInfo, tkMethods, nil);
if (PropCount > 0) then
begin
GetMem(Props, PropCount * SizeOf(PPropInfo));
try
GetPropList(Form.ClassInfo, tkMethods, Props);
for I := 0 to (PropCount-1) do
begin
with Props[I]^ do
begin
if MethodMatches(GetTypeData(PropType^)) then
Proc(Name);
end;
end;
finally
FreeMem(Props);
end;
end;
end;
Gambit
|
|
| Back to top |
|
 |
chnlog Guest
|
Posted: Sat Feb 21, 2004 5:51 am Post subject: Re: GetMehods procedure |
|
|
| Quote: | Why are you asking about Delphi code in a C++ newsgroup anyway?
|
I'm sorry
thanks, the code can get the event methods ,but it gets all methods from the
form's typeinfo ,for example, if OnFormShow event no code, it is null,but
the Event is exists , the code also get Onformshow event,but in fact it need
not get the Onformshow, and if Onformshow have codes named Form1Show,the
code should get Form1Show,but not are Onxxxxxx.
can you help me.
| Quote: |
uses TypInfo;
procedure TMyFormDesigner.GetMethods(TypeData: PTypeData; Proc:
TGetStrProc);
var
Props: PPropList;
PropTypeData: PTypeData;
PParamList: Pointer;
PropCount, I: Integer;
function MethodMatches(MethodData: PTypeData): Boolean;
var
J: Integer;
P1, P2: Pointer;
begin
Result := False;
if (MethodData^.MethodKind = TypeData^.MethodKind) and
(MethodData^.ParamCount = TypeData^.ParamCount) then
begin
P1 := @(MethodData^.ParamList);
P2 := @(TypeData^.ParamList);
for J := 0 to (MethodData^.ParamCount -1) do
begin
if not (TParamFlags(P1^) = TParamFlags(P1^)) then
Exit;
P1: = Pointer(Integer(P1)+1);
P2: = Pointer(Integer(P2)+1);
P1: =
Pointer(Integer(P1)+Length(PShortString(P1)^)+1);
P2: =
Pointer(Integer(P2)+Length(PShortString(P2)^)+1);
if not (PShortString(P1)^ = PShortString(P2)^) then
Exit;
P1 :=
Pointer(Integer(P1)+Length(PShortString(P1)^)+1);
P2 :=
Pointer(Integer(P2)+Length(PShortString(P2)^)+1);
end;
Result := True;
end;
end;
begin
if Form = nil then Exit;
PropCount := GetPropList(Form.ClassInfo, tkMethods, nil);
if (PropCount > 0) then
begin
GetMem(Props, PropCount * SizeOf(PPropInfo));
try
GetPropList(Form.ClassInfo, tkMethods, Props);
for I := 0 to (PropCount-1) do
begin
with Props[I]^ do
begin
if MethodMatches(GetTypeData(PropType^)) then
Proc(Name);
end;
end;
finally
FreeMem(Props);
end;
end;
end;
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sat Feb 21, 2004 8:44 am Post subject: Re: GetMehods procedure |
|
|
"chnlog" <chnlog (AT) 163 (DOT) com> wrote
| Quote: | thanks, the code can get the event methods ,but it gets
all methods from the form's typeinfo
|
Initially, yes. But it also loops through those methods looking for the
ones that actually match the TypeData parameter. That is the whole purpose
of IFormDesigner.GetMethods() to begin with - to retreive a list of names
for the methods that exactly match the specified method signature.
| Quote: | for example, if OnFormShow event no code, it is null,but
the Event is exists , the code also get Onformshow event
but in fact it need not get the Onformshow, and if Onformshow
have codes named Form1Show,the code should get
Form1Show,but not are Onxxxxxx.
|
I do not understand what you are referring to. Please clearify. Please
show an actual exacmple of what you are trying to accomplish.
Gambit
|
|
| Back to top |
|
 |
chnlog Guest
|
Posted: Sun Feb 22, 2004 1:37 pm Post subject: Re: GetMehods procedure |
|
|
yes,it is ok ,thank you.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|