<?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[Handle von einem DoModal-Fenster im Hauptdialog?]]></title><description><![CDATA[<p>Hi</p>
<p>Ich verwende ein TrayIcon in meiner Anwendung, und möchte nun das bei einem Linksklick auf das Icon, das aktuelle Fenster &quot;minimiert&quot; wird (ShowWindow(SW_HIDE)). Die Verarbeitung des Linksklicks passiert aber in der Hauptdialog-Klasse in OnTrayNotification().</p>
<p>Das Problem ist, dass ich mehrere Fenster per DoModal() erstellt haben könnte.<br />
Wie bekomme ich nun ein Handle auf das Fenster, dass ich per DoModal() in einer Funktion der Hauptdialog-Klasse erstellt habe, damit ich es in OnTrayNotification mit ShowWindow minimieren kann?</p>
<p>So sieht das aus:</p>
<pre><code class="language-cpp">CHauptDlg::Funk1()
{
	...
	CKind KindDlg;
	if (KindDlg.DoModal() == IDOK)	// Fenster da
	...
}
...
...
CHauptDlg::OnTrayNotification(WPARAM wParam, LPARAM lParam)
{
	if (lParam == WM_LBUTTONDOWN )
	{
		ShowWindow( KindDlghwnd ,SW_HIDE);	// hier brauch ich das Handle vom KindDlg
	}
	...
}
</code></pre>
<p>Wenn jemand weiß, wie man das anders/einfacher lösen kann, immer her damit.</p>
<p>mfg<br />
Andreas</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/48358/handle-von-einem-domodal-fenster-im-hauptdialog</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 17:38:29 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/48358.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 08 Sep 2003 12:29:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Handle von einem DoModal-Fenster im Hauptdialog? on Mon, 08 Sep 2003 12:29:10 GMT]]></title><description><![CDATA[<p>Hi</p>
<p>Ich verwende ein TrayIcon in meiner Anwendung, und möchte nun das bei einem Linksklick auf das Icon, das aktuelle Fenster &quot;minimiert&quot; wird (ShowWindow(SW_HIDE)). Die Verarbeitung des Linksklicks passiert aber in der Hauptdialog-Klasse in OnTrayNotification().</p>
<p>Das Problem ist, dass ich mehrere Fenster per DoModal() erstellt haben könnte.<br />
Wie bekomme ich nun ein Handle auf das Fenster, dass ich per DoModal() in einer Funktion der Hauptdialog-Klasse erstellt habe, damit ich es in OnTrayNotification mit ShowWindow minimieren kann?</p>
<p>So sieht das aus:</p>
<pre><code class="language-cpp">CHauptDlg::Funk1()
{
	...
	CKind KindDlg;
	if (KindDlg.DoModal() == IDOK)	// Fenster da
	...
}
...
...
CHauptDlg::OnTrayNotification(WPARAM wParam, LPARAM lParam)
{
	if (lParam == WM_LBUTTONDOWN )
	{
		ShowWindow( KindDlghwnd ,SW_HIDE);	// hier brauch ich das Handle vom KindDlg
	}
	...
}
</code></pre>
<p>Wenn jemand weiß, wie man das anders/einfacher lösen kann, immer her damit.</p>
<p>mfg<br />
Andreas</p>
]]></description><link>https://www.c-plusplus.net/forum/post/349528</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/349528</guid><dc:creator><![CDATA[Mr. IfThen]]></dc:creator><pubDate>Mon, 08 Sep 2003 12:29:10 GMT</pubDate></item><item><title><![CDATA[Reply to Handle von einem DoModal-Fenster im Hauptdialog? on Mon, 08 Sep 2003 13:10:21 GMT]]></title><description><![CDATA[<p>Du kannst den Dialoghandle (child) in einem Datenelement des Hauptdialoges speichern.</p>
<pre><code class="language-cpp">CHauptDlg::CHauptDlg():
    KindDlghwnd = NULL;
{
}

CHauptDlg::Funk1() 
{ 
    ... 
    CKind KindDlg;
    KindDlghwnd = KindDlg.GetSafeHwnd();
    if (KindDlg.DoModal() == IDOK)    // Fenster da 
    ... 
    KindDlghwnd = NULL;
} 
... 
... 
CHauptDlg::OnTrayNotification(WPARAM wParam, LPARAM lParam) 
{ 
    if (lParam == WM_LBUTTONDOWN ) 
    { 
        ShowWindow( KindDlghwnd ,SW_HIDE);    // hier brauch ich das Handle vom KindDlg 
    } 
    ... 
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/349579</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/349579</guid><dc:creator><![CDATA[proga]]></dc:creator><pubDate>Mon, 08 Sep 2003 13:10:21 GMT</pubDate></item><item><title><![CDATA[Reply to Handle von einem DoModal-Fenster im Hauptdialog? on Mon, 08 Sep 2003 13:12:36 GMT]]></title><description><![CDATA[<p>Sorry, muss natürlich so aussehen...</p>
<pre><code class="language-cpp">CHauptDlg::CHauptDlg(): 
    KindDlghwnd(NULL) 
{ 
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/349583</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/349583</guid><dc:creator><![CDATA[proga]]></dc:creator><pubDate>Mon, 08 Sep 2003 13:12:36 GMT</pubDate></item><item><title><![CDATA[Reply to Handle von einem DoModal-Fenster im Hauptdialog? on Mon, 08 Sep 2003 13:22:50 GMT]]></title><description><![CDATA[<p>Das geht ja eben nicht, weil:</p>
<pre><code class="language-cpp">CHauptDlg::Funk1()  
{  
    ...  
    CKind KindDlg; 
    KindDlghwnd = KindDlg.GetSafeHwnd();  // Fenster noch nicht da !!
    if (KindDlg.DoModal() == IDOK)        // Fenster da  
    ...  
    KindDlghwnd = NULL; 
}
</code></pre>
<p>Ergebnis:</p>
<p>KindDlghwnd = 0x00000000</p>
<p>Das Fenster wird in DoModal() ja erst erstellt. <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/349600</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/349600</guid><dc:creator><![CDATA[Mr. IfThen]]></dc:creator><pubDate>Mon, 08 Sep 2003 13:22:50 GMT</pubDate></item><item><title><![CDATA[Reply to Handle von einem DoModal-Fenster im Hauptdialog? on Mon, 08 Sep 2003 14:08:26 GMT]]></title><description><![CDATA[<p>Stimmt, hast recht :p<br />
Dann definier doch eine Message, die du in der Create-Methode<br />
an das Eltern-Fenster sendest und den Handle übergibst, etwa so....</p>
<pre><code class="language-cpp">int CModalDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CDialog::OnCreate(lpCreateStruct) == -1)
		return -1;

	HWND hParent = GetParent()-&gt;m_hWnd;
	::SendMessage(hParent, MESSAGE_HANDLE, (WPARAM) m_hWnd, 0);

	return 0;
}
</code></pre>
<p>hab's leider nicht getestet <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>
]]></description><link>https://www.c-plusplus.net/forum/post/349653</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/349653</guid><dc:creator><![CDATA[proga]]></dc:creator><pubDate>Mon, 08 Sep 2003 14:08:26 GMT</pubDate></item><item><title><![CDATA[Reply to Handle von einem DoModal-Fenster im Hauptdialog? on Mon, 08 Sep 2003 15:35:50 GMT]]></title><description><![CDATA[<p>Hi</p>
<p>Ob es in OnCreate funktioniert, weiß ich nicht, da ich ja DoModal benutze. Also hab ich es da probiert. Geht auch nicht. Aber in OnInitDialog funktioniert es einwandfrei.</p>
<p>Danke für die Hilfe. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/349722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/349722</guid><dc:creator><![CDATA[Mr. IfThen]]></dc:creator><pubDate>Mon, 08 Sep 2003 15:35:50 GMT</pubDate></item><item><title><![CDATA[Reply to Handle von einem DoModal-Fenster im Hauptdialog? on Mon, 08 Sep 2003 20:46:09 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">BOOL ChildDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	static_cast&lt;MyParentDlg*&gt; (GetParent())-&gt;SetMyChild(this);
	// oder
	static_cast&lt;MyParentDlg*&gt; (GetParent())-&gt;myChild = this;
}
</code></pre>
<p>Kannst auch mit FindWindowEx (hwndParent = m_hWnd) nach einem Child mit dem Klassennamen &quot;#32770&quot; suchen. Natürlich nur sinnvoll wenn du nur einen untergeordneten Dialog hast.</p>
<p>Aber wieso willst du nur das Child minimieren? Dann hast du ein sichtbares Fenster das man nicht anklicken kann - ist doch nicht der Sinn - oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/349886</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/349886</guid><dc:creator><![CDATA[Oliver]]></dc:creator><pubDate>Mon, 08 Sep 2003 20:46:09 GMT</pubDate></item><item><title><![CDATA[Reply to Handle von einem DoModal-Fenster im Hauptdialog? on Mon, 08 Sep 2003 23:41:45 GMT]]></title><description><![CDATA[<p>Nemesyzz schrieb:</p>
<blockquote>
<p>Aber wieso willst du nur das Child minimieren? Dann hast du ein sichtbares Fenster das man nicht anklicken kann - ist doch nicht der Sinn - oder?</p>
</blockquote>
<p>Doch, denn das Fenster des Hauptdialogs verstecke ich kurz vor DoModal() mit ShowWindow(SW_HIDE). Ich habe also nur noch das modale Fenster und das Trayicon und kann jetzt mit Linksklick auf das Icon das Fenster ein- und ausblenden.</p>
<p>Das sieht jetzt so aus:</p>
<pre><code class="language-cpp">LRESULT CHauptDlg::OnTrayNotification(WPARAM wParam, LPARAM lParam)
{
	if (WM_LBUTTONDOWN == lParam)
	{
        if (m_hwnd_Mini != NULL)	// HWND aus DoModal-Fenster per SendMessage
		{
			::IsWindowVisible(m_hwnd_Mini)?  ::ShowWindow(m_hwnd_Mini, SW_HIDE):
						       	      	::ShowWindow(m_hwnd_Mini, SW_SHOWNORMAL);
		}

		return 0L;
	}	

	// Verarbeitung in CTrayNotifyIcon
	m_TrayIcon.OnTrayNotification(wParam, lParam);

	return 0L;
}
</code></pre>
<p>Das Fenster, dass ich per DoModal aufrufe, hat keine Titelleiste, kein Systemmenü und keinen Titel(CAPTION), also auch keine Minimieren-Schaltfläche.</p>
<p>Bei Doppelklick auf das Trayicon oder bei Auswahl aus dem TrayMenü wird das &quot;DoModal&quot;-Fenster beendet, und das Fenster des Hauptdialogs wiederbelebt (ShowWindow(SW_SHOW)).</p>
<p>Hört sich ein bisschen krank an. Man muss es gesehen haben. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/349911</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/349911</guid><dc:creator><![CDATA[Mr. IfThen]]></dc:creator><pubDate>Mon, 08 Sep 2003 23:41:45 GMT</pubDate></item></channel></rss>