vb生成的界面随电脑分辨率变化方法,下面的程序为热心网友提供,但是运行时提示“编译错误:未找到数据或方法
Public Sub chang(ThisForm As Form)
Dim DesignX As Integer
Dim DesignY As Integer
Dim XFactor As Single
Dim YFactor As Single
Dim X As Integer
DesignX% = 1400: DesignY% = 900
XFactor = (Screen.Width / Screen.TwipsPerPixe1X) / DesignX
YFactor = (Screen.Height / Screen.TwipsPerPixe1Y) / DesignY
If XFactor = 1 And YFactor = 1 Then
Exit Sub
With ThisForm
.Move .Left * XFactor, .Top * YFactor, .Width * XFactor, .Height * YFactor
For X = 0 To .Controls.Count - 1
If TypeOf .Controls(X) Is DriveListBox Then
.Controls(X).Move .Controls(X).Left * XFactor, .Controls(X).Top * XFactor, .Controls(X).Width * XFactor
ElseIf TypeOf .Controls(X) Is ComboBox Then
If T.Controls(X).Style <> 1 Then
.Controls(X).Move .Controls(X).Left * XFactor, .Controls(X).Top * XFactor, .Controls(X).Width * XFactor
End If
Else
.Controls(X).Move .Controls(X).Left * XFactor, .Controls(X).Top * XFactor, .Controls(X).Width * XFactor, .Controls(X).Height * YFactor
If TypeOf .Controls(X) Is TextBox Then
.Controls(X).FontSize = .Controls(X).FontSize * XFactor
ElseIf TypeOf .Controls(X) Is Label Then
.Contr ols(X).FontSize = .Controls(X).FontSize * XFactor
End If
End If
Next X
End With
End Sub
引用是这样的:
Private Sub Command15_Click()
Load Form10
Call chang(Form10)
Form10.Show
End Sub
打开方法就是将图面另存后,再更改扩展名为rar ,解压就可以了.
我先试了一下,要下班了,你将分辩率改小到 1440X900以下试一下看看,是不是有效果了,我电脑的分辩率是1132X842.
如果你还有控件,按照模块里面的示例再改.
我下班了,回家后再帮你测试.
[解决办法]
我在家里试了一下。我改过的工程可以用.效果还不错。我家里是23"显示器。分辩率:1280X960
我改过的工程就是我的那个图面另存下来改后缀为rar.用rar解压就行了.