Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Problem mit DLL (https://www.delphipraxis.net/60477-problem-mit-dll.html)

Amo 7. Jan 2006 13:00


Problem mit DLL
 
Ich habe hier ein Problem:
Und zwar geht es darum, dass ich mithilfe einer DLL einige Captions ändern möchte, doch dies geht irgendwie nicht. Hier der code meiner dll:

Delphi-Quellcode:
library Project2;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  SysUtils, Unit1, Messages, Dialogs,
  Classes;

{$R *.res}

procedure setgerman; stdcall;
begin
try
 Form1.GroupBox1.Caption := 'Sprache';
 Form1.Button5.caption := 'Ton wählen';
 Form1.Button6.caption := 'Zeit wählen';
 Form1.Button1.caption := 'Wecker stellen';
 Form1.BitBtn1.caption := '&Schließen';
 Form1.BitBtn2.caption := '&Info';
 Form1.Panel2.caption := 'nicht bereit';
except showmessage('shit');
end;
end;

procedure setfrench; stdcall;
begin
 Form1.GroupBox1.caption := 'Langues';
 Form1.Button5.caption := 'choisir sonnerie';
 Form1.Button6.caption := 'choisir l´heure';
 Form1.Button1.caption := 'démarrer le réveil';
 Form1.BitBtn1.caption := '&Quitter';
 Form1.BitBtn2.caption := '&Info';
 Form1.Panel2.caption := 'pas réglé';
end;

procedure setenglish; stdcall;
begin
 Form1.GroupBox1.caption := 'Language';
 Form1.Button5.caption := 'set sound';
 Form1.Button6.caption := 'set time';
 Form1.Button1.caption := 'set alarm';
 Form1.BitBtn1.caption := '&Close';
 Form1.BitBtn2.caption := '&About';
 Form1.Panel2.caption := 'not ready';
end;

exports setgerman, setfrench, setenglish;

begin
end.
Im Hauptprogramm ist das ein radiobuttom, der angeklickt wird (dadurch soll sich die sprache ändern).

Was habe ich falsch gemacht?

JasonDX 7. Jan 2006 13:07

Re: Problem mit DLL
 
Ich glaub es fehlt n bissl an der Logik - oder dem Konzept :stupid:
  • Woher soll der Compiler wissen, was Form1 ist?
  • Woher soll der Compiler wissen, was GroupBox1 ist?
  • Woher soll der Compiler wissen, was Button1 ist?
  • ......
Stimmt - kanner garnich wissen :mrgreen:

zu deutsch: Du musst die unit mit TForm1 (ws. 'Unit1') auch in die DLL einbinden, und den Funktionen als Parameter 'Form1: TForm1' mitgeben, dann könnts klappen ;)


greetz
Mike

Robert Marquardt 7. Jan 2006 13:18

Re: Problem mit DLL
 
Man sollte auch unbedingt den Kommentar lesen und ShareMem einbinden.

marabu 7. Jan 2006 13:19

Re: Problem mit DLL
 
Was wird wohl in Unit1 stecken - Form1?

Ich würde trotzdem den aktiven part bei der jeweiligen Form (OnCreate) lassen und eine reine ressource dll verwenden.

Grüße vom marabu

Luckie 7. Jan 2006 13:20

Re: Problem mit DLL
 
Und wenn die VCL in DLLs Verwendung findet, würde ich bpls, Borland spezifische DLLs, nutzen anstatt herkömmlichen DLLs.

Amo 7. Jan 2006 13:28

Re: Problem mit DLL
 
OK, ich hatte mir schon gedacht es ist sowas wie Chimaira erklärt hat. Aber wie mache ich das jetzt genau mit TForm1? Unit1.Form1. ... oder wie?


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:53 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz