包含vbnet改自适应的词条
vb.net 怎样将窗体和所有控件根据电脑分辨率固定?
使用SplitContainer1控件不就行了,SplitContainer1控件的Fixedpanel属性设置为Panel1\x0d\x0aSplitContainer1的Panel2里面再放置一个SplitContainer2\x0d\x0aSplitContainer2控件的Fixedpanel属性设置为Panel2\x0d\x0a二个SplitContainer设置为水平折为器方向\x0d\x0a至于播放器控件就放在SplitContainer2控件Panel1里面\x0d\x0a播放器控件DOCK设置为FILL\x0d\x0a\x0d\x0a这样不管放大缩小界面,播放器控件总是自适应窗体大小而菜单按钮总是在最边缘
创新互联是专业的盘州网站建设公司,盘州接单;提供网站制作、成都做网站,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行盘州网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
vb.net 如何使得控件随着窗体大小 的改变而改变呢,大家帮忙给想想,最好有代码的哦
Public Class Form1
Dim 初始化控件自动大小调整与窗口的宽度比例 As Integer
Dim 初始化控件自动大小调整与窗口的高度比例 As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
初始化控件自动大小调整与窗口的宽度比例 = Me.Width / 控件自动大小调整.Width
初始化控件自动大小调整与窗口的高度比例 = Me.Height / 控件自动大小调整.Height
显示控件的位置坐标()
End Sub
Private Sub Form1_ResizeEnd(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ResizeEnd
' Form1_ResizeEnd 这个事件是 窗口大小变化完成后 再进行操作的
控件自动大小调整.Location = New Point(控件自动大小调整.Left, 控件自动大小调整.Top)
'设置控件的初始左位置坐标 与 上位置坐标
控件自动大小调整.Size = New Point(Int(Me.Width / 初始化控件自动大小调整与窗口的宽度比例), Int(Me.Height / 初始化控件自动大小调整与窗口的高度比例))
'更改控件的大小 按第一次窗口的比例 进行调整
显示控件的位置坐标()
End Sub
Private Sub 显示控件的位置坐标()
Label1.Text = "控件的上边距坐标: " 控件自动大小调整.Top
Label2.Text = "控件的左边距坐标: " 控件自动大小调整.Left
Label3.Text = "控件的宽度大小: " 控件自动大小调整.Width
Label4.Text = "控件的高度大小: " 控件自动大小调整.Height
End Sub
End Class
还有好多方法 慢慢研究吧兄弟 希望能帮到你
VB 窗体控件分辨率自适应问题
Public Type CONTROLRECT Left As Single Top As Single Width As Single Height As SingleEnd Type Public Const HORZRES = 8Public Const VERTRES = 10Public Declare Function GetDesktopWindow Lib "user32" () As LongPublic Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As LongPublic Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As LongPublic Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long '取得界面原始控件的位置及大小,并保存到数组里Public Sub GetSourcePos(this As Object, rc() As CONTROLRECT, Optional bigFont As Boolean = True)
'On Error Resume Next
Dim tempX As Integer, tempY As IntegertempX = this.ScaleWidth '1024tempY = this.ScaleHeight '768 '此处原来如果在1024*768分辨率下显示正常的话,就可以直接赋值1024和768 Dim temp As Control Dim nSum As Integer nSum = 0 For Each temp In this '此处要注意,有些控件没有width,height等属性,在此要做出判断 If TypeOf temp Is ComboBox Then With rc(nSum) .Left = temp.Left / tempX .Width = temp.Width / tempX .Top = temp.Top / tempY End With ElseIf TypeOf temp Is Timer Then' 'none' ElseIf TypeOf temp Is StatusBar Then' 'none Else With rc(nSum) .Left = temp.Left / tempX .Width = temp.Width / tempX .Top = temp.Top / tempY .Height = temp.Height / tempY End With End If nSum = nSum + 1 NextEnd Sub '根据比例调整控件的大小Public Sub SetNewPos(this As Object, rc() As CONTROLRECT)
'On Error Resume Next Dim tempX As Integer, tempY As Integer tempX = this.ScaleWidth '1024 tempY = this.ScaleHeight '768 ' '如果初始界面显示始终是以最大化的方式显示的话,此处就可以调用系统分辨率进行设置tempx,tempy' hwnd = GetDesktopWindow()' ' Get the device context for the desktop' hdc = GetWindowDC(hwnd)' If hdc Then' Dim a As Long, b As Long' a = GetDeviceCaps(hdc, HORZRES)' b = GetDeviceCaps(hdc, VERTRES)' tempX = a' tempY = b' End If' ReleaseDC hwnd, hdc Dim temp As Control '//用于取各种控件 Dim nSum As Integer nSum = 0 For Each temp In this '此处要注意,有些控件没有width,height等属性,在此要做出判断 If TypeOf temp Is ComboBox Then temp.Left = rc(nSum).Left * tempX temp.Width = rc(nSum).Width * tempX temp.Top = rc(nSum).Top * tempY ElseIf TypeOf temp Is Timer Then 'none 'ElseIf TypeOf temp Is StatusBar Then 'none Else temp.Left = rc(nSum).Left * tempX temp.Width = rc(nSum).Width * tempX temp.Top = rc(nSum).Top * tempY temp.Height = rc(nSum).Height * tempY End If nSum = nSum + 1 Next End Sub
VB窗体控件自动适应窗体大小
Dim f_size(1) As Long, fist_re As Boolean '用来存放窗体默认大小 以及 是否第一次初始化,全局变量,可在 模块中public声明
Private Sub Form_Resize()
If Me.WindowState 1 Then '必须排除最小化的状态
If fist_re = False Then '窗体初始化只记录窗体大小
f_size(0) = Me.Height: f_size(1) = Me.Width
fist_re = True
Else '否则开始适应屏幕变化
For Each a In Form1.Controls
On Error Resume Next
a.Width = a.Width * (Me.Width / f_size(1))
a.Height = a.Height * (Me.Height / f_size(0))
a.Top = a.Top * (Me.Height / f_size(0))
a.Left = a.Left * (Me.Width / f_size(1))
Next
f_size(0) = Me.Height: f_size(1) = Me.Width '重新记录窗口大小,用于下次运算
End If
End If
End Sub
''对于一些控件 如listbox的高度不适宜 呵呵
VS2013 VB.NET窗口控件怎么做自适应
窗体在改变大小时会有一个size事件的,在这个事件中写代码获取窗体的高度和宽度再根据窗体的高度和宽度的比例来效果自己的控件的高度宽度比例
VB.net TreeView 展开节点自适应宽度
'控制树状选单自动调整宽度
Private Sub tvMenu_AfterExpand(sender As Object, e As TreeViewEventArgs) Handles tvMenu.AfterExpand, tvMenu.AfterCollapse
Dim iMaxWidth As Integer = 0
For Each tn As TreeNode In tvMenu.Nodes
Dim iCurPos As Integer = tn.Bounds.X
Dim iCurWidth As Integer = iCurPos + tn.Bounds.Width
If tn.IsExpanded Then
iCurWidth = GetTreeViewMaxWidth(tn)
End If
If iMaxWidth iCurWidth Then
iMaxWidth = iCurWidth
Me.gbMenu.Width = iCurPos + iMaxWidth
End If
Next
End Sub
'取得目前树状选单节点下展开的最大宽度
Private Function GetTreeViewMaxWidth(tn As TreeNode) As Integer
Dim iMaxWidth As Integer = 0
For Each tnItem As TreeNode In tn.Nodes
Dim iCurPos As Integer = tnItem.Bounds.X
Dim iCurWidth As Integer = iCurPos + tnItem.Bounds.Width
If tnItem.IsExpanded Then
iCurWidth = GetTreeViewMaxWidth(tnItem)
End If
If iMaxWidth iCurWidth Then
iMaxWidth = iCurWidth
End If
Next
Return iMaxWidth
End Function
网页题目:包含vbnet改自适应的词条
网站URL:http://cdiso.cn/article/dscijpi.html