我使用这段代码来最大化和恢复我的自定义表单。但是当窗体最大化时,它仍然可以拖动,我使用计时器来拖动窗体。
Private Sub btnMaximize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMaximize.Click, lblTitle.MouseDoubleClick
Dim maximizeHeight As Integer = Screen.PrimaryScreen.WorkingArea.Height
Dim maximizeWidth As Integer = Screen.PrimaryScreen.WorkingArea.Width
Dim maximizeLocation As Point = New Point(0, 0)
Dim fullscreen As Boolean = False
If Me.Height = maximizeHeight Or Me.Width = maximizeWidth Or Me.Location = maximizeLocation Then
fullscreen = True
Else
fullscreen = False
End If
If fullscreen = True Then
Me.Size = New Size(1000, 500)
Me.Left = (Screen.PrimaryScreen.WorkingArea.Width - Me.Width) / 2
Me.Top = (Screen.PrimaryScreen.WorkingArea.Height - Me.Height) / 2
ElseIf fullscreen = False Then
Me.Location = New Point(0, 0)
Me.Size = New Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height)
End If
End Sub
Private Sub pnlBar_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblTitle.MouseDown
MoveTmr.Start()
refpositions()
End Sub
Private Sub MoveTmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles MoveTmr.Tick
Me.Location = oloc - ocur + System.Windows.Forms.Cursor.Position
refpositions()
End Sub
Private Sub pnlBar_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblTitle.MouseUp
MoveTmr.Stop()
refpositions()
End Sub
Private Sub RszTmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles RszTmr.Tick
Me.Size = appSize - curPos + Cursor.Position
refpositions()
End Sub
您可以用代码或可视化方式创建面板,然后放置dock。顶部然后,您可以在窗口的侧面或中间放置一个标签,在窗口的左侧放置一个图片框创建按钮以关闭最小化和最大化或其他按钮,并在上面添加好友代码以通过标题栏移动表单,就像在windows中一样
我使用Mousedown、Mouseup和Mousemove事件来移动我的表单。
Public Class Form1
Private Is_Dragged As Boolean = False
Private M_DownX As Integer
Private M_DownY As Integer
Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
If e.Button = MouseButtons.Left Then
Is_Dragged = True
M_DownX = e.X
M_DownY = e.Y
End If
End Sub
Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp
If e.Button = MouseButtons.Left Then
Is_Dragged = False
End If
End Sub
Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
If Is_Dragged Then
Dim tmp_pnt As Point = New Point()
tmp_pnt.X = Me.Location.X + (e.X - M_DownX)
tmp_pnt.Y = Me.Location.Y + (e.Y - M_DownY)
Me.Location = tmp_pnt
tmp_pnt = Nothing
End If
End Sub
End Class
最大化我的状态。
Private Sub Btn_Main_Max_Click(sender As Object, e As EventArgs) Handles Btn_Main_Max.Click
Static IsAlreadyResized As Boolean
If Not IsAlreadyResized Then
Me.WindowState = FormWindowState.Maximized
IsAlreadyResized = True
Exit Sub
End If
If IsAlreadyResized Then
Me.WindowState = FormWindowState.Normal
IsAlreadyResized = False
End If
End Sub
使:
Dim fullscreen As Boolean = False
一个类变量。
然后编辑此代码以适应您的变量:
Private Sub Mover_Tick(sender As System.Object, e As System.EventArgs) Handles Mover.Tick
If fullscreen = false Then
Dim pt As New Point((Me.Location.X + (MousePosition.X - mPosX)), (Me.Location.Y + (MousePosition.Y - mPosY)))
Me.Location = pt
mPosX = MousePosition.X
mPosY = MousePosition.Y
End If
End Sub
编辑:
还要实现这一点:
Private Sub Title_StartDrag(sender As System.Object, e As MouseEventArgs) Handles Title.MouseDown
mPosX = MousePosition.X
mPosY = MousePosition.Y
If e.Button = Windows.Forms.MouseButtons.Left Then
Mover.Start()
End If
End Sub
Private Sub Title_StopDrag(sender As System.Object, e As MouseEventArgs) Handles Title.MouseUp
Mover.Stop()
End Sub
你也可以说“我”来让事情变得更简单。WindowsState=FormWindowsState。最大化
本文向大家介绍Android 自定义标题栏的实例详解,包括了Android 自定义标题栏的实例详解的使用技巧和注意事项,需要的朋友参考一下 Android 自定义标题栏的实例详解 开发 Android APP 经常会用到自定义标题栏,而有多级页面的情况下还需要给自定义标题栏传递数据。 本文要点: 自定义标题填充不完整 自定义标题栏返回按钮的点击事件 一、代码 这里先介绍一下流程: 1. 创建一个
问题内容: 我希望在Java Swing桌面应用程序中有一个自定义的标题栏。最好的方法是什么?通过在JFrame的构造函数中使用以下代码,可以使用“标题栏”: 但是,如何自定义呢?是否可以覆盖任何 UI委托 ,还是必须从头开始实现自己的标题栏? 我想要类似Lawson Smart Office的东西: 问题答案: 您可以在Substance外观(镜像源)中看到一个示例。在代码中搜索Substanc
问题内容: 我正在尝试在导航栏的中心添加自定义视图,并且正在使用以下代码对其进行测试: 我在视图控制器的viewDidLoad方法中进行设置,但是当我运行程序时,导航栏中似乎没有任何变化。 你能帮我吗? 问题答案: 这可行。初始化时给框架
我试图获得一个带有自定义图标的JFrame,但没有任何效果。下面是我现在看到的Java 11:
我是MPAndroidChart的新手,我想在LineChart的XAxis上实时显示时间。我只想显示传入数据的最后10秒,如下图所示。我的采样频率为25Hz,因此我需要显示250个值才能记录10秒。 但是,我真的不知道该怎么做。我想我必须使用IAxisValueFormatter。 目前,我的传入值被添加到数据集,如下所示: 但也许我需要这样做: 然后创建一个格式化程序,将X值转换为类似“xxx
我正在尝试用PageView在Flutter中实现一个自定义的BottomNavigationBar,用于在同一支架中包含有状态小部件的不同页面之间滑动。 虽然我可以点击navbar并更改页面,但我无法在更改指示所选页面的icon_button的颜色的同时实现pageview滑动手势。我能够完美地使用BottomNavigationBarItem来完成此操作,但我想使用自定义设计。 包含不同Ico