<?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[Dialog mehrfach instanziieren]]></title><description><![CDATA[<p>Ich programmiere mit der WinAPI und möchte einen Dialog mehrfach gleichzeitig öffnen. Das Problem dahinter ist nun aber dass jede Dialog-Instanz unabhängig von den anderen Dialog-Instanzen sein muss da jede Instanz potentiell ihre eigene Ressourcen (Variablen) benutzt.<br />
Ich benutze den Dialog um Daten durch den Benutzer einzugeben. Ich möchte aber nicht dass wenn der Benutzer zwei Dialoge öffnet und im ersten Dialog einen Wert eingibt, dieser im zweiten geöffneten Dialog sichtbar ist. Objektorientiert betrachtet benötige ich einfach Klasse MeinDialog, welche als Member die EventHandling (MessageProc) Funktion hat.</p>
<p>Also etwas in der Form:</p>
<pre><code>class MeinDialog
{
private:
  std::string Name;
  std::string Nachname;

public:

  int CALLBACK EventDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);

  void ShowDlg();
};

void MeinDialog::ShowDlg()
{
  // Geht nicht weil hier eine globale Funktion erwartet wird
  DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_MEINDIALOG), hParent, this-&gt;EventDialogProc);
}
</code></pre>
<p>Wie kann ich eine solche Dialog-Klasse mit der WinAPI implementieren ?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/244565/dialog-mehrfach-instanziieren</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Apr 2026 23:02:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/244565.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 02 Jul 2009 08:26:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dialog mehrfach instanziieren on Thu, 02 Jul 2009 08:26:55 GMT]]></title><description><![CDATA[<p>Ich programmiere mit der WinAPI und möchte einen Dialog mehrfach gleichzeitig öffnen. Das Problem dahinter ist nun aber dass jede Dialog-Instanz unabhängig von den anderen Dialog-Instanzen sein muss da jede Instanz potentiell ihre eigene Ressourcen (Variablen) benutzt.<br />
Ich benutze den Dialog um Daten durch den Benutzer einzugeben. Ich möchte aber nicht dass wenn der Benutzer zwei Dialoge öffnet und im ersten Dialog einen Wert eingibt, dieser im zweiten geöffneten Dialog sichtbar ist. Objektorientiert betrachtet benötige ich einfach Klasse MeinDialog, welche als Member die EventHandling (MessageProc) Funktion hat.</p>
<p>Also etwas in der Form:</p>
<pre><code>class MeinDialog
{
private:
  std::string Name;
  std::string Nachname;

public:

  int CALLBACK EventDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);

  void ShowDlg();
};

void MeinDialog::ShowDlg()
{
  // Geht nicht weil hier eine globale Funktion erwartet wird
  DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_MEINDIALOG), hParent, this-&gt;EventDialogProc);
}
</code></pre>
<p>Wie kann ich eine solche Dialog-Klasse mit der WinAPI implementieren ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1735850</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1735850</guid><dc:creator><![CDATA[Bitte ein Bit]]></dc:creator><pubDate>Thu, 02 Jul 2009 08:26:55 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog mehrfach instanziieren on Thu, 02 Jul 2009 08:30:06 GMT]]></title><description><![CDATA[<p>Die MessageProc muß eine statische Memberfunktion oder eine freie Funktion sein. Den this-Pointer des jeweiligen Objekts musst du der MessageProc übergeben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1735853</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1735853</guid><dc:creator><![CDATA[general bacardi]]></dc:creator><pubDate>Thu, 02 Jul 2009 08:30:06 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog mehrfach instanziieren on Thu, 02 Jul 2009 08:51:20 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/11445">@general</a> bacardi<br />
Wie kann ich denn den this Pointer der Funktion übergeben ? Erstens ist nämlich der Funktionkopf vorgegeben (Typ DialogProc) und zweitens rufe ich die Funktion nicht explizit auf sondern Windows.</p>
<p>Ich habe bisher folgendes gemacht:</p>
<pre><code>class MeinDialog
{
private:
  std::string Name;
  std::string Nachname;

public:
  MeinDialog();
  ~MeinDialog();
  int CALLBACK EventDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  void ShowDlg();
};

MeinDialog* instance;   // Pointer auf aktuelle Instanz

// Speichert die akutelle Instanz des Dialogs
MeinDialog::MeinDialog()
{
  instance = this;
}

// Löscht die akutelle Instanz des Dialogs
MeinDialog::~MeinDialog()
{
  instance = NULL;
}

// Delegiert den Aufruf an die aktuelle Instanz
int CALLBACK GlobalEventDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  if (instance != NULL)
    instance-&gt;EventDialogProc(hwndDlg, uMsg, wParam, lParam);
}

void MeinDialog::ShowDlg()
{
  // Geht nicht weil hier eine globale Funktion erwartet wird
  DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_MEINDIALOG), hParent, this-&gt;GlobalEventDialogProc);
}
</code></pre>
<p>Das Ganze funktioniert nicht gut wenn ich zwei Dialoge gleichzeitig öffnen wollte, denn dann müsste ich zwei freie Eventfunktionen definieren, was recht unschön ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1735866</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1735866</guid><dc:creator><![CDATA[Bitte ein Bit]]></dc:creator><pubDate>Thu, 02 Jul 2009 08:51:20 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog mehrfach instanziieren on Thu, 02 Jul 2009 08:55:43 GMT]]></title><description><![CDATA[<p>Bitte ein Bit schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/11445">@general</a> bacardi<br />
Wie kann ich denn den this Pointer der Funktion übergeben ? Erstens ist nämlich der Funktionkopf vorgegeben (Typ DialogProc) und zweitens rufe ich die Funktion nicht explizit auf sondern Windows.</p>
</blockquote>
<p>Du kannst mit SetWindowLong() beim erzeugen des Fensters den this-Pointer mitgeben. in der DlgProc mit GetWindowLong() dann wieder rausholen. Hab ich vor eininegr Zei mal gemacht und hat gefunzt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1735871</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1735871</guid><dc:creator><![CDATA[general bacardi]]></dc:creator><pubDate>Thu, 02 Jul 2009 08:55:43 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog mehrfach instanziieren on Thu, 02 Jul 2009 09:09:53 GMT]]></title><description><![CDATA[<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> Danke für die geile Idee !!! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
<p>Einfach den this Pointer in DWL_USER speichern und in der freien Eventfunktion wieder herausholen damit man dann auf die klassenspezifische Eventfunktion aufrufen kann !!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1735878</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1735878</guid><dc:creator><![CDATA[Bitte ein Bit]]></dc:creator><pubDate>Thu, 02 Jul 2009 09:09:53 GMT</pubDate></item><item><title><![CDATA[Reply to Dialog mehrfach instanziieren on Thu, 02 Jul 2009 09:17:02 GMT]]></title><description><![CDATA[<p>Bitte ein Bit schrieb:</p>
<blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /> Danke für die geile Idee !!! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
</blockquote>
<p>Die Idee ist so alt wie Windows <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1735879</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1735879</guid><dc:creator><![CDATA[general bacardi]]></dc:creator><pubDate>Thu, 02 Jul 2009 09:17:02 GMT</pubDate></item></channel></rss>