Get location of form client rectangle

B

Benjamin Lukner

Hi all!

I have to get the upper left corner of the client rectangle in relation
to the upper left corner of the WinCE form in order to call
SetWindowRgn() correctly. Is there an easy way to do it? GetClientRect()
returns by definition 0;0 though it is e.g. 4;23 on an NT-style Windows
XP. I made up several ways that mostly only work in Full Framework but
not in Compact Framework:

1.
- Declare GetWindowInfo() and GetTitleBarInfo()
- Call them
- Location = New Point(WindowInfo.cxWindowBorders, _
WindowInfo.cyWindowBorders + oTitleBarInfo.rcTitleBar.Height)
-> CE does not have these two functions implemented

2.
- Create MyPanel at 0;0
- Declare ClientToScreen()
- New Point (0,0)
- ClientToScreen(MyPanel.Handle, Point)
- Location = Point.Offset(-Me.Left,-Me.Top)
-> CF does not allow to retreive the Handle of a control

3.
- Location = New Point((Me.Width-Me.ClientSize.Width)\2, _
Me.Height-Me.ClientSize.Height-((Me.Width-Me.ClientSize.Width)\2))
-> This assumes that the bottom (Y) border is the same width as the left
and right (X) border.


What is the suggested way to retreive the client location on Windows CE?

Kind regards,

Benjamin Lukner
 
B

Benjamin Lukner

I'd just P/Invoke GetWindowRect

Hi Chris,

that's not what I'm looking for...
I need the CLIENT rectangle in SCREEN coordinates.

Kind regards,

Benjamin
 
P

Paul G. Tobey [eMVP]

Get the client rectangle and convert it to screen coordinates with
ClientToScreen().

Paul T.
 
B

Benjamin Lukner

Paul said:
Get the client rectangle and convert it to screen coordinates with
ClientToScreen().

Hi Paul,

ARGH! I was just up to write that that's not what I wanted but now I've
found my error in reasoning and was able to work out the solution. :)

The upper left corner of the client coordinates is by definition (0;0).
So I thought this doesn't help. But it's that easy:


Dim ClientLocation As Point = Me.PointToScreen(Point.Empty)
ClientLocation.Offset(-Me.Left, -Me.Top)


That's the code I was looking for all the time. The upper left corner of
the client rectangle in relation to the upper left corner of the form.
Normally this is (1;24) on Windows CE devices.

Thanks for the food for thought!

Benjamin Lukner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top