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

CStatic GetClientRect, SetWindowPos weirdness...

207 views
Skip to first unread message

TomCooper

unread,
Jan 14, 2008, 8:20:02 AM1/14/08
to
If I call this function and pass in a CStatic with a static edge, it shrinks
the window by 2 pixels each time.

It works fine without a static edge.

Can anyone explain why?

The function Weirdness is trimmed down icon moving function, I'm not really
trying to set an icon to the postion it is already in.

Cheers,

Tom

void CMyWindow::Weirdness(CWnd& window)
{
CRect rect;
window.GetClientRect(&rect);
window.ClientToScreen(&rect);
ScreenToClient(&rect);

int height = rect.Height();

window.SetWindowPos(0, rect.left, rect.top, rect.Width(), rect.Height(),
SWP_NOACTIVATE | SWP_NOZORDER );
}

Scott McPhillips [MVP]

unread,
Jan 14, 2008, 9:51:32 AM1/14/08
to
"TomCooper" <TomC...@discussions.microsoft.com> wrote in message
news:25B1EDEB-CA8F-457D...@microsoft.com...

GetClientRect gets the inside of the window, its 'client' area inside any
border. But SetWindowPos sets the outside of the window. Try changing from
GetClientRect to GetWindowRect.

--
Scott McPhillips [VC++ MVP]

David Webber

unread,
Jan 14, 2008, 9:54:50 AM1/14/08
to

"TomCooper" <TomC...@discussions.microsoft.com> wrote in message
news:25B1EDEB-CA8F-457D...@microsoft.com...

> If I call this function and pass in a CStatic with a static edge, it

> shrinks
> the window by 2 pixels each time.
>
> It works fine without a static edge.
>
> Can anyone explain why?
>

> The function Weirdness....

No weirdness here:

> window.GetClientRect(&rect);
> window.ClientToScreen(&rect);
> ScreenToClient(&rect);
>
> int height = rect.Height();
>
> window.SetWindowPos(0, rect.left, rect.top, rect.Width(), rect.Height(),
> SWP_NOACTIVATE | SWP_NOZORDER );

You're getting the client area and setting the full window size to be what
its client area previously was. And it appears to be working perfectly :-)

Check out GetWindowRect()

Isn't it a pain that computers never do what you want, but rather they do
what you tell them to? :-)

Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm


0 new messages