<?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[ClientSize]]></title><description><![CDATA[<p>Hi,</p>
<p>ich möchte ein Fenster mit einer ClientSize der Größe width x height haben. Also errechne ich mir mit AdjustWindowRect aus der gewünschten ClientSize die Fenstergröße:</p>
<pre><code class="language-cpp">RECT size;
size.top = 0;
size.left = 0;
size.bottom = height;
size.right = width;
DWORD style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;

AdjustWindowRect(&amp;size, style, FALSE);

int windowWidth = size.right - size.left;
int windowHeight = size.bottom - size.top;
int windowLeft = GetSystemMetrics(SM_CXSCREEN) / 2 - windowWidth / 2;
int windowTop = GetSystemMetrics(SM_CYSCREEN) / 2 - windowHeight / 2;

windowHandle = CreateWindow(&quot;Window&quot;, title, WS_OVERLAPPEDWINDOW,
                                windowLeft, windowTop, windowWidth, windowHeight, NULL, NULL, GetModuleHandle(NULL), this);

// RECT rect;
// GetClientRect(windowHandle, &amp;rect);
</code></pre>
<p>Nur wenn ich jetzt die ClientSize des Fenster wieder auslese (wie unten in dem auskommentierten Code), dann krieg ich andere Werte für Breite und Höhe als sie in width und height stehen. z.B: bei width=640 und height=480 bekomme ich rect.bottom=478 und rect.right=638.<br />
Wieso stimmen die Werte nicht überein und wie fix ich das? <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/topic/190776/clientsize</link><generator>RSS for Node</generator><lastBuildDate>Wed, 01 Jul 2026 18:33:14 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/190776.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 26 Aug 2007 20:45:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ClientSize on Sun, 26 Aug 2007 20:45:49 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich möchte ein Fenster mit einer ClientSize der Größe width x height haben. Also errechne ich mir mit AdjustWindowRect aus der gewünschten ClientSize die Fenstergröße:</p>
<pre><code class="language-cpp">RECT size;
size.top = 0;
size.left = 0;
size.bottom = height;
size.right = width;
DWORD style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;

AdjustWindowRect(&amp;size, style, FALSE);

int windowWidth = size.right - size.left;
int windowHeight = size.bottom - size.top;
int windowLeft = GetSystemMetrics(SM_CXSCREEN) / 2 - windowWidth / 2;
int windowTop = GetSystemMetrics(SM_CYSCREEN) / 2 - windowHeight / 2;

windowHandle = CreateWindow(&quot;Window&quot;, title, WS_OVERLAPPEDWINDOW,
                                windowLeft, windowTop, windowWidth, windowHeight, NULL, NULL, GetModuleHandle(NULL), this);

// RECT rect;
// GetClientRect(windowHandle, &amp;rect);
</code></pre>
<p>Nur wenn ich jetzt die ClientSize des Fenster wieder auslese (wie unten in dem auskommentierten Code), dann krieg ich andere Werte für Breite und Höhe als sie in width und height stehen. z.B: bei width=640 und height=480 bekomme ich rect.bottom=478 und rect.right=638.<br />
Wieso stimmen die Werte nicht überein und wie fix ich das? <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/1352621</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352621</guid><dc:creator><![CDATA[SuperSizeMe]]></dc:creator><pubDate>Sun, 26 Aug 2007 20:45:49 GMT</pubDate></item><item><title><![CDATA[Reply to ClientSize on Mon, 27 Aug 2007 11:00:07 GMT]]></title><description><![CDATA[<p>Vielleicht weil Du nicht den gleichen Style benutzt:</p>
<pre><code class="language-cpp">DWORD style = WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;

AdjustWindowRect(&amp;size, style, FALSE);
...
windowHandle = CreateWindow(&quot;Window&quot;, title, WS_OVERLAPPEDWINDOW,
                                windowLeft, windowTop, windowWidth, windowHeight, NULL, NULL, GetModuleHandle(NULL), this);
</code></pre>
<p>Du könntest beim CreateWindow &quot;style&quot; übergeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1352884</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352884</guid><dc:creator><![CDATA[Airdamn]]></dc:creator><pubDate>Mon, 27 Aug 2007 11:00:07 GMT</pubDate></item><item><title><![CDATA[Reply to ClientSize on Mon, 27 Aug 2007 11:05:19 GMT]]></title><description><![CDATA[<p>Ich denke auch, dass in beiden Fällen der selbe Stil übergeben werden muss.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1352887</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352887</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 27 Aug 2007 11:05:19 GMT</pubDate></item><item><title><![CDATA[Reply to ClientSize on Mon, 27 Aug 2007 11:50:44 GMT]]></title><description><![CDATA[<p>Aaaaargh! Manchmal hat man echt Tomaten auf den Augen. Genau das wars! Vielen Dank <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1352938</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1352938</guid><dc:creator><![CDATA[SuperSizeMe]]></dc:creator><pubDate>Mon, 27 Aug 2007 11:50:44 GMT</pubDate></item></channel></rss>