<?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[Koppeln eines Menü&#x27;s mit Dialogfenster]]></title><description><![CDATA[<p>Hallo.</p>
<p>Ich möchte gern ein Dialogfenster mit Menü erstellen. Der folgende Code stellt nur das normale Fenster dar. Wie muss ich den verändern, damit das in der Ressource-Datei resource.h gespeicherte Menü &quot;IDR_MENU1&quot; auch dargestellt wird?</p>
<p>Danke!<br />
FRANK REICH</p>
<p>#include &lt;windows.h&gt;<br />
#include &quot;resource.h&quot;</p>
<p>HBRUSH g_hbrBackground = NULL;</p>
<p>BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch(Message)<br />
{<br />
case WM_INITDIALOG:<br />
g_hbrBackground = CreateSolidBrush(RGB(180, 180, 180));</p>
<p>SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(NULL,<br />
MAKEINTRESOURCE(IDI_APPLICATION)));<br />
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(NULL,<br />
MAKEINTRESOURCE(IDI_APPLICATION)));<br />
break;</p>
<p>case WM_CLOSE:<br />
EndDialog(hwnd, 0);<br />
break;</p>
<p>case WM_CTLCOLORDLG:<br />
return (LONG)g_hbrBackground;</p>
<p>case WM_CTLCOLORSTATIC:<br />
{<br />
HDC hdcStatic = (HDC)wParam;<br />
SetTextColor(hdcStatic, RGB(255, 255, 255));<br />
SetBkMode(hdcStatic, TRANSPARENT);<br />
return (LONG)g_hbrBackground;<br />
}<br />
break;<br />
case WM_COMMAND:<br />
switch(LOWORD(wParam))<br />
{<br />
case IDOK:<br />
EndDialog(hwnd, 0);<br />
break;</p>
<p>case IDCANCEL:<br />
EndDialog(hwnd, 0);<br />
break;<br />
}<br />
break;<br />
case WM_DESTROY:<br />
DeleteObject(g_hbrBackground);<br />
break;<br />
default:<br />
return FALSE;<br />
}<br />
return TRUE;<br />
}</p>
<p>int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,<br />
LPSTR lpCmdLine, int nCmdShow)<br />
{<br />
return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc);<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/127325/koppeln-eines-menü-s-mit-dialogfenster</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Jul 2026 16:09:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/127325.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 23 Nov 2005 11:30:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Koppeln eines Menü&#x27;s mit Dialogfenster on Wed, 23 Nov 2005 11:30:26 GMT]]></title><description><![CDATA[<p>Hallo.</p>
<p>Ich möchte gern ein Dialogfenster mit Menü erstellen. Der folgende Code stellt nur das normale Fenster dar. Wie muss ich den verändern, damit das in der Ressource-Datei resource.h gespeicherte Menü &quot;IDR_MENU1&quot; auch dargestellt wird?</p>
<p>Danke!<br />
FRANK REICH</p>
<p>#include &lt;windows.h&gt;<br />
#include &quot;resource.h&quot;</p>
<p>HBRUSH g_hbrBackground = NULL;</p>
<p>BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch(Message)<br />
{<br />
case WM_INITDIALOG:<br />
g_hbrBackground = CreateSolidBrush(RGB(180, 180, 180));</p>
<p>SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(NULL,<br />
MAKEINTRESOURCE(IDI_APPLICATION)));<br />
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(NULL,<br />
MAKEINTRESOURCE(IDI_APPLICATION)));<br />
break;</p>
<p>case WM_CLOSE:<br />
EndDialog(hwnd, 0);<br />
break;</p>
<p>case WM_CTLCOLORDLG:<br />
return (LONG)g_hbrBackground;</p>
<p>case WM_CTLCOLORSTATIC:<br />
{<br />
HDC hdcStatic = (HDC)wParam;<br />
SetTextColor(hdcStatic, RGB(255, 255, 255));<br />
SetBkMode(hdcStatic, TRANSPARENT);<br />
return (LONG)g_hbrBackground;<br />
}<br />
break;<br />
case WM_COMMAND:<br />
switch(LOWORD(wParam))<br />
{<br />
case IDOK:<br />
EndDialog(hwnd, 0);<br />
break;</p>
<p>case IDCANCEL:<br />
EndDialog(hwnd, 0);<br />
break;<br />
}<br />
break;<br />
case WM_DESTROY:<br />
DeleteObject(g_hbrBackground);<br />
break;<br />
default:<br />
return FALSE;<br />
}<br />
return TRUE;<br />
}</p>
<p>int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,<br />
LPSTR lpCmdLine, int nCmdShow)<br />
{<br />
return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc);<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/925112</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/925112</guid><dc:creator><![CDATA[frank reich]]></dc:creator><pubDate>Wed, 23 Nov 2005 11:30:26 GMT</pubDate></item><item><title><![CDATA[Reply to Koppeln eines Menü&#x27;s mit Dialogfenster on Wed, 23 Nov 2005 12:00:47 GMT]]></title><description><![CDATA[<p>Du wählst das Menü im Resourceeditor.<br />
Dazu brauchst Du keine Zeile Code schreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/925137</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/925137</guid><dc:creator><![CDATA[nemeses]]></dc:creator><pubDate>Wed, 23 Nov 2005 12:00:47 GMT</pubDate></item><item><title><![CDATA[Reply to Koppeln eines Menü&#x27;s mit Dialogfenster on Wed, 23 Nov 2005 12:07:07 GMT]]></title><description><![CDATA[<p>Aber wenn man nichts im Code ändert, woher weis dann dass Dialogfenster, dass es ein Menü besitzt?</p>
<p>Frank Reich</p>
]]></description><link>https://www.c-plusplus.net/forum/post/925148</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/925148</guid><dc:creator><![CDATA[frank reich]]></dc:creator><pubDate>Wed, 23 Nov 2005 12:07:07 GMT</pubDate></item><item><title><![CDATA[Reply to Koppeln eines Menü&#x27;s mit Dialogfenster on Wed, 23 Nov 2005 12:27:36 GMT]]></title><description><![CDATA[<p>Wenn Du was an den Resourcen änderst, dann wird es vermutlich in den Resourcen stehen und somit weis der wo die Resourcen lädt was er nehmen soll, oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/925176</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/925176</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Wed, 23 Nov 2005 12:27:36 GMT</pubDate></item><item><title><![CDATA[Reply to Koppeln eines Menü&#x27;s mit Dialogfenster on Wed, 23 Nov 2005 12:38:40 GMT]]></title><description><![CDATA[<p>Wenn ich mir das Resource Template anschaue, sehe ich da eine Definition für das Menü und eine für das Dialogfenster. Ich kann aber nirgendswo den Link sehen, dass das Menü zum Dialogfenster gehören soll. Die &quot;resource.h&quot; hilft mir da auch nicht viel weiter. Gibts nur ne ID für das Menü und eine für das Dialogfenster.</p>
<p><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong><strong>&quot;RESOURCE.H&quot;</strong></strong></strong></strong></strong></strong></strong></strong></strong></strong></strong><br />
//{{NO_DEPENDENCIES}}<br />
// Microsoft Developer Studio generated include file.<br />
// Used by dlg_three.rc<br />
//<br />
#define IDD_MAIN 101<br />
#define IDR_MENU1 102<br />
#define ID_EXIT 40001<br />
#define ID_OTHERS 40002</p>
<p>// Next default values for new objects<br />
//<br />
#ifdef APSTUDIO_INVOKED<br />
#ifndef APSTUDIO_READONLY_SYMBOLS<br />
#define _APS_NEXT_RESOURCE_VALUE 103<br />
#define _APS_NEXT_COMMAND_VALUE 40003<br />
#define _APS_NEXT_CONTROL_VALUE 1000<br />
#define _APS_NEXT_SYMED_VALUE 101<br />
#endif<br />
#endif</p>
<p>**********************RESOURCEN TEMPLATE**********************<br />
//Microsoft Developer Studio generated resource script.<br />
//<br />
#include &quot;resource.h&quot;</p>
<p>#define APSTUDIO_READONLY_SYMBOLS<br />
/////////////////////////////////////////////////////////////////////////////<br />
//<br />
// Generated from the TEXTINCLUDE 2 resource.<br />
//<br />
#ifndef __BORLANDC__<br />
#include &quot;winres.h&quot;<br />
#endif</p>
<p>/////////////////////////////////////////////////////////////////////////////<br />
#undef APSTUDIO_READONLY_SYMBOLS</p>
<p>/////////////////////////////////////////////////////////////////////////////<br />
// English (U.K.) resources</p>
<p>#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)<br />
#ifdef _WIN32<br />
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK<br />
#pragma code_page(1252)<br />
#endif //_WIN32</p>
<p>/////////////////////////////////////////////////////////////////////////////<br />
//<br />
// Menu<br />
//</p>
<p>IDR_MENU1 MENU DISCARDABLE<br />
BEGIN<br />
POPUP &quot;File&quot;<br />
BEGIN<br />
MENUITEM &quot;Exit&quot;, ID_EXIT<br />
END<br />
POPUP &quot;Others&quot;<br />
BEGIN<br />
MENUITEM &quot;???&quot;, ID_OTHERS<br />
END<br />
END</p>
<p>#endif // English (U.K.) resources<br />
/////////////////////////////////////////////////////////////////////////////</p>
<p>/////////////////////////////////////////////////////////////////////////////<br />
// English (Canada) resources</p>
<p>#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENC)<br />
#ifdef _WIN32<br />
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_CAN<br />
#pragma code_page(1252)<br />
#endif //_WIN32</p>
<p>#ifdef APSTUDIO_INVOKED<br />
/////////////////////////////////////////////////////////////////////////////<br />
//<br />
// TEXTINCLUDE<br />
//</p>
<p>1 TEXTINCLUDE DISCARDABLE<br />
BEGIN<br />
&quot;resource.h\0&quot;<br />
END</p>
<p>2 TEXTINCLUDE DISCARDABLE<br />
BEGIN<br />
&quot;#ifndef __BORLANDC__\r\n&quot;<br />
&quot;#include &quot;&quot;winres.h&quot;&quot;\r\n&quot;<br />
&quot;#endif\r\n&quot;<br />
&quot;\0&quot;<br />
END</p>
<p>3 TEXTINCLUDE DISCARDABLE<br />
BEGIN<br />
&quot;\r\n&quot;<br />
&quot;\0&quot;<br />
END</p>
<p>#endif // APSTUDIO_INVOKED</p>
<p>/////////////////////////////////////////////////////////////////////////////<br />
//<br />
// Dialog<br />
//</p>
<p>IDD_MAIN DIALOG DISCARDABLE 0, 0, 186, 46<br />
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU<br />
CAPTION &quot;Dialog tricks&quot;<br />
FONT 8, &quot;MS Sans Serif&quot;<br />
BEGIN<br />
DEFPUSHBUTTON &quot;OK&quot;,IDOK,129,25,50,14<br />
END</p>
<p>/////////////////////////////////////////////////////////////////////////////<br />
//<br />
// DESIGNINFO<br />
//</p>
<p>#ifdef APSTUDIO_INVOKED<br />
GUIDELINES DESIGNINFO DISCARDABLE<br />
BEGIN<br />
IDD_MAIN, DIALOG<br />
BEGIN<br />
LEFTMARGIN, 7<br />
RIGHTMARGIN, 179<br />
TOPMARGIN, 7<br />
BOTTOMMARGIN, 39<br />
END<br />
END<br />
#endif // APSTUDIO_INVOKED</p>
<p>#endif // English (Canada) resources<br />
/////////////////////////////////////////////////////////////////////////////</p>
<p>#ifndef APSTUDIO_INVOKED<br />
/////////////////////////////////////////////////////////////////////////////<br />
//<br />
// Generated from the TEXTINCLUDE 3 resource.<br />
//</p>
<p>/////////////////////////////////////////////////////////////////////////////<br />
#endif // not APSTUDIO_INVOKED</p>
]]></description><link>https://www.c-plusplus.net/forum/post/925189</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/925189</guid><dc:creator><![CDATA[frank reich]]></dc:creator><pubDate>Wed, 23 Nov 2005 12:38:40 GMT</pubDate></item></channel></rss>