Autor Beitrag
Danny87
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 688

Windows 10 Pro 64bit
Sprachen: HTML, PHP, JavaScript, Delphi || IDE: RAD Studio 10.1 Berlin Starter, WeBuilder
BeitragVerfasst: Do 16.11.06 12:56 
Hey Leute,

ich möchte in einer DLL die Funktion FindComponent() benutzen.
Dazu hab ich 2 kleine Fragen:

Wie kann ich FindComponent() dazu bewegen auf einem bestimmten Form zu suchen (?) und
welchen Header muss ich einbinden, damit ich FindComponent() benutzen kann?

Danke schon mal im voraus :)

Greet'z
Daniel
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Do 16.11.06 14:23 
FindComponent gehört zur VCL (und zu TForm) --> Unit Forms.

Aber Achtung: die DLL wird durch Einbinden der VCL/Forms- Unit verdammt groß

_________________
Programmers never die, they just GOSUB without RETURN
Danny87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 688

Windows 10 Pro 64bit
Sprachen: HTML, PHP, JavaScript, Delphi || IDE: RAD Studio 10.1 Berlin Starter, WeBuilder
BeitragVerfasst: Do 16.11.06 17:52 
Hab die Unit Forms jetzt eingebunden. Es geht aber trotzdem net :(
Hier is mal meine ganze DLL (der momentane Stand). Bitte keine Kommentare über die momentan noch unnötig eingebundenen Units (zB Dialogs). Das kommt alles später noch ;)

ausblenden volle Höhe Delphi-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:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
library lib0005;

uses
  SysUtils,
  Classes,
  Dialogs,
  Forms,
  umysqlvio,
  uMysqlCT,
  uMysqlClient,
  uMysqlHelpers;

{$R *.res}

// ############################# Planeten laden ################################
procedure ViewPlanets(sSystem : string; FMysql : TMysqlClient); stdcall;
var FResult : TMysqlResult;
    ex : boolean;
    i : integer;
    sHint : string;
begin
FResult := FMysql.query('select * from planeten where system ='+
                        QuotedStr(sSystem),true,ex);
for i:=0 to FResult.RowsCount -1 do
  begin
  (FindComponent('imgPlanet'+IntToStr(i+1)) as TImage).Picture.LoadFromFile(FResult.FieldValueByName('pic'));
  with FResult do
    begin
    sHint := 'Name: '+FieldValueByName('planeten')+#10#13+
             'Typ: '+FieldValueByName('typ')+#10#13+#10#13+
             'Bevölkerung: '+FieldValueByName('bevolkerung')+#10#13+
             'Arbeitslose: '+FieldValueByName('arbeitslose')+#10#13+#10#13+
             'Anzahl Gebäude: '+FieldValueByName('gebaude')+#10#13+
             'Anzahl Schiffe: '+FieldValueByName('schiffe');
    end;
  (FindComponent('imgPlanet'+IntToStr(i+1)) as TImage).Hint := sHint;
  FResult.Next;
  end;

if FResult <> nil then FResult.Free;
end;

exports
    ViewPlanets;

begin
end.

Ich hoffe das hilft irgendwie weiter.

Gruss
Daniel
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Do 16.11.06 18:00 
Jaaa FindComponent ist ja eine Methode einer Klasse, wie z.B. deiner Form. D.h. du musst deiner DLL schon die Form beibringen. Und dann FormXY.FindComponent ausführen.

_________________
Programmers never die, they just GOSUB without RETURN
Danny87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 688

Windows 10 Pro 64bit
Sprachen: HTML, PHP, JavaScript, Delphi || IDE: RAD Studio 10.1 Berlin Starter, WeBuilder
BeitragVerfasst: Do 16.11.06 18:14 
Danke :)

...
Da hätte ich mit meinen Kenntnissen und en bisschen überlegen echt selbst drauf kommen müssen....:autsch:
*kopfauftischkanteknall*
...
???
*tischsuch*


Danke nochmal :)

Gruss
Daniel
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 16.11.06 19:11 
Das:
procedure ViewPlanets(sSystem : string; FMysql : TMysqlClient); stdcall; wird nicht gehen. Lies dir mal den Kommentar durch den Delphi in eine Unit schreibt, wenn du eine neue DLL mit dem Wizzard ertellst. Entweder du bindest überal die Unit ShareMem als erste Unit ein oder du benutzt den Typ PChar. Sie dazu auch mein Artikel: Rückgabe von Strings aus DLLs -> www.michael-puff.de/..._07_String_DLL.shtml
Danny87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 688

Windows 10 Pro 64bit
Sprachen: HTML, PHP, JavaScript, Delphi || IDE: RAD Studio 10.1 Berlin Starter, WeBuilder
BeitragVerfasst: Do 16.11.06 19:54 
Es geht aber trotzdem ;)