<?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[Menüpunkte innerhalb eines Dropdown-Menüs funktionieren nicht]]></title><description><![CDATA[<p>Hallo,</p>
<p>bin neu auf dem Gebiet der Windows-Programmierung und habe ein Verständnisproblem. Unter <a href="http://www.winprog.org/tutorial/menus.html" rel="nofollow">http://www.winprog.org/tutorial/menus.html</a> werden folgende Symbole durch eine Präprozessordirektive erzeugt:</p>
<pre><code class="language-cpp">#define IDR_MYMENU 101
#define IDI_MYICON 201

#define ID_FILE_EXIT 9001
#define ID_STUFF_GO 9002
</code></pre>
<p>Nach meinem Verständnis sind dies einfach nur Symbole, die durch die entsprechenden Zahlen ausgedrückt werden. ID_FILE_EXIT entspricht einer &quot;Nachricht&quot;(?) die mit einem entsprechenden</p>
<pre><code class="language-cpp">case ID_FILE_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0);					
break;
</code></pre>
<p>zu einer Schließung des Fensters führt. Wieso klappt dies nicht, wenn ich aus 9001 bspw. 12 mache?</p>
<p>Unter</p>
<pre><code class="language-cpp">#include &quot;resource.h&quot;

IDR_MYMENU MENU
BEGIN
    POPUP &quot;&amp;File&quot;
    BEGIN
        MENUITEM &quot;E&amp;xit&quot;, ID_FILE_EXIT
    END

    POPUP &quot;&amp;Stuff&quot;
    BEGIN
        MENUITEM &quot;&amp;Go&quot;, ID_STUFF_GO
        MENUITEM &quot;G&amp;o somewhere else&quot;, 0, GRAYED
    END
END

IDI_MYICON ICON &quot;menu_one.ico&quot;
</code></pre>
<p>erstellt der Autor eine Ressourcen-Datei, welche wohl die Struktur des Menüs wiederspiegeln soll.</p>
<p>1. Frage: Was sollen die Fragezeichen innerhalb der Zeichenketten?<br />
2. Frage: Jedes Item bekommt eine bestimmte MenuID zugeteilt. Der Name dieser MenuID ist doch mir überlassen, oder?</p>
<p>Der Vollständigkeit halber hier mein Windows-Programm dazu:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &quot;resource.h&quot;
#include &lt;tchar.h&gt;

LRESULT CALLBACK WndProc (HWND , UINT , WPARAM , LPARAM);
HINSTANCE hActInstance;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    LPSTR lpszCmdParam, int nCmdShow)
{
   MSG msg;
   HWND hwnd;
   WNDCLASS wndclass ;

   hActInstance = hInstance ;

   if (!hPrevInstance) {

      wndclass.style         = CS_HREDRAW | CS_VREDRAW;
      wndclass.lpfnWndProc   = WndProc;
      wndclass.cbClsExtra    = 0;
      wndclass.cbWndExtra    = 0;
      wndclass.hInstance     = hInstance;
      wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION);
      wndclass.hCursor       = LoadCursor (NULL , IDC_ARROW);
      wndclass.hbrBackground = GetStockObject (LTGRAY_BRUSH);
      wndclass.lpszMenuName  = MAKEINTRESOURCE(IDR_MYMENU);
      wndclass.lpszClassName = _T(&quot;WndClassName&quot;);

      RegisterClass (&amp;wndclass);
   }

   hwnd = CreateWindow (_T(&quot;WndClassName&quot;), _T(&quot;LED&quot;),
                        WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
                        CW_USEDEFAULT, 320, 240,
                        NULL,  NULL, hInstance,  NULL);

   ShowWindow(hwnd, nCmdShow);
   UpdateWindow(hwnd);

   while (GetMessage (&amp;msg, NULL, 0, 0)) {

      TranslateMessage(&amp;msg) ;
      DispatchMessage(&amp;msg) ;
   }

   return msg.wParam ;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   switch (message) {

      case WM_DESTROY:     PostQuitMessage(0);
                           break;
		case WM_COMMAND:		switch(LOWORD(wParam))
									{

										case ID_FILE_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0);
										break;

										case ID_STUFF_GO: MessageBox(hwnd, _T(&quot;bla&quot;), _T(&quot;test&quot;), MB_OK);
										break;
									}
									break;

      case WM_LBUTTONDOWN: MessageBox(NULL, _T(&quot;Bitte einen Menuepunkt wählen&quot;), _T(&quot;&quot;), MB_OK);
                           break;
      return 0;
   }

   return DefWindowProc (hwnd, message, wParam, lParam) ;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/226384/menüpunkte-innerhalb-eines-dropdown-menüs-funktionieren-nicht</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 10:46:15 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/226384.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 31 Oct 2008 17:05:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Menüpunkte innerhalb eines Dropdown-Menüs funktionieren nicht on Fri, 31 Oct 2008 17:05:59 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>bin neu auf dem Gebiet der Windows-Programmierung und habe ein Verständnisproblem. Unter <a href="http://www.winprog.org/tutorial/menus.html" rel="nofollow">http://www.winprog.org/tutorial/menus.html</a> werden folgende Symbole durch eine Präprozessordirektive erzeugt:</p>
<pre><code class="language-cpp">#define IDR_MYMENU 101
#define IDI_MYICON 201

#define ID_FILE_EXIT 9001
#define ID_STUFF_GO 9002
</code></pre>
<p>Nach meinem Verständnis sind dies einfach nur Symbole, die durch die entsprechenden Zahlen ausgedrückt werden. ID_FILE_EXIT entspricht einer &quot;Nachricht&quot;(?) die mit einem entsprechenden</p>
<pre><code class="language-cpp">case ID_FILE_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0);					
break;
</code></pre>
<p>zu einer Schließung des Fensters führt. Wieso klappt dies nicht, wenn ich aus 9001 bspw. 12 mache?</p>
<p>Unter</p>
<pre><code class="language-cpp">#include &quot;resource.h&quot;

IDR_MYMENU MENU
BEGIN
    POPUP &quot;&amp;File&quot;
    BEGIN
        MENUITEM &quot;E&amp;xit&quot;, ID_FILE_EXIT
    END

    POPUP &quot;&amp;Stuff&quot;
    BEGIN
        MENUITEM &quot;&amp;Go&quot;, ID_STUFF_GO
        MENUITEM &quot;G&amp;o somewhere else&quot;, 0, GRAYED
    END
END

IDI_MYICON ICON &quot;menu_one.ico&quot;
</code></pre>
<p>erstellt der Autor eine Ressourcen-Datei, welche wohl die Struktur des Menüs wiederspiegeln soll.</p>
<p>1. Frage: Was sollen die Fragezeichen innerhalb der Zeichenketten?<br />
2. Frage: Jedes Item bekommt eine bestimmte MenuID zugeteilt. Der Name dieser MenuID ist doch mir überlassen, oder?</p>
<p>Der Vollständigkeit halber hier mein Windows-Programm dazu:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &quot;resource.h&quot;
#include &lt;tchar.h&gt;

LRESULT CALLBACK WndProc (HWND , UINT , WPARAM , LPARAM);
HINSTANCE hActInstance;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    LPSTR lpszCmdParam, int nCmdShow)
{
   MSG msg;
   HWND hwnd;
   WNDCLASS wndclass ;

   hActInstance = hInstance ;

   if (!hPrevInstance) {

      wndclass.style         = CS_HREDRAW | CS_VREDRAW;
      wndclass.lpfnWndProc   = WndProc;
      wndclass.cbClsExtra    = 0;
      wndclass.cbWndExtra    = 0;
      wndclass.hInstance     = hInstance;
      wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION);
      wndclass.hCursor       = LoadCursor (NULL , IDC_ARROW);
      wndclass.hbrBackground = GetStockObject (LTGRAY_BRUSH);
      wndclass.lpszMenuName  = MAKEINTRESOURCE(IDR_MYMENU);
      wndclass.lpszClassName = _T(&quot;WndClassName&quot;);

      RegisterClass (&amp;wndclass);
   }

   hwnd = CreateWindow (_T(&quot;WndClassName&quot;), _T(&quot;LED&quot;),
                        WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
                        CW_USEDEFAULT, 320, 240,
                        NULL,  NULL, hInstance,  NULL);

   ShowWindow(hwnd, nCmdShow);
   UpdateWindow(hwnd);

   while (GetMessage (&amp;msg, NULL, 0, 0)) {

      TranslateMessage(&amp;msg) ;
      DispatchMessage(&amp;msg) ;
   }

   return msg.wParam ;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   switch (message) {

      case WM_DESTROY:     PostQuitMessage(0);
                           break;
		case WM_COMMAND:		switch(LOWORD(wParam))
									{

										case ID_FILE_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0);
										break;

										case ID_STUFF_GO: MessageBox(hwnd, _T(&quot;bla&quot;), _T(&quot;test&quot;), MB_OK);
										break;
									}
									break;

      case WM_LBUTTONDOWN: MessageBox(NULL, _T(&quot;Bitte einen Menuepunkt wählen&quot;), _T(&quot;&quot;), MB_OK);
                           break;
      return 0;
   }

   return DefWindowProc (hwnd, message, wParam, lParam) ;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1608175</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1608175</guid><dc:creator><![CDATA[Rinneradio]]></dc:creator><pubDate>Fri, 31 Oct 2008 17:05:59 GMT</pubDate></item><item><title><![CDATA[Reply to Menüpunkte innerhalb eines Dropdown-Menüs funktionieren nicht on Fri, 31 Oct 2008 18:12:58 GMT]]></title><description><![CDATA[<p>also diese</p>
<pre><code class="language-cpp">#define ID_FILE_EXIT 9001
</code></pre>
<p>sind einfach Platzhalter, weil man sich die meisten Leute ein ID_FILE_EXIT einfacher merken kann als ein 9001, während des Compilierens ersetzt dein Compiler diese Platzhalter gegen die Zahl die du definiert hast.</p>
<p>Zu deinen anderen Fragen<br />
1.das sind keine Fragezeichen sondern das ist das Kaufmanns-Und, wenn du das vor einem Buchstaben in der Menüleiste schreibst, bekommt der Buchstabe einen Underscore und du kannst mit den Taste ALT+Buchstabe den Menüpunkt ausführen<br />
2.bedingt, wenn du eine Headerdatei einbindest in der der Name schon mit define definiert ist, wird dir der Compiler beim Compilieren eine Fehlermeldung erzeugen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1608195</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1608195</guid><dc:creator><![CDATA[#define ID_FILE_EXIT]]></dc:creator><pubDate>Fri, 31 Oct 2008 18:12:58 GMT</pubDate></item><item><title><![CDATA[Reply to Menüpunkte innerhalb eines Dropdown-Menüs funktionieren nicht on Fri, 31 Oct 2008 20:56:27 GMT]]></title><description><![CDATA[<p>Sorry, natürlich Kaufmanns-UND. Weis garnicht wie ich auf ein Fragezeichen komme <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    />.</p>
<p>Mir ist klar, dass ID_FILE_EXIT ein Platzhalter (Symbol) für 9001 ist. Aber wieso 9001 und nicht 1234? Wenn ich 9001 durch 1234 ersetze, so wird das Programm durch das Klicken auf Exit nicht beendet. Ändere ich es wieder auf 9001, so funzt es wieder. Die Zahlen müssen doch irgend eine Bedeutung haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1608256</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1608256</guid><dc:creator><![CDATA[Rinneradio]]></dc:creator><pubDate>Fri, 31 Oct 2008 20:56:27 GMT</pubDate></item><item><title><![CDATA[Reply to Menüpunkte innerhalb eines Dropdown-Menüs funktionieren nicht on Fri, 31 Oct 2008 21:43:38 GMT]]></title><description><![CDATA[<p>Hier mal mein Quellcode und die zugehörigen Fehlermeldungen:</p>
<pre><code class="language-cpp">/* resource.h */
#define ID_MENUE 101
#define ID_DATEI_STARTEN 9002
#define ID_DATEI_BEENDEN 9001
#define ID_HILFE_INFO 21
</code></pre>
<pre><code class="language-cpp">/* winskel.rc */
#include &quot;resource.h&quot;

ID_MENUE MENU
BEGIN
    POPUP &quot;Datei&quot;
    BEGIN
	    MENUITEM &quot;Starten&quot;, ID_DATEI_STARTEN
		 MENUITEM &quot;Beenden&quot;, ID_DATEI_BEENDEN
    END

    POPUP &quot;Hilfe&quot;
    BEGIN
	    MENUITEM &quot;Information&quot;, ID_HILFE_INFO       
    END
END
</code></pre>
<pre><code class="language-cpp">/* winskel.c */
#include &lt;windows.h&gt;
#include &lt;tchar.h&gt;
#include &quot;resource.h&quot;

LRESULT CALLBACK WndProc (HWND , UINT , WPARAM , LPARAM);
HINSTANCE hActInstance;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    LPSTR lpszCmdParam, int nCmdShow)
{
   MSG msg;
   HWND hwnd;
   WNDCLASS wndclass ;

   hActInstance = hInstance ;

   if (!hPrevInstance) {

      wndclass.style         = CS_HREDRAW | CS_VREDRAW;
      wndclass.lpfnWndProc   = WndProc;
      wndclass.cbClsExtra    = 0;
      wndclass.cbWndExtra    = 0;
      wndclass.hInstance     = hInstance;
      wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION);
      wndclass.hCursor       = LoadCursor (NULL , IDC_ARROW);
      wndclass.hbrBackground = GetStockObject (LTGRAY_BRUSH);
      wndclass.lpszMenuName  = MAKEINTRESOURCE(ID_MENUE);
      wndclass.lpszClassName = _T(&quot;WndClassName&quot;);

      RegisterClass (&amp;wndclass);
   }

   hwnd = CreateWindow (_T(&quot;WndClassName&quot;), _T(&quot;Titel&quot;),
                        WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
                        CW_USEDEFAULT, 320, 240,
                        NULL,  NULL, hInstance,  NULL);

   ShowWindow(hwnd, nCmdShow);
   UpdateWindow(hwnd);

   while (GetMessage (&amp;msg, NULL, 0, 0)) {

      TranslateMessage(&amp;msg) ;
      DispatchMessage(&amp;msg) ;
   }

   return msg.wParam ;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   switch (message) {

      case WM_DESTROY:     PostQuitMessage(0);
                           break;

		case WM_COMMAND:		switch(LOWORD(wParam))
									{

										case ID_DATEI_BEENDEN: PostMessage(hwnd, WM_CLOSE, 0, 0);
										break;

										case ID_HILFE_INFO: MessageBox(hwnd, _T(&quot;Maeh&quot;), _T(&quot;Muh&quot;), MB_OK);
										break;
									}
									break;

      case WM_LBUTTONDOWN: MessageBox(NULL, _T(&quot;Bitte einen Menuepunkt wählen&quot;), _T(&quot;&quot;), MB_OK);
                           break;
      return 0;
   }

   return DefWindowProc (hwnd, message, wParam, lParam) ;
}
</code></pre>
<blockquote>
<p>error C2065: 'ID_MENUE': nichtdeklarierter Bezeichner winskel.c 27<br />
error C2065: 'ID_DATEI_BEENDEN': nichtdeklarierter Bezeichner winskel.c 61<br />
error C2051: case-Ausdruck ist keine Konstante winskel.c 61<br />
error C2065: 'ID_HILFE_INFO': nichtdeklarierter Bezeichner winskel.c 64<br />
error C2051: case-Ausdruck ist keine Konstante winskel.c 64</p>
</blockquote>
<p>Bin ich blind?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1608272</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1608272</guid><dc:creator><![CDATA[Rinneradio]]></dc:creator><pubDate>Fri, 31 Oct 2008 21:43:38 GMT</pubDate></item><item><title><![CDATA[Reply to Menüpunkte innerhalb eines Dropdown-Menüs funktionieren nicht on Fri, 31 Oct 2008 22:33:58 GMT]]></title><description><![CDATA[<p>Prüf mal ob die &quot;resource.h&quot; in der &quot;winskel.c&quot; auch die gleiche ist wie die in der &quot;winskel.rc&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1608287</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1608287</guid><dc:creator><![CDATA[küchenchef]]></dc:creator><pubDate>Fri, 31 Oct 2008 22:33:58 GMT</pubDate></item><item><title><![CDATA[Reply to Menüpunkte innerhalb eines Dropdown-Menüs funktionieren nicht on Fri, 31 Oct 2008 22:57:45 GMT]]></title><description><![CDATA[<p>Mensch küchenchef, you made my day. Daran lags. Hab ich doch glatt eine falsche Datei in das Projekt eingebunden. Danke dir!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1608290</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1608290</guid><dc:creator><![CDATA[Rinneradio]]></dc:creator><pubDate>Fri, 31 Oct 2008 22:57:45 GMT</pubDate></item></channel></rss>