<?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[Fenstergröße bereits aus WM_CREATE lesen ?]]></title><description><![CDATA[<p>Laut MSDN beeinhaltet lParam von WM_CREATE einen Zeiger auf eine CREATESTRUCT-Struktur, die wiederum ihrerseits einige Informationen über das Fenster enthält. Nun wollte ich an Hand dieses Parameters die Fensterbreite bzw. die Breite des Anwendungsbereiches in eine Variable einlesen:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#define WINAPP &quot;WinApp&quot;

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

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
	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(NULL, IDI_APPLICATION);
	wndclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
	wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wndclass.lpszMenuName  = NULL;
	wndclass.lpszClassName = WINAPP;

	if(!RegisterClass(&amp;wndclass))
	    return 0;

	hwnd = CreateWindow(WINAPP,                       // wndclass
		        WINAPP,                               // title
                WS_OVERLAPPEDWINDOW,                  // style
				CW_USEDEFAULT,                        // x-pos
                CW_USEDEFAULT,                        // y-pos
				CW_USEDEFAULT,                        // width
				CW_USEDEFAULT,                        // height
				NULL,                                 
				NULL,                                 // menu
				hInstance,                            // ID
				NULL);                                // additional parameters

	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;
	static int cxClient;
	char szBuffer[32];

	switch(message)
	{
	case WM_CREATE:
		cxClient = ((LPCREATESTRUCT)lParam)-&gt;cx;    // Zuweisung
		return 0;

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

		TextOut(hdc, 100, 100, itoa(cxClient, szBuffer, 10), 31);

		EndPaint(hwnd, &amp;ps);
     	return 0;

	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	return DefWindowProc(hwnd, message, wParam, lParam);
}
</code></pre>
<p>Nur leider entspricht die Ausgabe überhaupt nicht dem erwarteten Wert, denn da steht dann irgendeine Zahl -2147483648 oder so.</p>
<p>Hat jemand eine Idee woran das liegen könnte? Also eine Zuweisung müsste auf jeden Fall stattfinden, denn ich hab auch schon probiert cxClient einfach mal mit 0 zu initialisieren, aber es wird trotzdem wieder o.g. Zahl ausgegeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/70701/fenstergröße-bereits-aus-wm_create-lesen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Apr 2026 11:23:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/70701.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 10 Apr 2004 14:18:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fenstergröße bereits aus WM_CREATE lesen ? on Sat, 10 Apr 2004 14:18:23 GMT]]></title><description><![CDATA[<p>Laut MSDN beeinhaltet lParam von WM_CREATE einen Zeiger auf eine CREATESTRUCT-Struktur, die wiederum ihrerseits einige Informationen über das Fenster enthält. Nun wollte ich an Hand dieses Parameters die Fensterbreite bzw. die Breite des Anwendungsbereiches in eine Variable einlesen:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#define WINAPP &quot;WinApp&quot;

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

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
	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(NULL, IDI_APPLICATION);
	wndclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
	wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wndclass.lpszMenuName  = NULL;
	wndclass.lpszClassName = WINAPP;

	if(!RegisterClass(&amp;wndclass))
	    return 0;

	hwnd = CreateWindow(WINAPP,                       // wndclass
		        WINAPP,                               // title
                WS_OVERLAPPEDWINDOW,                  // style
				CW_USEDEFAULT,                        // x-pos
                CW_USEDEFAULT,                        // y-pos
				CW_USEDEFAULT,                        // width
				CW_USEDEFAULT,                        // height
				NULL,                                 
				NULL,                                 // menu
				hInstance,                            // ID
				NULL);                                // additional parameters

	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;
	static int cxClient;
	char szBuffer[32];

	switch(message)
	{
	case WM_CREATE:
		cxClient = ((LPCREATESTRUCT)lParam)-&gt;cx;    // Zuweisung
		return 0;

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

		TextOut(hdc, 100, 100, itoa(cxClient, szBuffer, 10), 31);

		EndPaint(hwnd, &amp;ps);
     	return 0;

	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	return DefWindowProc(hwnd, message, wParam, lParam);
}
</code></pre>
<p>Nur leider entspricht die Ausgabe überhaupt nicht dem erwarteten Wert, denn da steht dann irgendeine Zahl -2147483648 oder so.</p>
<p>Hat jemand eine Idee woran das liegen könnte? Also eine Zuweisung müsste auf jeden Fall stattfinden, denn ich hab auch schon probiert cxClient einfach mal mit 0 zu initialisieren, aber es wird trotzdem wieder o.g. Zahl ausgegeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/498800</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/498800</guid><dc:creator><![CDATA[zuckzappel]]></dc:creator><pubDate>Sat, 10 Apr 2004 14:18:23 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstergröße bereits aus WM_CREATE lesen ? on Sat, 10 Apr 2004 14:37:11 GMT]]></title><description><![CDATA[<p>Das rührt daher, weil du das CW_USEDEFAULT Makro bei der CreateWindow-Funktion benutzt. Das ist wie folgt definiert: #define CW_USEDEFAULT ((int)0x80000000)</p>
<p>Ich würde an deiner Stelle in der WM_SIZE Nachricht &quot;cxClient&quot; die Breite des Fensters zuweisen. Außerdem wäre der Variablen-Name wndCX viel sinnvoler als cxClient, weil das kleine 'c' ohnehin für Client steht. (Ist aber nur eine persönliche Annahme...).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/498809</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/498809</guid><dc:creator><![CDATA[Aziz]]></dc:creator><pubDate>Sat, 10 Apr 2004 14:37:11 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstergröße bereits aus WM_CREATE lesen ? on Sat, 10 Apr 2004 14:40:49 GMT]]></title><description><![CDATA[<p>Wird die WM_SIZE-Nachricht auch direkt beim Programmstart zumindest einmal gesendet ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/498811</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/498811</guid><dc:creator><![CDATA[zuckzappel]]></dc:creator><pubDate>Sat, 10 Apr 2004 14:40:49 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstergröße bereits aus WM_CREATE lesen ? on Sat, 10 Apr 2004 14:42:19 GMT]]></title><description><![CDATA[<p>Ich denke sie wird mindestens einmal gesendet, bevor überhaupt WM_CREATE gesendet wird.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/498812</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/498812</guid><dc:creator><![CDATA[Aziz]]></dc:creator><pubDate>Sat, 10 Apr 2004 14:42:19 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstergröße bereits aus WM_CREATE lesen ? on Sat, 10 Apr 2004 14:43:01 GMT]]></title><description><![CDATA[<p>Das kannst du mit einem Debugger natürlich besser überprüfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/498813</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/498813</guid><dc:creator><![CDATA[Aziz]]></dc:creator><pubDate>Sat, 10 Apr 2004 14:43:01 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstergröße bereits aus WM_CREATE lesen ? on Sat, 10 Apr 2004 14:43:42 GMT]]></title><description><![CDATA[<p>Nachprüfen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/498814</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/498814</guid><dc:creator><![CDATA[ChrisK]]></dc:creator><pubDate>Sat, 10 Apr 2004 14:43:42 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstergröße bereits aus WM_CREATE lesen ? on Sat, 10 Apr 2004 14:56:14 GMT]]></title><description><![CDATA[<p>wie kann ich genau prüfen? (ich verwende MSVC++)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/498832</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/498832</guid><dc:creator><![CDATA[zuckzappel]]></dc:creator><pubDate>Sat, 10 Apr 2004 14:56:14 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstergröße bereits aus WM_CREATE lesen ? on Sat, 10 Apr 2004 15:01:06 GMT]]></title><description><![CDATA[<p>Überhaupt keine Erfahrung mit dem Debugger?</p>
<p>Ich habs jetzt aber selber nachgeprüft: WM_SIZE kommt doch erst nach WM_CREATE. Entschuldige!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/498835</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/498835</guid><dc:creator><![CDATA[Aziz]]></dc:creator><pubDate>Sat, 10 Apr 2004 15:01:06 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstergröße bereits aus WM_CREATE lesen ? on Sat, 10 Apr 2004 15:13:38 GMT]]></title><description><![CDATA[<p>also ich brauchte den debugger bisher überhaupt nicht, deshalb hab ich auch keine erfahrung. aber wenn WM_SIZE erst nacht WM_CREATE kommt, dann gibts bei default-werten für die fenstergröße doch eigentlich keine möglichkeit, die fenstergröße bereits in WM_CREATE irgendwo einzulesen oder ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/498845</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/498845</guid><dc:creator><![CDATA[zuckzappel]]></dc:creator><pubDate>Sat, 10 Apr 2004 15:13:38 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstergröße bereits aus WM_CREATE lesen ? on Sat, 10 Apr 2004 15:22:36 GMT]]></title><description><![CDATA[<p>Wenn du Default-Werte verwenden willst, kannst du in WM_CREATE mit GetClientRect die richtige Fensterbreite und Fensterhöhe ermitteln.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/498854</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/498854</guid><dc:creator><![CDATA[Aziz]]></dc:creator><pubDate>Sat, 10 Apr 2004 15:22:36 GMT</pubDate></item></channel></rss>