Get location of form client rectangle

  • Thread starter Thread starter Benjamin Lukner
  • Start date Start date
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
 
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
 
Get the client rectangle and convert it to screen coordinates with
ClientToScreen().

Paul T.
 
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
 
Back
Top