<?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[Ich komme mit Menüs nicht klar(GetMenu,Loadmenu,Resource.h etc.)]]></title><description><![CDATA[<p>Ich schaffe das mit den menüs nicht. Ich habe mir den Artikel im Petzold schon x mal durchgelesen.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &quot;resource.h&quot;
#define ID_EDIT		1

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

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     static TCHAR szAppName[] = TEXT (&quot;HelloWin&quot;) ;

     HWND         hwnd ;
     MSG          msg ;
     WNDCLASS     wndclass ;

     wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
     wndclass.lpfnWndProc   = WndProc ;
     wndclass.cbClsExtra    = 0 ;
     wndclass.cbWndExtra    = 0 ;
     wndclass.hInstance     = hInstance ;
     wndclass.hIcon         = LoadIcon (hInstance,MAKEINTRESOURCE(IDI_ICON)) ;
     wndclass.hCursor       = LoadCursor (hInstance,MAKEINTRESOURCE(IDC_CURSOR));
     wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
     wndclass.lpszMenuName  = TEXT(&quot;IDR_MENU1&quot;);
     wndclass.lpszClassName = szAppName;

     if (!RegisterClass (&amp;wndclass))
     {    // UNICODE-Compilierung ist die einzige realistische Fehlermöglichkeit 
          MessageBox (NULL, TEXT (&quot;Programm arbeitet mit Unicode und setzt Windows NT voraus!&quot;), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }

      hwnd = CreateWindow (szAppName,                 // Name der Fensterklasse
                  TEXT (&quot;Das erste echte Programm&quot;),  // Fenstertitel
                  WS_OVERLAPPEDWINDOW,                // Fensterstil
                  CW_USEDEFAULT,                      // X-Position des Fensters
                  CW_USEDEFAULT,                      // Y-Position des Fensters
                  CW_USEDEFAULT,                      // Fensterbreite
                  CW_USEDEFAULT,                      // Fensterhöhe
                  NULL,                               // übergeordnetes Fenster
                  NULL,                               // Menü
                  hInstance,                          // Programm-Kopiezähler (Programm-ID)
                  NULL) ;                             // zusätzliche Parameter

     ShowWindow (hwnd, iCmdShow) ;
     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)
{
     HDC         hdc ;
     PAINTSTRUCT ps ;
     RECT        rect ;
	 HMENU hMenu;
	 static char szText[30];
	 static HWND hwndEdit;

     switch (message)
     {
     case WM_CREATE:
          //PlaySound (&quot;hellowin.wav&quot;), NULL, SND_FILENAME | SND_ASYNC) ;
		 wsprintf(szText,&quot;a&quot;);
		hwndEdit = CreateWindow(&quot;edit&quot;,NULL,
					ES_LEFT|WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|WS_BORDER|
					ES_MULTILINE|ES_AUTOHSCROLL|ES_AUTOVSCROLL,
					0,0,0,0,hwnd,(HMENU) ID_EDIT,
					 ((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL);
		hMenu = LoadMenu(hInstance,MAKEINTRESOURCE(IDR_MENU1));// stimmt das?
          return 0 ;
	 case WM_SIZE:
		 MoveWindow(hwndEdit,0,0,LOWORD(lParam)-500,HIWORD(lParam),TRUE);

     case WM_PAINT:
          hdc = BeginPaint (hwnd, &amp;ps) ;

          GetClientRect (hwnd, &amp;rect) ;

          DrawText (hdc, TEXT (szText), -1, &amp;rect,
                    DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;

          EndPaint (hwnd, &amp;ps) ;
          return 0 ;
	 case WM_COMMAND:
		 hMenu = GetMenu(hwnd);//steht so im Petzold
		 return 0;
     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
</code></pre>
<pre><code class="language-cpp">//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by RESOURCE.RC
//
#define IDI_ICON                        101
#define IDC_CURSOR                      102
#define IDR_MENU1                       103
#define ID_DATEI_BEENDEN                40001

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        104
#define _APS_NEXT_COMMAND_VALUE         40002
#define _APS_NEXT_CONTROL_VALUE         1000
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
</code></pre>
<p>Ich verstehe das nicht. Im Petzold wird nicht mal LoadMenu benutzt. Wenn ich das beispiel aus dem Petzold posten soll, dann sagt bescheid.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/127828/ich-komme-mit-menüs-nicht-klar-getmenu-loadmenu-resource-h-etc</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Jul 2026 18:08:09 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/127828.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 27 Nov 2005 19:36:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ich komme mit Menüs nicht klar(GetMenu,Loadmenu,Resource.h etc.) on Sun, 27 Nov 2005 19:36:39 GMT]]></title><description><![CDATA[<p>Ich schaffe das mit den menüs nicht. Ich habe mir den Artikel im Petzold schon x mal durchgelesen.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &quot;resource.h&quot;
#define ID_EDIT		1

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

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     static TCHAR szAppName[] = TEXT (&quot;HelloWin&quot;) ;

     HWND         hwnd ;
     MSG          msg ;
     WNDCLASS     wndclass ;

     wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
     wndclass.lpfnWndProc   = WndProc ;
     wndclass.cbClsExtra    = 0 ;
     wndclass.cbWndExtra    = 0 ;
     wndclass.hInstance     = hInstance ;
     wndclass.hIcon         = LoadIcon (hInstance,MAKEINTRESOURCE(IDI_ICON)) ;
     wndclass.hCursor       = LoadCursor (hInstance,MAKEINTRESOURCE(IDC_CURSOR));
     wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
     wndclass.lpszMenuName  = TEXT(&quot;IDR_MENU1&quot;);
     wndclass.lpszClassName = szAppName;

     if (!RegisterClass (&amp;wndclass))
     {    // UNICODE-Compilierung ist die einzige realistische Fehlermöglichkeit 
          MessageBox (NULL, TEXT (&quot;Programm arbeitet mit Unicode und setzt Windows NT voraus!&quot;), 
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }

      hwnd = CreateWindow (szAppName,                 // Name der Fensterklasse
                  TEXT (&quot;Das erste echte Programm&quot;),  // Fenstertitel
                  WS_OVERLAPPEDWINDOW,                // Fensterstil
                  CW_USEDEFAULT,                      // X-Position des Fensters
                  CW_USEDEFAULT,                      // Y-Position des Fensters
                  CW_USEDEFAULT,                      // Fensterbreite
                  CW_USEDEFAULT,                      // Fensterhöhe
                  NULL,                               // übergeordnetes Fenster
                  NULL,                               // Menü
                  hInstance,                          // Programm-Kopiezähler (Programm-ID)
                  NULL) ;                             // zusätzliche Parameter

     ShowWindow (hwnd, iCmdShow) ;
     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)
{
     HDC         hdc ;
     PAINTSTRUCT ps ;
     RECT        rect ;
	 HMENU hMenu;
	 static char szText[30];
	 static HWND hwndEdit;

     switch (message)
     {
     case WM_CREATE:
          //PlaySound (&quot;hellowin.wav&quot;), NULL, SND_FILENAME | SND_ASYNC) ;
		 wsprintf(szText,&quot;a&quot;);
		hwndEdit = CreateWindow(&quot;edit&quot;,NULL,
					ES_LEFT|WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|WS_BORDER|
					ES_MULTILINE|ES_AUTOHSCROLL|ES_AUTOVSCROLL,
					0,0,0,0,hwnd,(HMENU) ID_EDIT,
					 ((LPCREATESTRUCT) lParam) -&gt; hInstance, NULL);
		hMenu = LoadMenu(hInstance,MAKEINTRESOURCE(IDR_MENU1));// stimmt das?
          return 0 ;
	 case WM_SIZE:
		 MoveWindow(hwndEdit,0,0,LOWORD(lParam)-500,HIWORD(lParam),TRUE);

     case WM_PAINT:
          hdc = BeginPaint (hwnd, &amp;ps) ;

          GetClientRect (hwnd, &amp;rect) ;

          DrawText (hdc, TEXT (szText), -1, &amp;rect,
                    DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;

          EndPaint (hwnd, &amp;ps) ;
          return 0 ;
	 case WM_COMMAND:
		 hMenu = GetMenu(hwnd);//steht so im Petzold
		 return 0;
     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
</code></pre>
<pre><code class="language-cpp">//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by RESOURCE.RC
//
#define IDI_ICON                        101
#define IDC_CURSOR                      102
#define IDR_MENU1                       103
#define ID_DATEI_BEENDEN                40001

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        104
#define _APS_NEXT_COMMAND_VALUE         40002
#define _APS_NEXT_CONTROL_VALUE         1000
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif
</code></pre>
<p>Ich verstehe das nicht. Im Petzold wird nicht mal LoadMenu benutzt. Wenn ich das beispiel aus dem Petzold posten soll, dann sagt bescheid.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/928589</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/928589</guid><dc:creator><![CDATA[Leon++]]></dc:creator><pubDate>Sun, 27 Nov 2005 19:36:39 GMT</pubDate></item><item><title><![CDATA[Reply to Ich komme mit Menüs nicht klar(GetMenu,Loadmenu,Resource.h etc.) on Sun, 27 Nov 2005 19:44:43 GMT]]></title><description><![CDATA[<p>Du solltest</p>
<pre><code class="language-cpp">wndclass.lpszMenuName  = TEXT(&quot;IDR_MENU1&quot;);
</code></pre>
<p>durch</p>
<pre><code class="language-cpp">wndclass.lpszMenuName  = MAKEINTRESOURCE(IDR_MENU1);
</code></pre>
<p>ersetzen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/928591</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/928591</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 27 Nov 2005 19:44:43 GMT</pubDate></item><item><title><![CDATA[Reply to Ich komme mit Menüs nicht klar(GetMenu,Loadmenu,Resource.h etc.) on Sun, 27 Nov 2005 19:58:41 GMT]]></title><description><![CDATA[<pre><code>hMenu = LoadMenu(hInstance,MAKEINTRESOURCE(IDR_MENU1));
</code></pre>
<p>[quote&quot;Compieler&quot;]hInstance --- nicht declarierter Bezeichner[/quote]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/928601</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/928601</guid><dc:creator><![CDATA[Leon++]]></dc:creator><pubDate>Sun, 27 Nov 2005 19:58:41 GMT</pubDate></item><item><title><![CDATA[Reply to Ich komme mit Menüs nicht klar(GetMenu,Loadmenu,Resource.h etc.) on Sun, 27 Nov 2005 20:03:37 GMT]]></title><description><![CDATA[<p>&quot;hInstance&quot; ist in WinMain definiert... entweder Du machst jetzt eine globale Variable, wo Du diesen Wert speicherst, oder Du übergibst ihn eben...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/928609</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/928609</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 27 Nov 2005 20:03:37 GMT</pubDate></item><item><title><![CDATA[Reply to Ich komme mit Menüs nicht klar(GetMenu,Loadmenu,Resource.h etc.) on Sun, 27 Nov 2005 20:06:48 GMT]]></title><description><![CDATA[<p>Jochen Kalmbach schrieb:</p>
<blockquote>
<p>&quot;hInstance&quot; ist in WinMain definiert... entweder Du machst jetzt eine globale Variable, wo Du diesen Wert speicherst, oder Du übergibst ihn eben...</p>
</blockquote>
<p>wie mach ich das?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/928611</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/928611</guid><dc:creator><![CDATA[Leon++]]></dc:creator><pubDate>Sun, 27 Nov 2005 20:06:48 GMT</pubDate></item><item><title><![CDATA[Reply to Ich komme mit Menüs nicht klar(GetMenu,Loadmenu,Resource.h etc.) on Sun, 27 Nov 2005 20:27:13 GMT]]></title><description><![CDATA[<p>Vielleicht ganz einfach?</p>
<pre><code class="language-cpp">HMODULE g_hInstance;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
  g_hInstance = hInstance;
</code></pre>
<p>// ...<br />
}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/928618</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/928618</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 27 Nov 2005 20:27:13 GMT</pubDate></item><item><title><![CDATA[Reply to Ich komme mit Menüs nicht klar(GetMenu,Loadmenu,Resource.h etc.) on Mon, 28 Nov 2005 05:56:41 GMT]]></title><description><![CDATA[<p>GetModuleHandle(NULL);</p>
<p>Ist meiner Meinung nach schöner, als globale Variablen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/928731</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/928731</guid><dc:creator><![CDATA[Tc++H]]></dc:creator><pubDate>Mon, 28 Nov 2005 05:56:41 GMT</pubDate></item><item><title><![CDATA[Reply to Ich komme mit Menüs nicht klar(GetMenu,Loadmenu,Resource.h etc.) on Mon, 28 Nov 2005 06:38:53 GMT]]></title><description><![CDATA[<p>Tc++H schrieb:</p>
<blockquote>
<p>GetModuleHandle(NULL);<br />
Ist meiner Meinung nach schöner, als globale Variablen...</p>
</blockquote>
<p>Da kann man sich drüber streiten...<br />
Deine Lösung funktioniert nicht, wenn der Source in einer DLL steckt...</p>
<p>Die &quot;schönste&quot; Lösung wäre es den passenden Funktionen/Klassen mitzugeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/928736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/928736</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Mon, 28 Nov 2005 06:38:53 GMT</pubDate></item><item><title><![CDATA[Reply to Ich komme mit Menüs nicht klar(GetMenu,Loadmenu,Resource.h etc.) on Mon, 28 Nov 2005 13:33:22 GMT]]></title><description><![CDATA[<p>Herr Kalmbach,<br />
ich bin ihnen zu ewigem Dank verpflichtet. Als Zeichen meiner Dankbarkeit wird ihr name absofort unter meinen artikeln stehen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/928969</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/928969</guid><dc:creator><![CDATA[Leon++]]></dc:creator><pubDate>Mon, 28 Nov 2005 13:33:22 GMT</pubDate></item><item><title><![CDATA[Reply to Ich komme mit Menüs nicht klar(GetMenu,Loadmenu,Resource.h etc.) on Mon, 28 Nov 2005 13:43:15 GMT]]></title><description><![CDATA[<p>Leon++ schrieb:</p>
<blockquote>
<p>Herr Kalmbach,</p>
</blockquote>
<p>Normalerweise spricht man sich doch hier mit Vornamen oder Nick-Name an, oder?</p>
<p>Leon++ schrieb:</p>
<blockquote>
<p>ich bin ihnen zu ewigem Dank verpflichtet. Als Zeichen meiner Dankbarkeit wird ihr name absofort unter meinen artikeln stehen!</p>
</blockquote>
<p>Zu viel Ironie ist auch wieder schlecht... <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/928982</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/928982</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Mon, 28 Nov 2005 13:43:15 GMT</pubDate></item></channel></rss>