Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GetSystemMetrics( SM_CYSIZEFRAME ) is LYING , please explain!

202 views
Skip to first unread message

tillerm...@my-deja.com

unread,
Jan 10, 2001, 6:37:38 PM1/10/01
to
Hi,

This should be really easy to solve for all you
GURUS out there. But it sure is foxing my mind:-

DWORD dwFrameWidth = GetSystemMetrics(
SM_CYSIZEFRAME );

Basically I am using the above function to get
the size of my frames and I am using it in the
following manner so I can always get my client
area to the correct size as follows:-

DWORD dwWindowWidth = SCREEN_WIDTH +
dwFrameWidth * 2;

DWORD dwWindowHeight = SCREEN_HEIGHT +
dwFrameHeight * 2 + dwCaptionHeight;

I am then using the dwWindowWidth and
dwWindowHeight in my CreateWindowEx function thus
always having a client area which =
SCREEN_WIDTH*SCREEN_HEIGHT.

RIGHT?

WRONG!

I've tested this by making my client area 640*480
using above method. But its not making it
640*480, its making it 642*482!!

The reason for this is as follows :-

GetSystemMetrics( SM_CYSIZEFRAME );

is returning 4 as the value for my frames.

Thus for my window I want the width to be
SCREEN_WIDTH + dwFrameWidth * 2 which would =
648 giving me client area of 640.

The problem is that the FRAMES are not 4 but
actually 3!!!

2*3 = 6 taken away from 648 gives me 642 which is
wrong. Why is this function lying to me?

I have even printed my screen , gone in and
measured the window frames by hand and they are
indeed 3 pixels wide. Why the hell is the
function returning 4?

To get around this problem I am at the moment
simply hardcoding :-
DWORD dwWindowWidth = SCREEN_WIDTH +
dwFrameWidth * 2-2;

This is only a temporary solution , I want to
know why it is doing this, so please please help
me find out.

PS Microsoft uses the above method too in their
DirectX samples to get a client area to the
correct size, so dont suggest using
AdjustWindowEx or MoveWindow as alternatives. I
want to use the above, there is nothing wrong
with it in theory.

Thanks in Advance
Iain Girdwood


Sent via Deja.com
http://www.deja.com/

Quixote

unread,
Jan 11, 2001, 12:16:34 PM1/11/01
to
> GetSystemMetrics( SM_CYSIZEFRAME );
>
> is returning 4 as the value for my frames.
>
> Thus for my window I want the width to be
> SCREEN_WIDTH + dwFrameWidth * 2 which would =
> 648 giving me client area of 640.
>
> The problem is that the FRAMES are not 4 but
> actually 3!!!

Are you testing the right type of frame? On my computer, SM_CYSIZEFRAME is
reported as 4, but SM_CYFIXEDFRAME is reported as 3. The former refers to
windows that can be re-sized by the user by dragging with the mouse, the
latter to windows that cannot be re-sized in this manner.

--

Quixote
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)


0 new messages