<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[DLL mit VCL]]></title><description><![CDATA[<p>Hallo.</p>
<p>Unter Suchen fand ich viel, aber nix half mir. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>Ich habe eine DLL erstellt wo eine TForm mit einem Edit und 2 Buttons.<br />
Wenn ich diese statisch in meine EXE einbinde (mittels .lib) geht es, aber ich möchte es ja dynamisch haben, um die DLLs austauschen zu können.</p>
<p>DLL Formular Code</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;Unit2.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TDLLForm *DLLForm;
//extern AnsiString stext;

__declspec(dllexport) void FormShow(TComponent* Owner)
{
TDLLForm* DLLForm = new TDLLForm(Owner);
DLLForm-&gt;ShowModal();
}

//---------------------------------------------------------------------------
__fastcall TDLLForm::TDLLForm(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TDLLForm::Button1Click(TObject *Sender)
{
	Edit1-&gt;Text=&quot;huhu&quot;;
}
//---------------------------------------------------------------------------
void __fastcall TDLLForm::Button2Click(TObject *Sender)
{
//	Edit1-&gt;Text=stext;
}
//---------------------------------------------------------------------------
</code></pre>
<p>In EXE Formular</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;
AnsiString stext;

__declspec(dllimport) void FormShow(TComponent* Owner);

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
     stext = &quot;Dieser Text soll im TEdit der DLL zu sehen sein&quot;;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
	if (!DllInstance) DllInstance = LoadLibrary(&quot;Project1.dll&quot;); // DLL laden
	if (DllInstance) Form1-&gt;Caption = &quot;DLL wurde geladen.&quot;;

	FormShow(Application);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &amp;Action)
{
	if (DllInstance)
	{
	   if (FreeLibrary(DllInstance)) DllInstance = NULL; // DLL entladen
	}

	if (!DllInstance)
	{
		ShowMessage(&quot;DLL nicht entladen&quot;);
	}
}
//---------------------------------------------------------------------------
</code></pre>
<p>Er meldet mir : [Linker Fehler] Unresolved external 'FormShow(Classes::TComponent *)' referenced from \UNIT1.OBJ<br />
Wie bekomme ich nun die DLLForm &quot;richtig&quot; dynamisch geladen. Den momentan mach ichs wohl total falsch <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
<p>Zusätzlich:<br />
Die Variable &quot;AnsiString stext&quot; (momentan auskommentiert weil ich nicht weiss wie) möchte ich in der DLLForm nutzen.<br />
Per druck auf DLLForm-&gt;Button2 soll im DLLForm-&gt;Edit1 der Text erscheinen den ich zuvor in meiner EXE Anwendung definiert habe.</p>
<p>Wie exportiere/importiere ich Variablen zwischen der DLLForm und meiner EXE Form?</p>
<p>Als wäre für jede nützliche Hilfe mehr als Dankbar, da ich jetzt schon paar stunden an dem Problem hänge <sub>.</sub></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/90631/dll-mit-vcl</link><generator>RSS for Node</generator><lastBuildDate>Mon, 06 Jul 2026 23:54:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/90631.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 31 Oct 2004 14:31:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DLL mit VCL on Sun, 31 Oct 2004 14:31:10 GMT]]></title><description><![CDATA[<p>Hallo.</p>
<p>Unter Suchen fand ich viel, aber nix half mir. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>Ich habe eine DLL erstellt wo eine TForm mit einem Edit und 2 Buttons.<br />
Wenn ich diese statisch in meine EXE einbinde (mittels .lib) geht es, aber ich möchte es ja dynamisch haben, um die DLLs austauschen zu können.</p>
<p>DLL Formular Code</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;Unit2.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TDLLForm *DLLForm;
//extern AnsiString stext;

__declspec(dllexport) void FormShow(TComponent* Owner)
{
TDLLForm* DLLForm = new TDLLForm(Owner);
DLLForm-&gt;ShowModal();
}

//---------------------------------------------------------------------------
__fastcall TDLLForm::TDLLForm(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TDLLForm::Button1Click(TObject *Sender)
{
	Edit1-&gt;Text=&quot;huhu&quot;;
}
//---------------------------------------------------------------------------
void __fastcall TDLLForm::Button2Click(TObject *Sender)
{
//	Edit1-&gt;Text=stext;
}
//---------------------------------------------------------------------------
</code></pre>
<p>In EXE Formular</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;
AnsiString stext;

__declspec(dllimport) void FormShow(TComponent* Owner);

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
     stext = &quot;Dieser Text soll im TEdit der DLL zu sehen sein&quot;;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
	if (!DllInstance) DllInstance = LoadLibrary(&quot;Project1.dll&quot;); // DLL laden
	if (DllInstance) Form1-&gt;Caption = &quot;DLL wurde geladen.&quot;;

	FormShow(Application);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &amp;Action)
{
	if (DllInstance)
	{
	   if (FreeLibrary(DllInstance)) DllInstance = NULL; // DLL entladen
	}

	if (!DllInstance)
	{
		ShowMessage(&quot;DLL nicht entladen&quot;);
	}
}
//---------------------------------------------------------------------------
</code></pre>
<p>Er meldet mir : [Linker Fehler] Unresolved external 'FormShow(Classes::TComponent *)' referenced from \UNIT1.OBJ<br />
Wie bekomme ich nun die DLLForm &quot;richtig&quot; dynamisch geladen. Den momentan mach ichs wohl total falsch <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
<p>Zusätzlich:<br />
Die Variable &quot;AnsiString stext&quot; (momentan auskommentiert weil ich nicht weiss wie) möchte ich in der DLLForm nutzen.<br />
Per druck auf DLLForm-&gt;Button2 soll im DLLForm-&gt;Edit1 der Text erscheinen den ich zuvor in meiner EXE Anwendung definiert habe.</p>
<p>Wie exportiere/importiere ich Variablen zwischen der DLLForm und meiner EXE Form?</p>
<p>Als wäre für jede nützliche Hilfe mehr als Dankbar, da ich jetzt schon paar stunden an dem Problem hänge <sub>.</sub></p>
]]></description><link>https://www.c-plusplus.net/forum/post/641661</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/641661</guid><dc:creator><![CDATA[diemaske]]></dc:creator><pubDate>Sun, 31 Oct 2004 14:31:10 GMT</pubDate></item><item><title><![CDATA[Reply to DLL mit VCL on Sun, 31 Oct 2004 17:47:17 GMT]]></title><description><![CDATA[<p>Mach mal nen Prototyp von</p>
<p>__declspec(dllexport) void FormShow(TComponent* Owner)</p>
<p>PS: am besten in einer .h Datei</p>
]]></description><link>https://www.c-plusplus.net/forum/post/641780</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/641780</guid><dc:creator><![CDATA[DerAltenburger]]></dc:creator><pubDate>Sun, 31 Oct 2004 17:47:17 GMT</pubDate></item></channel></rss>