重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
窗体在改变大小时会有一个size事件的,在这个事件中写代码获取窗体的高度和宽度再根据窗体的高度和宽度的比例来效果自己的控件的高度宽度比例
成都创新互联服务项目包括信丰网站建设、信丰网站制作、信丰网页制作以及信丰网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,信丰网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到信丰省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
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
Me.Height = My.Computer.Screen.Bounds.Height
Me.Width = My.Computer.Screen.Bounds.Width
这是设置窗体的长宽和屏幕的分辨率一样大小,相当于全屏。
如果Me.WindowState=FormWindowState.Maximized的话,只是单纯的将窗体最大化,但恢复窗口大小后窗体的大小实际上还和原来一样大。
VB.NET的特点
1.真正成为面向对象以及支持继承性的语言。
2.窗体设计器支持可视化继承,并且包含了许多新的特性,比如自动改变窗体大小、资源本地化支持、数据类工具内在支持XML数据。
3.直接建立在.NET的框架结构上,因此开发人员可以充分利用所有.NET平台特性,也可以与其他的.NET语言交互。
4.为Windows应用程序提供了XCOPY部署,开发者不再需要为DLL的版本问题担忧。