当前位置: 网学 > 编程文档 > VB > 正文

窗体控件大小随窗体大小变化而变化

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/16
下载{$ArticleTitle}原创论文样式

有时窗体变化后,如改变分辨率后控件大小却不能随之改变。手工代码调整实在麻烦,下面的模块实现自动查找窗体上控件并使其改变大小以适应窗体变化。

在Form的Resize事件中调用函数Resize_All就能实现控件自动调整大小,如:

Private Sub Form_Resize()
Dim H, i As Integer
On Error Resume Next
Resize_ALL Me   ''Me是窗体名,Form1,Form2等等都可以

End Sub

在模块中添加以下代码:

Public Type ctrObj
       Name As String
       Index As Long
       Parrent As String
       Top As Long
       Left As Long
       Height As Long
       Width As Long
       ScaleHeight As Long
       ScaleWidth As Long
End Type

Private FormRecord() As ctrObj
Private ControlRecord() As ctrObj
Private bRunning As Boolean
Private MaxForm As Long
Private MaxControl As Long
Private Const WM_NCLBUTTONDOWN = &HA1
Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function ReleaseCapture Lib "USER32" () As Long
Function ActualPos(plLeft As Long) As Long


              If plLeft < 0 Then
                     ActualPos = plLeft + 75000
              Else
                     ActualPos = plLeft
              End If

End Function


Function FindForm(pfrmIn As Form) As Long

       Dim i As Long
       FindForm = -1

              If MaxForm > 0 Then

                            For i = 0 To (MaxForm - 1)

                                          If FormRecord(i).Name = pfrmIn.Name Then
                                           &nbs
  • 上一篇资讯: 浅谈VB编写病毒的思路
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号