Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

GetWindowRect returns what?
According to all articles about GetWindowRect it returns positon relative to
"upper left corner". However, when I try MoveWindow into this position it
does not move into area advertized.
What am I missing?



Report this thread to moderator Post Follow-up to this message
Old Post
Vaclav
05-30-05 01:55 AM


RE: GetWindowRect returns what?
The GetWindowRect function retrieves the dimensions of the bounding rectangl
e
of the specified window. The dimensions are given in screen coordinates that
are relative to the upper-left corner of the screen.

If you are moving to return value of GetWindowRect then you are moving the
window to the same place.  What are your cordinates? (0,0) should be top lef
t
of desktop.  Watch out for task bars at top of desktop!  I hate it when
windows hide them selves under the task bar.

"Vaclav" wrote:

> According to all articles about GetWindowRect it returns positon relative 
to
> "upper left corner". However, when I try MoveWindow into this position it
> does not move into area advertized.
> What am I missing?
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
Terry
05-30-05 01:55 AM


RE: GetWindowRect returns what?

"Terry" wrote:

> The GetWindowRect function retrieves the dimensions of the bounding rectan
gle
> of the specified window. The dimensions are given in screen coordinates th
at
> are relative to the upper-left corner of the screen.
>
> If you are moving to return value of GetWindowRect then you are moving the
> window to the same place.  What are your cordinates? (0,0) should be top l
eft
> of desktop.  Watch out for task bars at top of desktop!  I hate it when
> windows hide them selves under the task bar.
>
> "Vaclav" wrote:
> 


Here is my test code .
Basically I have two CStatic "objects" in the CFormView - created in
associated
dialog.
I want to move them together, side by side.
I can get the CDC pointer and can draw a test line from upper left corner to
the lower right corner using eitherGetClientRect or GetWindowRect( followed
by ScreenToClient).
Both of these "methods" apparently set the object window origin to upper
left corner of the objects.

GetWindowRect retruns what appears to be relative coordinates at random
origin, but they are the dimensions of the objects!
I am using
m_test.GetWindowRect(&rect1);
without using
m_test.ScreenToClient(&rect1);

When I use MoveWindow on m_test object it moves into these coorinates which
ARE NOT correct.
I must be doing something wrong!







. Either 
CBrush brush(RGB(255,0,0));
CPen pen(PS_SOLID,10,RGB(0,0,0));
CPen pen1(PS_SOLID,5,RGB(255,0,0));

CDC *pDC = m_test.GetDC();
m_test.GetClientRect(&rect);
/*
m_test.GetWindowRect(&rect1);
m_test.ScreenToClient(&rect1);

pDC->SelectObject(pen);
pDC->MoveTo(rect.left,rect.top);
pDC->LineTo(rect.right,rect.bottom);


pDC->SelectObject(pen1);
pDC->MoveTo(rect1.left,rect1.top);
pDC->LineTo(rect1.right,rect1.bottom);
*/
//CPen pen1(PS_SOLID,2,RGB(0,255,0));

CDC *pDC1 = m_test1.GetDC();
pDC1->SelectObject(pen1);

//	m_test1.GetClientRect(&rect1);

m_test1.GetWindowRect(&rect2);
m_test1.ScreenToClient(&rect2);

pDC1->MoveTo(rect1.left,rect1.top);
pDC1->LineTo(rect2.right,rect2.bottom);





Report this thread to moderator Post Follow-up to this message
Old Post
Vaclav
05-30-05 08:55 AM


Re: GetWindowRect returns what?
"Vaclav" <Vaclav@discussions.microsoft.com> wrote in message
news:65E08BE2-8D47-4C5F-81B9-2464F42F0F13@microsoft.com...
> Here is my test code .
> Basically I have two CStatic "objects" in the CFormView - created in
> associated
> dialog.
> I want to move them together, side by side.
> I can get the CDC pointer and can draw a test line from upper left corner
to
> the lower right corner using eitherGetClientRect or GetWindowRect(
followed
> by ScreenToClient).
> Both of these "methods" apparently set the object window origin to upper
> left corner of the objects.
>
> GetWindowRect retruns what appears to be relative coordinates at random
> origin, but they are the dimensions of the objects!
> I am using
> m_test.GetWindowRect(&rect1);
> without using
> m_test.ScreenToClient(&rect1);
>
> When I use MoveWindow on m_test object it moves into these coorinates
which
> ARE NOT correct.
> I must be doing something wrong!

My guess is that after calling m_test.GetWindowRect you need to then call
the parent CFormView's ScreenToClient before calling m_test.MoveWindow.

--
Jeff Partch [VC++ MVP]




Report this thread to moderator Post Follow-up to this message
Old Post
Jeff Partch [MVP]
05-30-05 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

MSDN archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:36 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.