<?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[Fenstervergrößerung nur in bestimmten Seitenverhältnis erlauben]]></title><description><![CDATA[<p>Schönen guten Abend zusammen! <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>wie der Titel schon vermuten lässt, würde ich gerne das 'resizen' des Fenster auf ein bestimmtes Seitenverhältnis begrenzen: Verändert der Benutzer die Größe, soll sich die entsprechende andere Seite automatisch mit anpassen, so das das Verhältnis gewahrt bleibt <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="😉"
    /> . Hätte jemand eine Idee, wie ich das realisieren könnte?</p>
<p>Mein Ansatz war Folgender:</p>
<pre><code class="language-cpp">case WM_SIZE:
			iX = LOWORD(lParam);
			iY = HIWORD(lParam);
			BITMAP bmInfo;
			GetObject(hiCurrent, sizeof(BITMAP), &amp;bmInfo);
			double f = (double)bmInfo.bmWidth / (double)bmInfo.bmHeight; // Seitenverhältnis errechnen
			if((double)iX / (double)iY != f)
			{
				//SetWindowPos(hWnd, NULL, 0, 0, f * iY, iY, SWP_NOMOVE | SWP_NOZORDER);
				RECT rc;
				GetWindowRect(hWnd, &amp;rc);
				MoveWindow(hWnd, rc.left, rc.top, f * iY, iY, TRUE);
			}
			break;
</code></pre>
<p>Aber irgendwie ließ sich das Fenster danach gar nicht mehr verändern. Mit SetWindowPos (auskommentiert) hat es ebenfalls nicht funktioniert.</p>
<p>Hat jmd. eine Idee? Wäre sehr dankbar!</p>
<p>MfG Daniel</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/205626/fenstervergrößerung-nur-in-bestimmten-seitenverhältnis-erlauben</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 07:26:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/205626.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 15 Feb 2008 21:18:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fenstervergrößerung nur in bestimmten Seitenverhältnis erlauben on Fri, 15 Feb 2008 21:18:15 GMT]]></title><description><![CDATA[<p>Schönen guten Abend zusammen! <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>wie der Titel schon vermuten lässt, würde ich gerne das 'resizen' des Fenster auf ein bestimmtes Seitenverhältnis begrenzen: Verändert der Benutzer die Größe, soll sich die entsprechende andere Seite automatisch mit anpassen, so das das Verhältnis gewahrt bleibt <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="😉"
    /> . Hätte jemand eine Idee, wie ich das realisieren könnte?</p>
<p>Mein Ansatz war Folgender:</p>
<pre><code class="language-cpp">case WM_SIZE:
			iX = LOWORD(lParam);
			iY = HIWORD(lParam);
			BITMAP bmInfo;
			GetObject(hiCurrent, sizeof(BITMAP), &amp;bmInfo);
			double f = (double)bmInfo.bmWidth / (double)bmInfo.bmHeight; // Seitenverhältnis errechnen
			if((double)iX / (double)iY != f)
			{
				//SetWindowPos(hWnd, NULL, 0, 0, f * iY, iY, SWP_NOMOVE | SWP_NOZORDER);
				RECT rc;
				GetWindowRect(hWnd, &amp;rc);
				MoveWindow(hWnd, rc.left, rc.top, f * iY, iY, TRUE);
			}
			break;
</code></pre>
<p>Aber irgendwie ließ sich das Fenster danach gar nicht mehr verändern. Mit SetWindowPos (auskommentiert) hat es ebenfalls nicht funktioniert.</p>
<p>Hat jmd. eine Idee? Wäre sehr dankbar!</p>
<p>MfG Daniel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1456882</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1456882</guid><dc:creator><![CDATA[Trickler]]></dc:creator><pubDate>Fri, 15 Feb 2008 21:18:15 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstervergrößerung nur in bestimmten Seitenverhältnis erlauben on Fri, 15 Feb 2008 21:20:05 GMT]]></title><description><![CDATA[<p>mit WM_SIZING</p>
<p>Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1456886</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1456886</guid><dc:creator><![CDATA[Mmacher]]></dc:creator><pubDate>Fri, 15 Feb 2008 21:20:05 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstervergrößerung nur in bestimmten Seitenverhältnis erlauben on Sat, 16 Feb 2008 11:11:18 GMT]]></title><description><![CDATA[<p>jo! genau ich habe da mal was zusammengeschustert.<br />
Das funktioniert astrein und sehr benutzerfreundlich (für die mausfreaks)</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
BOOL AdjustWindowRatio(LPRECT lpRect, float fRatio, int nWindowEdge);

int WINAPI wWinMain(HINSTANCE hInstance,
					HINSTANCE hPrevInstance,
					LPWSTR    lpCmdLine,
					int       nShowCmd)
{
	WNDCLASS wcs;
	HWND hWnd;
	MSG msg;

	ZeroMemory(&amp;wcs, sizeof(WNDCLASS));
	wcs.hInstance     = hInstance;
	wcs.style         = CS_HREDRAW | CS_VREDRAW;
	wcs.lpfnWndProc   = WndProc;
	wcs.cbClsExtra    = 0;
	wcs.cbWndExtra    = 0;
	wcs.hCursor       = LoadCursor(NULL, IDC_ARROW);
	wcs.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
	wcs.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wcs.lpszClassName = L&quot;HomeToGo&quot;;
	wcs.lpszMenuName  = NULL;

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

	hWnd = CreateWindow(L&quot;HomeToGO&quot;,
						L&quot;Home To Go&quot;,
						WS_OVERLAPPEDWINDOW,
						CW_USEDEFAULT,
						CW_USEDEFAULT,
						CW_USEDEFAULT,
						CW_USEDEFAULT,
						NULL,
						NULL,
						hInstance,
						(LPVOID)lpCmdLine);

	ShowWindow(hWnd, SW_SHOW);
	UpdateWindow(hWnd);

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

	return 0;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	static float fRatio = 1.5;

	RECT rect;

	switch (uMsg)
	{
	case WM_CREATE:
		GetWindowRect(hWnd, &amp;rect);
		AdjustWindowRatio(&amp;rect, fRatio, WMSZ_BOTTOMRIGHT);
		MoveWindow(hWnd, 
				   rect.left,
				   rect.top,
				   rect.right - rect.left,
				   rect.bottom - rect.top,
				   TRUE);
		return 0;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	case WM_SIZING:
		AdjustWindowRatio((LPRECT)lParam, fRatio, wParam);
		return 0;
	default:
		return DefWindowProc(hWnd, uMsg, wParam, lParam);
	}
}

BOOL AdjustWindowRatio(LPRECT lpRect, float fRatio, int nWindowEdge)
{
	int nAvg, nWidth, nHeight;

	switch (nWindowEdge)
	{
	case WMSZ_LEFT:
	case WMSZ_RIGHT:
		nAvg = (int)((lpRect-&gt;right - lpRect-&gt;left) / fRatio);
		break;
	case WMSZ_TOP:
	case WMSZ_BOTTOM:
		nAvg = (int)((lpRect-&gt;bottom - lpRect-&gt;top) * fRatio);
		break;
	case WMSZ_TOPLEFT:
	case WMSZ_TOPRIGHT:
	case WMSZ_BOTTOMLEFT:
	case WMSZ_BOTTOMRIGHT:
		nAvg = (int)(((lpRect-&gt;right - lpRect-&gt;left) / fRatio + (lpRect-&gt;bottom - lpRect-&gt;top) * fRatio) / 2.0);
		break;
	}
	nWidth = (int)(nAvg * fRatio);
	nHeight = (int)(nAvg / fRatio);

	if (( (lpRect-&gt;right - lpRect-&gt;left) != nAvg) ||
		( (lpRect-&gt;bottom - lpRect-&gt;top) != nAvg))
	{
		switch (nWindowEdge)
		{
		case WMSZ_BOTTOM:
		case WMSZ_BOTTOMRIGHT:
		case WMSZ_RIGHT:
			lpRect-&gt;right = lpRect-&gt;left + nWidth;
			lpRect-&gt;bottom = lpRect-&gt;top + nHeight;
			break;
		case WMSZ_LEFT:
		case WMSZ_BOTTOMLEFT:
			lpRect-&gt;left = lpRect-&gt;right - nWidth;
			lpRect-&gt;bottom = lpRect-&gt;top + nHeight;
			break;
		case WMSZ_TOP:
		case WMSZ_TOPRIGHT:
			lpRect-&gt;right = lpRect-&gt;left + nWidth;
			lpRect-&gt;top = lpRect-&gt;bottom - nHeight;
			break;
		case WMSZ_TOPLEFT:
			lpRect-&gt;left = lpRect-&gt;right - nWidth;
			lpRect-&gt;top = lpRect-&gt;bottom - nHeight;
			break;
		}
	}

	return TRUE;
}
</code></pre>
<p>have fun</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1456916</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1456916</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Sat, 16 Feb 2008 11:11:18 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstervergrößerung nur in bestimmten Seitenverhältnis erlauben on Sat, 16 Feb 2008 08:56:06 GMT]]></title><description><![CDATA[<p>Beim Ändern der Fenstergröße sendet Windows die Nachricht WM_SIZE. Darin sind in lParam die neuen Maße des Fensters angegeben. Mit SetWindowPos() kannst Du die Größe neu setzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1457006</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1457006</guid><dc:creator><![CDATA[Elektronix]]></dc:creator><pubDate>Sat, 16 Feb 2008 08:56:06 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstervergrößerung nur in bestimmten Seitenverhältnis erlauben on Sat, 16 Feb 2008 10:00:24 GMT]]></title><description><![CDATA[<p>Das ist doch schwachsinn...<br />
Wenn man das so macht, flackert das Fenster doch...</p>
<p>Einfach WM_SIZING abfangen, (LPRECT)lParam ist dann das Fenster-RECT und wParam die Ecke, an der der user zieht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1457032</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1457032</guid><dc:creator><![CDATA[Totaler Quatch]]></dc:creator><pubDate>Sat, 16 Feb 2008 10:00:24 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstervergrößerung nur in bestimmten Seitenverhältnis erlauben on Wed, 20 Feb 2008 17:04:08 GMT]]></title><description><![CDATA[<p>Wieso sollte man das überhaupt machen wollen?</p>
<p>Wenn man irgendwas nur in einem bestimmten Seitenverhältnis darstellen möchte kann man ja die Darstellung im Client-Bereich des Fensters entsprechend machen, z.B. so dass oben und unten bzw. seitlich 2 Balken freibleiben wenn das Seitenverhältnis nicht passt.</p>
<p>Ist IMO immer noch userfreundlicher als beim Resizen des Fensters einzugreifen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1459622</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1459622</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Wed, 20 Feb 2008 17:04:08 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstervergrößerung nur in bestimmten Seitenverhältnis erlauben on Fri, 22 Feb 2008 23:20:52 GMT]]></title><description><![CDATA[<p>Danke erstmal für eure Antworten! (Und sry, dass ich mich jetzt erst melde <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /> )</p>
<p>Script-Styler Dein Code funktioniert soweit, danke!</p>
<p>hustbear's Vorschlag gefällt mir allerdings noch besser nur:<br />
Irgendwie bekomme ich es nicht gebackten, die Bitmap entsprechenden dem Seitenverhältnis in mein Client-Bereich zu blitten.<br />
Zum Darstellen verwende ich StretchBlt. Aber die Berechnungen gehen irgendwie immer schief <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>
<p>Das Seitenverhältnis berechne ich doch mit:</p>
<pre><code>verhaeltnis = bitmap_breite / bitmap_hoehe;
</code></pre>
<p>oder?</p>
<p>Wenn nun wnd_x meine Client-Fensterbreite und wnd_y meinte Client-Fensterhöhe ist und bmp_x bzw. bmp_y entsprechend die Breite bzw. der Höhe der Bitmap, wie berechne ich dann gemäß dem Seitenverhältnis die neue Bitmap-Breite/Höhe, damit die Bitmap in mein Client passt? Glaube es ist ja trivial, aber es will nicht funktionieren <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>
<p>Ich danke schonmal für euer Interesse! <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/1461278</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461278</guid><dc:creator><![CDATA[Trickler]]></dc:creator><pubDate>Fri, 22 Feb 2008 23:20:52 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstervergrößerung nur in bestimmten Seitenverhältnis erlauben on Sat, 23 Feb 2008 17:10:28 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">this-&gt;push();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1461621</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1461621</guid><dc:creator><![CDATA[Trickler]]></dc:creator><pubDate>Sat, 23 Feb 2008 17:10:28 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstervergrößerung nur in bestimmten Seitenverhältnis erlauben on Sun, 24 Feb 2008 20:03:32 GMT]]></title><description><![CDATA[<p>Müsste doch etwa so gehen:</p>
<pre><code class="language-cpp">// in:
//   bmp_w, bmp_h = width/height der bitmap
//   wnd_w, wnd_h = width/height des verwendbaren bereichs im fenster

// out:
//   view_w, view_h = width/height des bereichs den wir zur ausgabe verwenden

// 1. versuch mit der max. breite und angepasster höhe
view_w = wnd_w;
view_h = (bmp_h * wnd_w) / bmp_w;

// gucken ob höhe noch ok ist
if (view_h &gt; wnd_h)
{
    // 2. versuch mit der max. höhe und angepasster breite
    view_h = wnd_h;
    view_w = (bmp_w * wnd_h) / bmp_h;
}

// fertig

int offset_x = (wnd_w - view_w) / 2;
int offset_y = (wnd_h - view_h) / 2;

// ...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1462139</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1462139</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sun, 24 Feb 2008 20:03:32 GMT</pubDate></item><item><title><![CDATA[Reply to Fenstervergrößerung nur in bestimmten Seitenverhältnis erlauben on Mon, 25 Feb 2008 05:27:53 GMT]]></title><description><![CDATA[<p>Hmm, haste auch float benutzt, bei int geht ja was verloren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1462274</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1462274</guid><dc:creator><![CDATA[integer-float]]></dc:creator><pubDate>Mon, 25 Feb 2008 05:27:53 GMT</pubDate></item></channel></rss>