检测 WindowState 是否被捕捉 [英] Detect if WindowState is snapped
问题描述
因此,有一种方法可以将事物一半"最大化,(当您将表单拖到屏幕一侧时,它会填满一半,而在 Windows 10 中,您可以填满屏幕的四分之一.)如何我们能检测到吗?
So, there is a way to "Half" maximize things, (when you drag a form to the side of your screen it fills it up with half, and in Windows 10 you can fill a quarter of the screen.) how can we detect that?
If WindowState = FormWindowState.Normal Then My.Settings.Size = Size
该代码在其一半最小化/四分之一时运行.如何检测其他最大化"状态?
That code runs when its half minimized/quarter. How can I detect the other "maximized" states?
推荐答案
我想你必须计算一下.
If me.width = Screen.PrimaryScreen.Bounds.Width / 2 And me.left = 0 Then
'code
End If
为每个可能的选项创建一些检查,然后将其放入一个返回 Enum 的函数中应该不会那么难
shouldnt be that hard to create some checks for every possible option and then put it in a function that returns a Enum like
Enum snap As Integer
isLeft
isRigh
isTop
isBotton
NoSnapDetected
End Enum
相同的方向 - 当您想将窗口设置为该大小/点时
same goes the different direction - when you wanna set your window to that size/point
这篇关于检测 WindowState 是否被捕捉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!