如何在c#windows应用程序中最大化windowstate时在屏幕中心显示表单 [英] how to show form in the center of screen when windowstate in maximized in c# windows application

查看:398
本文介绍了如何在c#windows应用程序中最大化windowstate时在屏幕中心显示表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I´ve got a form which maximum size is 300x300 pixels.
It can be resized and maximized. The problem:

If the user sets the window state to maximized, the forms location
is set to 0,0. Changing the Location property doesn´t help.

Is it possible to center it on the screen even if maximized?
And if yes, how is it done?



Plz帮助我紧急。


Plz Help Me It''s Urgent.

推荐答案

try this code.
<pre lang="Javascript">
function MyPopUpWin() {
var iMyWidth;
var iMyHeight;
//half the screen width minus half the new window width (plus 5 pixel borders).
iMyWidth = (window.screen.width/2) - (75 + 10);
//half the screen height minus half the new window height (plus title and status bars).
iMyHeight = (window.screen.height/2) - (100 + 50);
//Open the window.
var win2 = window.open("filename.htm","Window2","status=no,height=200,width=150,resizable=yes,left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
win2.focus();
}</pre>


您好b $ b

您可以使用以下代码:



Hi
You can use from bellow code:

-------------------------------------------------------------------------------------
this.Location = new System.Drawing.Point(ScreenLen - WinLen, ScreenHeigh - WinHeigh);





并注意以下链接:

http://stackoverflow.com/questions/5082610/get - 并设置屏幕分辨率 [ ^ ]



http://stackoverflow.com/questions/10828179/how-to-get-the-resolution-of-screen-for-a-winrt-app [ ^ ]


你好朋友

i认为有一个像默认窗口布局的属性。将此属性设置为true。

我认为它可以帮助你。
hello friend
i think there is a property like default window layout. set this property to true.
i think it helps you.


这篇关于如何在c#windows应用程序中最大化windowstate时在屏幕中心显示表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆