<?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[Wiso funktioniert das nicht?!]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;windows.h&gt;

typedef struct BUTTON_{
	HWND hwnd;
	int cx, cy;
	POINT pos;
} BUTTON;

typedef struct EDIT_{
	HWND hwnd;
	int cx, cy;
	POINT pos;
} EDIT;

typedef struct GROUPBOX_{
	HWND hwnd;
	int cx, cy;
	POINT pos;
} GROUPBOX;

LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
BUTTON CreateButton(HWND, int, char *);
VOID MoveButton(BUTTON *, int, int);
EDIT CreateEdit(HWND, int, int);
VOID MoveEdit(EDIT *, int, int);
GROUPBOX CreateGroupbox(HWND, int, char *);

char szClassName[ ] = &quot;Edit&quot;;

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    HWND hwnd;               
    MSG messages;            
    WNDCLASSEX wincl;        

    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;
    wincl.style = CS_DBLCLKS;           
    wincl.cbSize = sizeof (WNDCLASSEX);
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL; 
    wincl.cbClsExtra = 0;      
    wincl.cbWndExtra = 0;                      
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    if (!RegisterClassEx (&amp;wincl))
        return 0;

    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           szClassName,        /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    ShowWindow (hwnd, nFunsterStil);
	UpdateWindow(hwnd);

    while (GetMessage (&amp;messages, NULL, 0, 0))
    {
        TranslateMessage(&amp;messages);
        DispatchMessage(&amp;messages);
    }

    return messages.wParam;
}

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	static int cxClient, cyClient, cxChar, cyChar;
	static BUTTON button[2];
	static EDIT edit[2];
	static GROUPBOX groupbox;
	HDC hdc;
	PAINTSTRUCT ps;
	char szBuffer[128];
	static int iLen;
	int i;

    switch (message)                  
    {
        case WM_DESTROY:
            PostQuitMessage (0);       
            break;
		case WM_CREATE:
			cxChar = LOWORD(GetDialogBaseUnits());
			cyChar = HIWORD(GetDialogBaseUnits());
			groupbox = CreateGroupbox(hwnd, 10, &quot;Control&quot;);
			for(i = 0; i &lt; 2; i++){
				edit[i] = CreateEdit(hwnd, (20 + i), 10);
				iLen = wsprintf(szBuffer, &quot;Button %d&quot;, i);
				button[i] = CreateButton(hwnd, (30 + i), szBuffer);
			} 
			break;
		case WM_SIZE:
			cxClient = LOWORD(lParam);
			cyClient = HIWORD(lParam);

		//	MoveButton(&amp;button[1], cxClient/2, cyClient/2);
			MoveEdit(&amp;edit[0], cxClient/2, cyClient/2);
			break;
		case WM_PAINT:
			hdc = BeginPaint(hwnd, &amp;ps);

			EndPaint(hwnd, &amp;ps);
			break;
		case WM_COMMAND:
			break;
        default:                      
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}

BUTTON CreateButton(HWND hwndParent, int id, char * szCaption)
{
	BUTTON button;
	HINSTANCE hInstance;

	hInstance = (HINSTANCE) GetWindowLong(hwndParent, GWL_HINSTANCE);

	button.hwnd = CreateWindowEx(
		0, &quot;button&quot;, szCaption, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
		0, 0, 0, 0, hwndParent, (HMENU) id, hInstance, NULL);

	button.cx = LOWORD(GetDialogBaseUnits()) * (strlen(szCaption) + 2);
	button.cy = HIWORD(GetDialogBaseUnits())/4 * 7;

	button.pos.x = 0;
	button.pos.y = 0;

	return(button);
}

VOID MoveButton(BUTTON * button, int x, int y)
{
	RECT rect;

	rect.left = button-&gt;pos.x - 10;
	rect.top = button-&gt;pos.y - 10;
	rect.right = rect.left + button-&gt;cx + 20;
	rect.bottom = rect.top + button-&gt;cy + 20;	

	button-&gt;pos.x = x;
	button-&gt;pos.y = y;

	MoveWindow(button-&gt;hwnd, x, y, button-&gt;cx, button-&gt;cy, TRUE);

	InvalidateRect(GetParent(button-&gt;hwnd), &amp;rect, TRUE);
}

EDIT CreateEdit(HWND hwndParent, int id, int cChars)
{
	EDIT edit;
	HINSTANCE hInstance;

	hInstance = (HINSTANCE) GetWindowLong(hwndParent, GWL_HINSTANCE);

	edit.hwnd = CreateWindowEx(
		0, &quot;edit&quot;, NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOHSCROLL,
		0, 0, 0, 0, hwndParent, (HMENU) id, hInstance, NULL);

	edit.cx = LOWORD(GetDialogBaseUnits()) * cChars;
	edit.cy = HIWORD(GetDialogBaseUnits())/3 * 4;

	edit.pos.x = 0;
	edit.pos.y = 0;

	return(edit);
}

VOID MoveEdit(EDIT * edit, int x, int y)
{
	RECT rect;

	rect.left = edit-&gt;pos.x - 10;
	rect.top = edit-&gt;pos.y - 10;
	rect.right = rect.left + edit-&gt;cx + 20;
	rect.bottom = rect.top + edit-&gt;cy + 20;	

	edit-&gt;pos.x = x;
	edit-&gt;pos.y = y;

	MoveWindow(edit-&gt;hwnd, x, y, edit-&gt;cx, edit-&gt;cy, TRUE);

	InvalidateRect(GetParent(edit-&gt;hwnd), &amp;rect, TRUE);
}

GROUPBOX CreateGroupbox(HWND hwndParent, int id, char * szCaption)
{
	GROUPBOX groupbox;
	HINSTANCE hInstance;

	hInstance = (HINSTANCE) GetWindowLong(hwndParent, GWL_HINSTANCE);

	groupbox.hwnd = CreateWindowEx(
		0, &quot;button&quot;, szCaption, WS_VISIBLE | WS_CHILD | BS_GROUPBOX,
		0, 0, 0, 0, hwndParent, (HMENU) id, hInstance, NULL);

	groupbox.cx = 0;
	groupbox.cy = 0;

	groupbox.pos.x = 0;
	groupbox.pos.y = 0;

	return(groupbox);
}
</code></pre>
<p>Hi Leute,</p>
<p>erst mal tut mir Leid, das ich so viel code hier reinpacke.<br />
Ich weis einfach nicht, wo ich den Fehler suchen soll. Nach einigen Tests stelle ich fest, dass es probleme mit CreateEdit() zu geben scheint:<br />
Das Problem:<br />
Wenn ich das Programm starte, kommt kein fenster, und das Bild fängt an zu flackern <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> Wenn ich die Operationen mit dem Edit rauskomentiere, dann funktioniert alles.<br />
Aber wo ist nun der Fehler?</p>
<p>Für Eure Antwort wäre ich sehr dankbar <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>
<p>gruss <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/topic/126990/wiso-funktioniert-das-nicht</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Jul 2026 05:58:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/126990.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 20 Nov 2005 14:23:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wiso funktioniert das nicht?! on Sun, 20 Nov 2005 14:25:04 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;windows.h&gt;

typedef struct BUTTON_{
	HWND hwnd;
	int cx, cy;
	POINT pos;
} BUTTON;

typedef struct EDIT_{
	HWND hwnd;
	int cx, cy;
	POINT pos;
} EDIT;

typedef struct GROUPBOX_{
	HWND hwnd;
	int cx, cy;
	POINT pos;
} GROUPBOX;

LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
BUTTON CreateButton(HWND, int, char *);
VOID MoveButton(BUTTON *, int, int);
EDIT CreateEdit(HWND, int, int);
VOID MoveEdit(EDIT *, int, int);
GROUPBOX CreateGroupbox(HWND, int, char *);

char szClassName[ ] = &quot;Edit&quot;;

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
    HWND hwnd;               
    MSG messages;            
    WNDCLASSEX wincl;        

    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;
    wincl.style = CS_DBLCLKS;           
    wincl.cbSize = sizeof (WNDCLASSEX);
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL; 
    wincl.cbClsExtra = 0;      
    wincl.cbWndExtra = 0;                      
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    if (!RegisterClassEx (&amp;wincl))
        return 0;

    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           szClassName,        /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    ShowWindow (hwnd, nFunsterStil);
	UpdateWindow(hwnd);

    while (GetMessage (&amp;messages, NULL, 0, 0))
    {
        TranslateMessage(&amp;messages);
        DispatchMessage(&amp;messages);
    }

    return messages.wParam;
}

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	static int cxClient, cyClient, cxChar, cyChar;
	static BUTTON button[2];
	static EDIT edit[2];
	static GROUPBOX groupbox;
	HDC hdc;
	PAINTSTRUCT ps;
	char szBuffer[128];
	static int iLen;
	int i;

    switch (message)                  
    {
        case WM_DESTROY:
            PostQuitMessage (0);       
            break;
		case WM_CREATE:
			cxChar = LOWORD(GetDialogBaseUnits());
			cyChar = HIWORD(GetDialogBaseUnits());
			groupbox = CreateGroupbox(hwnd, 10, &quot;Control&quot;);
			for(i = 0; i &lt; 2; i++){
				edit[i] = CreateEdit(hwnd, (20 + i), 10);
				iLen = wsprintf(szBuffer, &quot;Button %d&quot;, i);
				button[i] = CreateButton(hwnd, (30 + i), szBuffer);
			} 
			break;
		case WM_SIZE:
			cxClient = LOWORD(lParam);
			cyClient = HIWORD(lParam);

		//	MoveButton(&amp;button[1], cxClient/2, cyClient/2);
			MoveEdit(&amp;edit[0], cxClient/2, cyClient/2);
			break;
		case WM_PAINT:
			hdc = BeginPaint(hwnd, &amp;ps);

			EndPaint(hwnd, &amp;ps);
			break;
		case WM_COMMAND:
			break;
        default:                      
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}

BUTTON CreateButton(HWND hwndParent, int id, char * szCaption)
{
	BUTTON button;
	HINSTANCE hInstance;

	hInstance = (HINSTANCE) GetWindowLong(hwndParent, GWL_HINSTANCE);

	button.hwnd = CreateWindowEx(
		0, &quot;button&quot;, szCaption, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
		0, 0, 0, 0, hwndParent, (HMENU) id, hInstance, NULL);

	button.cx = LOWORD(GetDialogBaseUnits()) * (strlen(szCaption) + 2);
	button.cy = HIWORD(GetDialogBaseUnits())/4 * 7;

	button.pos.x = 0;
	button.pos.y = 0;

	return(button);
}

VOID MoveButton(BUTTON * button, int x, int y)
{
	RECT rect;

	rect.left = button-&gt;pos.x - 10;
	rect.top = button-&gt;pos.y - 10;
	rect.right = rect.left + button-&gt;cx + 20;
	rect.bottom = rect.top + button-&gt;cy + 20;	

	button-&gt;pos.x = x;
	button-&gt;pos.y = y;

	MoveWindow(button-&gt;hwnd, x, y, button-&gt;cx, button-&gt;cy, TRUE);

	InvalidateRect(GetParent(button-&gt;hwnd), &amp;rect, TRUE);
}

EDIT CreateEdit(HWND hwndParent, int id, int cChars)
{
	EDIT edit;
	HINSTANCE hInstance;

	hInstance = (HINSTANCE) GetWindowLong(hwndParent, GWL_HINSTANCE);

	edit.hwnd = CreateWindowEx(
		0, &quot;edit&quot;, NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOHSCROLL,
		0, 0, 0, 0, hwndParent, (HMENU) id, hInstance, NULL);

	edit.cx = LOWORD(GetDialogBaseUnits()) * cChars;
	edit.cy = HIWORD(GetDialogBaseUnits())/3 * 4;

	edit.pos.x = 0;
	edit.pos.y = 0;

	return(edit);
}

VOID MoveEdit(EDIT * edit, int x, int y)
{
	RECT rect;

	rect.left = edit-&gt;pos.x - 10;
	rect.top = edit-&gt;pos.y - 10;
	rect.right = rect.left + edit-&gt;cx + 20;
	rect.bottom = rect.top + edit-&gt;cy + 20;	

	edit-&gt;pos.x = x;
	edit-&gt;pos.y = y;

	MoveWindow(edit-&gt;hwnd, x, y, edit-&gt;cx, edit-&gt;cy, TRUE);

	InvalidateRect(GetParent(edit-&gt;hwnd), &amp;rect, TRUE);
}

GROUPBOX CreateGroupbox(HWND hwndParent, int id, char * szCaption)
{
	GROUPBOX groupbox;
	HINSTANCE hInstance;

	hInstance = (HINSTANCE) GetWindowLong(hwndParent, GWL_HINSTANCE);

	groupbox.hwnd = CreateWindowEx(
		0, &quot;button&quot;, szCaption, WS_VISIBLE | WS_CHILD | BS_GROUPBOX,
		0, 0, 0, 0, hwndParent, (HMENU) id, hInstance, NULL);

	groupbox.cx = 0;
	groupbox.cy = 0;

	groupbox.pos.x = 0;
	groupbox.pos.y = 0;

	return(groupbox);
}
</code></pre>
<p>Hi Leute,</p>
<p>erst mal tut mir Leid, das ich so viel code hier reinpacke.<br />
Ich weis einfach nicht, wo ich den Fehler suchen soll. Nach einigen Tests stelle ich fest, dass es probleme mit CreateEdit() zu geben scheint:<br />
Das Problem:<br />
Wenn ich das Programm starte, kommt kein fenster, und das Bild fängt an zu flackern <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> Wenn ich die Operationen mit dem Edit rauskomentiere, dann funktioniert alles.<br />
Aber wo ist nun der Fehler?</p>
<p>Für Eure Antwort wäre ich sehr dankbar <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>
<p>gruss <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/922276</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/922276</guid><dc:creator><![CDATA[linu*x*bie]]></dc:creator><pubDate>Sun, 20 Nov 2005 14:25:04 GMT</pubDate></item><item><title><![CDATA[Reply to Wiso funktioniert das nicht?! on Sun, 20 Nov 2005 14:27:42 GMT]]></title><description><![CDATA[<p>Schlechter Beitrag. Bitte vernünftige Beiträge erstellen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/922277</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/922277</guid><dc:creator><![CDATA[Tipp]]></dc:creator><pubDate>Sun, 20 Nov 2005 14:27:42 GMT</pubDate></item><item><title><![CDATA[Reply to Wiso funktioniert das nicht?! on Sun, 20 Nov 2005 14:49:38 GMT]]></title><description><![CDATA[<p>Tipp schrieb:</p>
<blockquote>
<p>Schlechter Beitrag. Bitte vernünftige Beiträge erstellen.</p>
</blockquote>
<p>Ja sorry, ist mir schon aufgefallen. Tut mir leid kommt nicht mehr wider vor <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/922294</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/922294</guid><dc:creator><![CDATA[linu(x)bie_logout]]></dc:creator><pubDate>Sun, 20 Nov 2005 14:49:38 GMT</pubDate></item><item><title><![CDATA[Reply to Wiso funktioniert das nicht?! on Sun, 20 Nov 2005 15:51:56 GMT]]></title><description><![CDATA[<p>So ich hab nun endlich den Fehler gefunden:</p>
<p>Ich hatte die Fensterklasse (meines Haubtfensters) &quot;edit&quot; genannt. So heist aber bereits die Klasse das Edits. Das hat zu Fehlern geführt.</p>
<p>Vielen Dank an alle, die sich dennoch bemüht 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>
<p>gruss</p>
]]></description><link>https://www.c-plusplus.net/forum/post/922366</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/922366</guid><dc:creator><![CDATA[linu(x)bie_logout]]></dc:creator><pubDate>Sun, 20 Nov 2005 15:51:56 GMT</pubDate></item></channel></rss>