<?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[RegisterClassEx tut irgendwie nicht...]]></title><description><![CDATA[<p>Hi, kann mir jemand sagen was ich falsch mache? Ich bekomme von einem GetLastError den Fehlercode 87.<br />
Kann das evtl am hInstance liegen? Da steht bei mir eine NULL drin, bzw das CreateWindow liefert NULL.</p>
<pre><code>//---------------------------------------------------------------------------
#include &lt;Windows.h&gt;
#include &lt;Messages.hpp&gt;
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsused

  int iLeft = 100;
  int iTop = 100;
  int iWidth = 300;
  int iHeight = 200;
  char cClassName[] = &quot;TCm_miso1&quot;;
  HINSTANCE hInstance=0;

LRESULT __stdcall WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
  LRESULT  Result = 0;
  HWND ID_OK;

  switch(uMsg){
    case(WM_CREATE):{
        ID_OK = CreateWindow(&quot;BUTTON&quot;, &quot;OK-Button&quot;, WS_VISIBLE | WS_CHILD,
                    100, 100, 100, 30, hWnd, 0, hInstance, NULL);
        if(ID_OK == INVALID_HANDLE_VALUE)
          MessageBox(hWnd, &quot;Button nicht erzeugt&quot;, &quot;Meldung&quot;, 0);
    }
    case(WM_DESTROY): PostQuitMessage(0);
    case(WM_COMMAND):{
      if(HIWORD(wParam) == BN_CLICKED)
        if(LOWORD(wParam) == (WPARAM)ID_OK)
          MessageBox(hWnd, &quot;OK Button gedrückt&quot;, &quot;Meldung&quot;, 0);
    }
    default: Result = DefWindowProc(hWnd, uMsg, wParam, lParam);
  }
  return(Result);
}

int main(int argc, char* argv[])
{
  MSG msg;
  TRect rect;
  int deskh, deskw;
  NONCLIENTMETRICS ncm;
  HANDLE hWnd;
  WNDCLASSEX wc;

  hInstance=GetModuleHandle(NULL);  //NACHTRÄGLICH EDITIERT

  SetLastError(0);
  wc.cbSize = sizeof(wc);          // size of structure
  wc.style = CS_HREDRAW |CS_VREDRAW;// redraw if size changes
  wc.lpfnWndProc = &amp;WndProc;     // points to window procedure
  wc.cbClsExtra = 0;                // no extra class memory
  wc.cbWndExtra = 0;                // no extra window memory
  wc.hInstance = hInstance;         // handle to instance
  wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);// predefined app. icon
  wc.hCursor = LoadCursor(NULL,IDC_ARROW);// predefined arrow
  wc.hbrBackground = GetStockObject(WHITE_BRUSH);// white background brush
  wc.lpszMenuName =  &quot;MainMenu&quot;;    // name of menu resource
  wc.lpszClassName = &quot;MainWClass&quot;;  // name of window class
  SystemParametersInfo(SPI_GETWORKAREA, 0, &amp;rect, 0);
  deskw = rect.Right - rect.Left;
  deskh = rect.Bottom - rect.Top;
  ncm.cbSize = sizeof(ncm);
  SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &amp;ncm, 0);
  iWidth = iLeft + iWidth;
  iHeight = iTop + iHeight + ncm.iMenuHeight + ncm.iCaptionHeight;
  iLeft = (deskw / 2) - (iHeight / 2);
  iTop = (deskh / 2) - (iHeight / 2);

  if(!RegisterClassEx(&amp;wc))
    return(GetLastError());

  hWnd = CreateWindow(
        &quot;MainWClass&quot;,        // name of window class
        &quot;Sample&quot;,            // title-bar string
        WS_OVERLAPPEDWINDOW, // top-level window 
        CW_USEDEFAULT,       // default horizontal position 
        CW_USEDEFAULT,       // default vertical position 
        CW_USEDEFAULT,       // default width 
        CW_USEDEFAULT,       // default height 
        (HWND) NULL,         // no owner window 
        (HMENU) NULL,        // use class menu 
        hInstance,           // handle to application instance 
        (LPVOID) NULL);      // no window-creation data

  if(!hWnd)return(GetLastError());

  while(1){
    if(!GetMessage(&amp;msg, 0, 0, 0)) break; //oops :o)
    TranslateMessage(&amp;msg);
    DispatchMessage(&amp;msg);
  }

  return(GetLastError());
}
//---------------------------------------------------------------------------
</code></pre>
<p>Freundlichen Gruss<br />
Michael</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/118614/registerclassex-tut-irgendwie-nicht</link><generator>RSS for Node</generator><lastBuildDate>Sat, 04 Jul 2026 17:06:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/118614.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 22 Aug 2005 12:28:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to RegisterClassEx tut irgendwie nicht... on Mon, 22 Aug 2005 12:56:08 GMT]]></title><description><![CDATA[<p>Hi, kann mir jemand sagen was ich falsch mache? Ich bekomme von einem GetLastError den Fehlercode 87.<br />
Kann das evtl am hInstance liegen? Da steht bei mir eine NULL drin, bzw das CreateWindow liefert NULL.</p>
<pre><code>//---------------------------------------------------------------------------
#include &lt;Windows.h&gt;
#include &lt;Messages.hpp&gt;
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsused

  int iLeft = 100;
  int iTop = 100;
  int iWidth = 300;
  int iHeight = 200;
  char cClassName[] = &quot;TCm_miso1&quot;;
  HINSTANCE hInstance=0;

LRESULT __stdcall WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
  LRESULT  Result = 0;
  HWND ID_OK;

  switch(uMsg){
    case(WM_CREATE):{
        ID_OK = CreateWindow(&quot;BUTTON&quot;, &quot;OK-Button&quot;, WS_VISIBLE | WS_CHILD,
                    100, 100, 100, 30, hWnd, 0, hInstance, NULL);
        if(ID_OK == INVALID_HANDLE_VALUE)
          MessageBox(hWnd, &quot;Button nicht erzeugt&quot;, &quot;Meldung&quot;, 0);
    }
    case(WM_DESTROY): PostQuitMessage(0);
    case(WM_COMMAND):{
      if(HIWORD(wParam) == BN_CLICKED)
        if(LOWORD(wParam) == (WPARAM)ID_OK)
          MessageBox(hWnd, &quot;OK Button gedrückt&quot;, &quot;Meldung&quot;, 0);
    }
    default: Result = DefWindowProc(hWnd, uMsg, wParam, lParam);
  }
  return(Result);
}

int main(int argc, char* argv[])
{
  MSG msg;
  TRect rect;
  int deskh, deskw;
  NONCLIENTMETRICS ncm;
  HANDLE hWnd;
  WNDCLASSEX wc;

  hInstance=GetModuleHandle(NULL);  //NACHTRÄGLICH EDITIERT

  SetLastError(0);
  wc.cbSize = sizeof(wc);          // size of structure
  wc.style = CS_HREDRAW |CS_VREDRAW;// redraw if size changes
  wc.lpfnWndProc = &amp;WndProc;     // points to window procedure
  wc.cbClsExtra = 0;                // no extra class memory
  wc.cbWndExtra = 0;                // no extra window memory
  wc.hInstance = hInstance;         // handle to instance
  wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);// predefined app. icon
  wc.hCursor = LoadCursor(NULL,IDC_ARROW);// predefined arrow
  wc.hbrBackground = GetStockObject(WHITE_BRUSH);// white background brush
  wc.lpszMenuName =  &quot;MainMenu&quot;;    // name of menu resource
  wc.lpszClassName = &quot;MainWClass&quot;;  // name of window class
  SystemParametersInfo(SPI_GETWORKAREA, 0, &amp;rect, 0);
  deskw = rect.Right - rect.Left;
  deskh = rect.Bottom - rect.Top;
  ncm.cbSize = sizeof(ncm);
  SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &amp;ncm, 0);
  iWidth = iLeft + iWidth;
  iHeight = iTop + iHeight + ncm.iMenuHeight + ncm.iCaptionHeight;
  iLeft = (deskw / 2) - (iHeight / 2);
  iTop = (deskh / 2) - (iHeight / 2);

  if(!RegisterClassEx(&amp;wc))
    return(GetLastError());

  hWnd = CreateWindow(
        &quot;MainWClass&quot;,        // name of window class
        &quot;Sample&quot;,            // title-bar string
        WS_OVERLAPPEDWINDOW, // top-level window 
        CW_USEDEFAULT,       // default horizontal position 
        CW_USEDEFAULT,       // default vertical position 
        CW_USEDEFAULT,       // default width 
        CW_USEDEFAULT,       // default height 
        (HWND) NULL,         // no owner window 
        (HMENU) NULL,        // use class menu 
        hInstance,           // handle to application instance 
        (LPVOID) NULL);      // no window-creation data

  if(!hWnd)return(GetLastError());

  while(1){
    if(!GetMessage(&amp;msg, 0, 0, 0)) break; //oops :o)
    TranslateMessage(&amp;msg);
    DispatchMessage(&amp;msg);
  }

  return(GetLastError());
}
//---------------------------------------------------------------------------
</code></pre>
<p>Freundlichen Gruss<br />
Michael</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856091</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856091</guid><dc:creator><![CDATA[focus]]></dc:creator><pubDate>Mon, 22 Aug 2005 12:56:08 GMT</pubDate></item><item><title><![CDATA[Reply to RegisterClassEx tut irgendwie nicht... on Mon, 22 Aug 2005 12:30:12 GMT]]></title><description><![CDATA[<p>du überprüfst ja noch nicht mal den rückgabewert. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/856094</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856094</guid><dc:creator><![CDATA[setfocus]]></dc:creator><pubDate>Mon, 22 Aug 2005 12:30:12 GMT</pubDate></item><item><title><![CDATA[Reply to RegisterClassEx tut irgendwie nicht... on Mon, 22 Aug 2005 12:34:03 GMT]]></title><description><![CDATA[<p>Rückgabewert von RegisterClassEx ist &quot;0&quot;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856098</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856098</guid><dc:creator><![CDATA[focus]]></dc:creator><pubDate>Mon, 22 Aug 2005 12:34:03 GMT</pubDate></item><item><title><![CDATA[Reply to RegisterClassEx tut irgendwie nicht... on Mon, 22 Aug 2005 12:45:39 GMT]]></title><description><![CDATA[<p>hInstance = GetModuleHandle(NULL);</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856107</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856107</guid><dc:creator><![CDATA[global]]></dc:creator><pubDate>Mon, 22 Aug 2005 12:45:39 GMT</pubDate></item><item><title><![CDATA[Reply to RegisterClassEx tut irgendwie nicht... on Mon, 22 Aug 2005 12:52:09 GMT]]></title><description><![CDATA[<p>Habe das jetzt eingebaut und bekomme an folgender Stelle den Fehler 87.</p>
<pre><code>RegisterClassEx(&amp;wc);
  HRESULT res=GetLastError();
</code></pre>
<p>Gruss<br />
Michael</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856109</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856109</guid><dc:creator><![CDATA[focus]]></dc:creator><pubDate>Mon, 22 Aug 2005 12:52:09 GMT</pubDate></item><item><title><![CDATA[Reply to RegisterClassEx tut irgendwie nicht... on Mon, 22 Aug 2005 13:27:27 GMT]]></title><description><![CDATA[<p>Du hast zum Beispiel hIconSm nicht angegeben und da du deine WNDCLASSEX-Struktur nicht vorher geleert hast, enthält dieser Member einen undefinierten, zufälligen Wert. Also entweder mit ZeroMemory(&amp;wc,sizeof(WNDCLASSEX)) den Speicher leeren oder alle unbenutzten Member auf 0 setzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856155</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856155</guid><dc:creator><![CDATA[masterofx32]]></dc:creator><pubDate>Mon, 22 Aug 2005 13:27:27 GMT</pubDate></item><item><title><![CDATA[Reply to RegisterClassEx tut irgendwie nicht... on Mon, 22 Aug 2005 13:52:40 GMT]]></title><description><![CDATA[<p>Das wars, danke euch..</p>
<p>Grüsse Michael</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856187</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856187</guid><dc:creator><![CDATA[focus]]></dc:creator><pubDate>Mon, 22 Aug 2005 13:52:40 GMT</pubDate></item></channel></rss>