Autor Beitrag
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mi 23.10.02 23:25 
Hi,

ich bastel grad an einer komponente, und hab da ein problem.. ich möchte etwas wie einen NotifyEvent machen, da es allerdings NonVCL ist geht nen TNotifyEvent net :)

kann mir jemand erklären wie ich das am besten machen kann mit NonVCL???

in meiner Komponente habe ich eine Funktion, die ruft man einmalig auf, und die soll eine Funktion meiner wahl zu einem bestimmten zeitpunkt aufrufen... nur hab ich KA, wie ich festlege welche funktion aufgerufen wird... :)

ich hoffe mal irgendjemand hat verstanden was ich machen will *g*

Au'revoir,
Aya
FriFra
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Mi 23.10.02 23:43 
Setze beim Aufruf Deiner Funktion einfach eine Variable...
Später (onEvent) fragst Du einfach diese Variable ab und führst dann eben Code in Abhängikeit dieses Wertes aus

Ich hoffe ich hatte das richtig verstanden :roll:
Aya Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mi 23.10.02 23:58 
kannst du mir mal ein beispiel machen? :)
Cashels
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167



BeitragVerfasst: Do 24.10.02 07:12 
Hey,

ne andere Möglichkeit ist die, dass du dir einen Funktionstyp baust. Hier erst mal der Code:
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
unit Unit2;

interface

type
 TFunc = function (x : double) : double ;

function Kreis (x : double) : double ;
function Quadrat (x : double) : double ;

procedure Teste (f : TFunc ; x : double) ;


implementation
uses dialogs, sysutils ;

function Kreis (x : double) : double ;
begin
   Result := x*x*Pi ;
end ;

function Quadrat (x : double) : double ;
begin
   Result := x*x ;
end;


procedure Teste (f : TFunc ; x : double) ;
begin
   showmessage (format ('%.2f',[f(x)])) ;
end ;

end.


Jetzt kanns du deine Procedur mit Teste aufrufen. Abhängig vom Parameter f wird dann entweder die Kreis- oder Quadratfläche errechnet. Aufruf mittels Teste (Kreis,2) z.B.

Diese Methode hat allerdings den Nachteil, dass sämtlich aufrufbaren Funktionen genau die gleichen Parameter haben wie TFunc. Hier wäre die Berechnung eines Rechtecks mittels einem Parameter also z.B. nicht möglich. Deshalb würd ich auch die Ereignismethode bevorzuge.

Gruss,
Tom