如何:从Main函数最大化窗口? [英] How to: Maximize window from the Main function?
本文介绍了如何:从Main函数最大化窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的表单的主要功能中,我检查应用程序是否已经运行了
。如果是,我会抛出一个告诉用户的消息框。我想要做的事情也是最大化应用程序,但我无法这样做。
任何人都有这方面的经验。
TIA,
马特
In the main function of my form I check to see if the application is already
running. If it is, I throw up a message box telling the user. What I would
like to do is also maximize the application, but I am unable to do so. Does
anyone have any experience with this.
TIA,
Matt
推荐答案
这不会将窗口设置为最大化,但它具有基本相同的影响。我认为有
Dim ScrnRec As Rectangle
ScrnRec = Screen.PrimaryScreen.Bounds()
Me.Top = ScrnRec .TOP
Me.Left = ScrnRec.Left
Me.Width = ScrnRec.Width
Me.Height = ScrnRec.Height >
您也可以尝试...
Me.WindowState = FormWindowState.Maximized
This won''t set the window to maximized, but it has
basically the same affect. I think there is
Dim ScrnRec As Rectangle
ScrnRec = Screen.PrimaryScreen.Bounds()
Me.Top = ScrnRec.Top
Me.Left = ScrnRec.Left
Me.Width = ScrnRec.Width
Me.Height = ScrnRec.Height
You could also try...
Me.WindowState=FormWindowState.Maximized
-----原始讯息-----
在我的表单的主要功能中,我检查
应用程序是否是alreadyrunning。如果是的话,我会抛出一个告诉
用户的消息框。我想做的也是最大化应用程序,但我是
无法这样做。任何人都有这方面的经验。
TIA,
Matt
。
-----Original Message-----
In the main function of my form I check to see if the application is alreadyrunning. If it is, I throw up a message box telling the user. What I wouldlike to do is also maximize the application, but I am unable to do so. Doesanyone have any experience with this.
TIA,
Matt
.
试试这个:
this.WindowState = FormWindowState.Maximiz
但是你不能从Main那里做 - 使用构造函数或者OnLoad事件或
无论什么
" MJB" < mb*@email.com>在留言中写道
news:OR ************** @ TK2MSFTNGP10.phx.gbl ...
try this:
this.WindowState = FormWindowState.Maximiz
but you cant do it from Main - use the constructor or or the OnLoad event or
whatever
"MJB" <mb*@email.com> wrote in message
news:OR**************@TK2MSFTNGP10.phx.gbl...
在主要功能中我的表单我检查应用程序是否已经运行
。如果是,我会抛出一个告诉用户的消息框。我b $ b想要做的也是最大化应用程序,但我无法这样做。
有没有人有这方面的经验。
TIA,
Matt
In the main function of my form I check to see if the application is already running. If it is, I throw up a message box telling the user. What I would like to do is also maximize the application, but I am unable to do so. Does anyone have any experience with this.
TIA,
Matt
我假设您将杀死第二个实例并激活第一个实例,
如果是这样,您只需调用SetActiveWindow API:
[DllImport(" user32.dll")]
IntPtr SetActiveWindow(IntPtr hWnd);
这个诀窍。
你需要第一个应用程序的hWnd,如果你需要代码让它让我知道。
希望这个帮助,
-
Ignacio Machin,
ignacio.machin at dot.state.fl.us >
佛罗里达州交通局
" MJB" < mb*@email.com>在留言中写道
news:OR ************** @ TK2MSFTNGP10.phx.gbl ...
Hi,
I assume that you will kill the second instance and activate the first one,
if so all you have to do is call SetActiveWindow API:
[DllImport("user32.dll")]
IntPtr SetActiveWindow( IntPtr hWnd);
This will do the trick.
You need the hWnd of the first app, if you need code to get it let me know.
Hope this help,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"MJB" <mb*@email.com> wrote in message
news:OR**************@TK2MSFTNGP10.phx.gbl...
在主要功能中我的表单我检查应用程序是否已经运行
。如果是,我会抛出一个告诉用户的消息框。我b $ b想要做的也是最大化应用程序,但我无法这样做。
有没有人有这方面的经验。
TIA,
Matt
In the main function of my form I check to see if the application is already running. If it is, I throw up a message box telling the user. What I would like to do is also maximize the application, but I am unable to do so. Does anyone have any experience with this.
TIA,
Matt
这篇关于如何:从Main函数最大化窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文