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

Form stays on lefttop corner

13 views
Skip to first unread message

Peter

unread,
Jan 22, 2005, 11:02:40 AM1/22/05
to
Hello,

My form with Borderstyle set to none and ControlBox and MaximizeBox and
MinimizeBox set to false stays on location 0;0 (topleft)
but I want the form centered to the screen, so I added in the formload event
:
Rectangle screen = Screen.PrimaryScreen.Bounds;

this.Location = new Point((screen.Width - this.Width) / 2,

(screen.Height - this.Height ) / 2);

no result ! the form stays on topleft location 0;0

Is the a solution for this problem ?

thanks

Peter.


Sergey Bogdanov

unread,
Jan 23, 2005, 5:38:36 AM1/23/05
to
It certainly works for WindowsCE devices but not for PocketPC due to the
fact that a window shows as fullscreen. To avoid this limitation you may
position window by yourself:

Load Event Handler
{


Rectangle screen = Screen.PrimaryScreen.Bounds;
this.Location = new Point((screen.Width - this.Width) / 2,
(screen.Height - this.Height ) / 2);

//
// below goes new code
//

this.Capture = true;
IntPtr hwnd = OpenNETCF.Win32.Win32Window.GetCapture();
this.Capture = false;

OpenNETCF.Win32.Win32Window.SetWindowPos(hwnd,
Win32Window.SetWindowPosZOrder.HWND_TOP, this.Location.X,
this.Location.Y, this.Width, this.Height, 0);
}

Hope this help,
Sergey Bogdanov
http://www.sergeybogdanov.com

Peter

unread,
Jan 25, 2005, 8:50:16 AM1/25/05
to
Thanks Sergey,

the code you gave is working on a WinCe 4.2 device.

the code :


>>>Rectangle screen = Screen.PrimaryScreen.Bounds;
>>> this.Location = new Point((screen.Width - this.Width) / 2,
> >>(screen.Height - this.Height ) / 2);

is not working on my wince 4.2 device ! (for a borderless form)

your code and the OpenNet code did the trick.

Kind regards

Peter.


"Sergey Bogdanov" <sergey....@gmail.com> schreef in bericht
news:%23qkvweT...@TK2MSFTNGP12.phx.gbl...

0 new messages