散分~~~~来顶者给分~~~~~
怎么使按最大化 窗体的 内容也跟着变化~~?解决者分多给!!! 问题点数:100、回复次数:38Top
1 楼AprilSong(X)回复于 2004-12-02 00:40:40 得分 10
是要实现这个功能么?
http://community.csdn.net/Expert/topic/3524/3524719.xmlTop
2 楼weilexingfu(为了幸福)回复于 2004-12-02 00:45:41 得分 1
我也想知道Top
3 楼AprilSong(X)回复于 2004-12-02 01:02:26 得分 10
或者这个……
http://community.csdn.net/Expert/topic/3607/3607138.xmlTop
4 楼wuxudong82(飞行侠)回复于 2004-12-02 07:45:00 得分 1
upTop
5 楼cindytsai(笨笨的蔡鸟)回复于 2004-12-02 08:14:37 得分 1
五谷丰登Top
6 楼guoxu_009(迟来)回复于 2004-12-02 08:15:51 得分 1
UP。。。。Top
7 楼True1024()回复于 2004-12-02 08:18:47 得分 2
Form Resize 里设置不行吗?Top
8 楼jilong4(凹凹)回复于 2004-12-02 08:20:06 得分 1
顶Top
9 楼gokill(天上的虫子)回复于 2004-12-02 08:24:02 得分 1
upTop
10 楼cindytsai(笨笨的蔡鸟)回复于 2004-12-02 08:27:52 得分 1
十全十美了Top
11 楼zhzhq800204(lazio)回复于 2004-12-02 08:30:21 得分 2
把控件的位置和大小属性设置成窗体大小的百分比就可以了Top
12 楼gg137zeus(分在脚下)回复于 2004-12-02 08:39:40 得分 1
upTop
13 楼creazyfish(梳分头的鱼)回复于 2004-12-02 08:43:19 得分 2
顶,你可以用控件,好象叫什么resize32的Top
14 楼wumylove1234(毁于随)回复于 2004-12-02 08:44:30 得分 2
呵.
.Net就容易些.
不过自已做起来,不过也就是控制百分比而已.Top
15 楼allywin(GYT)回复于 2004-12-02 08:46:10 得分 1
upTop
16 楼mingday(小山)回复于 2004-12-02 08:46:12 得分 2
在form的resize中控件控件的大小就行了Top
17 楼noisy(noisy)回复于 2004-12-02 09:03:54 得分 1
upTop
18 楼True1024()回复于 2004-12-02 09:04:52 得分 1
做出来了效果会很差。Top
19 楼orangezj(橘子)回复于 2004-12-02 09:06:56 得分 1
顶先!Top
20 楼xayzmb(行者)回复于 2004-12-02 09:07:41 得分 1
接分Top
21 楼rossilx(小新)回复于 2004-12-02 09:09:15 得分 2
我有个问题想请教:
Dim Agent1 as string
Dim Info as string
Dim i as integer
i=1
Agent1="A"
Info="Agent" & i
结果Info值为"Agent1"而不是"A" 用什么方式才能解决 让Info值为"A"
谢谢
一定要以"Agent"与i的组合方式负值
请按照我的实例 写出具体的程式代码Top
22 楼pingkwok(凭空倭寇)回复于 2004-12-02 09:40:12 得分 10
看看这个,也许可以帮你
lblTittle.Left = 300
lblTittle.Width = Me.ScaleWidth - 600
dgListData.Left = 300
dgListData.Width = Me.ScaleWidth - 600
dgListData.Top = dgListData.Top
dgListData.Height = Me.ScaleHeight - dgListData.Top - 845
Me.cmdPrint.Left = Me.ScaleWidth - 2830
Me.cmdPrint.Top = Me.ScaleHeight - 695
Me.cmdCancel.Left = Me.ScaleWidth - 1515
Me.cmdCancel.Top = Me.ScaleHeight - 695
Top
23 楼fog(不会就问)回复于 2004-12-02 11:32:56 得分 1
顶Top
24 楼myhgyp(也许是这样的,信不信由你)回复于 2004-12-02 11:44:28 得分 2
我认为这个问题在VB里做得再复杂效果也不一定会好,希望如愿吧Top
25 楼gg137zeus(分在脚下)回复于 2004-12-02 11:49:05 得分 1
upTop
26 楼WallesCai(女人之美,在于蠢得无怨无悔,男人之美,在于撒谎撒得白日见鬼)回复于 2004-12-02 11:56:19 得分 1
顶哦Top
27 楼shanlisong(lisong)回复于 2004-12-02 13:33:34 得分 1
接 分
Top
28 楼True1024()回复于 2004-12-02 13:42:17 得分 1
顶Top
29 楼jackclh(艺海游鱼)回复于 2004-12-02 14:09:07 得分 0
http://community.csdn.net/Expert/topic/3524/3524719.xml可解决这个问题.
顶呀、顶呀,顶呀、顶!Top
30 楼mingday(小山)回复于 2004-12-02 14:17:24 得分 1
upTop
31 楼zhaochengqing(糊涂)回复于 2004-12-02 14:30:38 得分 10
给你下面这个模块:
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
Public Sub ResizeForm(pfrmIn As Form)
Dim FormControl As Control
Dim isVisible As Boolean
Dim StartX, StartY, MaxX, MaxY As Long
Dim bNew As Boolean
If Not bRunning Then
bRunning = True
If FindForm(pfrmIn) < 0 Then
bNew = True
Else
bNew = False
End If
If pfrmIn.Top < 30000 Then
isVisible = pfrmIn.Visible
On Error Resume Next
If Not pfrmIn.MDIChild Then
On Error GoTo 0
' ' pfrmIn.Visible = False
Else
If bNew Then
StartY = pfrmIn.Height
StartX = pfrmIn.Width
On Error Resume Next
For Each FormControl In pfrmIn
If FormControl.Left + FormControl.Width + 200 > MaxX Then
MaxX = FormControl.Left + FormControl.Width + 200
End If
If FormControl.Top + FormControl.Height + 500 > MaxY Then
MaxY = FormControl.Top + FormControl.Height + 500
End If
If FormControl.X1 + 200 > MaxX Then
MaxX = FormControl.X1 + 200
End If
If FormControl.Y1 + 500 > MaxY Then
MaxY = FormControl.Y1 + 500
End If
If FormControl.X2 + 200 > MaxX Then
MaxX = FormControl.X2 + 200
End If
If FormControl.Y2 + 500 > MaxY Then
MaxY = FormControl.Y2 + 500
End If
Next FormControl
On Error GoTo 0
pfrmIn.Height = MaxY
pfrmIn.Width = MaxX
End If
On Error GoTo 0
End If
For Each FormControl In pfrmIn
ResizeControl FormControl, pfrmIn
Next FormControl
On Error Resume Next
If Not pfrmIn.MDIChild Then
On Error GoTo 0
pfrmIn.Visible = isVisible
Else
If bNew Then
pfrmIn.Height = StartY
pfrmIn.Width = StartX
For Each FormControl In pfrmIn
ResizeControl FormControl, pfrmIn
Next FormControl
End If
End If
On Error GoTo 0
End If
bRunning = False
End If
End Sub
Private Function ActualPos(plLeft As Long) As Long
If plLeft < 0 Then
ActualPos = plLeft + 75000
Else
ActualPos = plLeft
End If
End Function
Top
32 楼zhaochengqing(糊涂)回复于 2004-12-02 14:31:43 得分 5
接着上面的
Private 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
FindForm = I
Exit Function
End If
Next I
End If
End Function
Private Function AddForm(pfrmIn As Form) As Long
Dim FormControl As Control
Dim I As Long
ReDim Preserve FormRecord(MaxForm + 1)
FormRecord(MaxForm).Name = pfrmIn.Name
FormRecord(MaxForm).Top = pfrmIn.Top
FormRecord(MaxForm).Left = pfrmIn.Left
FormRecord(MaxForm).Height = pfrmIn.Height
FormRecord(MaxForm).Width = pfrmIn.Width
FormRecord(MaxForm).ScaleHeight = pfrmIn.ScaleHeight
FormRecord(MaxForm).ScaleWidth = pfrmIn.ScaleWidth
AddForm = MaxForm
MaxForm = MaxForm + 1
For Each FormControl In pfrmIn
I = FindControl(FormControl, pfrmIn.Name)
If I < 0 Then
I = AddControl(FormControl, pfrmIn.Name)
End If
Next FormControl
End Function
Private Function FindControl(inControl As Control, inName As String) As Long
Dim I As Long
FindControl = -1
For I = 0 To (MaxControl - 1)
If ControlRecord(I).Parrent = inName Then
If ControlRecord(I).Name = inControl.Name Then
On Error Resume Next
If ControlRecord(I).Index = inControl.Index Then
FindControl = I
Exit Function
End If
On Error GoTo 0
End If
End If
Next I
End Function
Private Function AddControl(inControl As Control, inName As String) As Long
ReDim Preserve ControlRecord(MaxControl + 1)
On Error Resume Next
ControlRecord(MaxControl).Name = inControl.Name
ControlRecord(MaxControl).Index = inControl.Index
ControlRecord(MaxControl).Parrent = inName
If TypeOf inControl Is Line Then
ControlRecord(MaxControl).Top = inControl.Y1
ControlRecord(MaxControl).Left = ActualPos(inControl.X1)
ControlRecord(MaxControl).Height = inControl.Y2
ControlRecord(MaxControl).Width = ActualPos(inControl.X2)
Else
ControlRecord(MaxControl).Top = inControl.Top
ControlRecord(MaxControl).Left = ActualPos(inControl.Left)
ControlRecord(MaxControl).Height = inControl.Height
ControlRecord(MaxControl).Width = inControl.Width
End If
inControl.IntegralHeight = False
On Error GoTo 0
AddControl = MaxControl
MaxControl = MaxControl + 1
End Function
Top
33 楼zhaochengqing(糊涂)回复于 2004-12-02 14:32:08 得分 5
再来
Private Function PerWidth(pfrmIn As Form) As Long
Dim I As Long
I = FindForm(pfrmIn)
If I < 0 Then
I = AddForm(pfrmIn)
End If
PerWidth = (pfrmIn.ScaleWidth * 100) \ FormRecord(I).ScaleWidth
End Function
Private Function PerHeight(pfrmIn As Form) As Single
Dim I As Long
I = FindForm(pfrmIn)
If I < 0 Then
I = AddForm(pfrmIn)
End If
PerHeight = (pfrmIn.ScaleHeight * 100) \ FormRecord(I).ScaleHeight
End Function
Private Sub ResizeControl(inControl As Control, pfrmIn As Form)
On Error Resume Next
Dim I As Long
Dim widthfactor As Single, heightfactor As Single
Dim minFactor As Single
Dim yRatio, xRatio, lTop, lLeft, lWidth, lHeight As Long
yRatio = PerHeight(pfrmIn)
xRatio = PerWidth(pfrmIn)
I = FindControl(inControl, pfrmIn.Name)
If inControl.Left < 0 Then
lLeft = CLng(((ControlRecord(I).Left * xRatio) \ 100) - 75000)
Else
lLeft = CLng((ControlRecord(I).Left * xRatio) \ 100)
End If
lTop = CLng((ControlRecord(I).Top * yRatio) \ 100)
lWidth = CLng((ControlRecord(I).Width * xRatio) \ 100)
lHeight = CLng((ControlRecord(I).Height * yRatio) \ 100)
If TypeOf inControl Is Line Then
If inControl.X1 < 0 Then
inControl.X1 = CLng(((ControlRecord(I).Left * xRatio) \ 100) - 75000)
Else
inControl.X1 = CLng((ControlRecord(I).Left * xRatio) \ 100)
End If
inControl.Y1 = CLng((ControlRecord(I).Top * yRatio) \ 100)
If inControl.X2 < 0 Then
inControl.X2 = CLng(((ControlRecord(I).Width * xRatio) \ 100) - 75000)
Else
inControl.X2 = CLng((ControlRecord(I).Width * xRatio) \ 100)
End If
inControl.Y2 = CLng((ControlRecord(I).Height * yRatio) \ 100)
Else
inControl.Move lLeft, lTop, lWidth, lHeight
inControl.Move lLeft, lTop, lWidth
inControl.Move lLeft, lTop
End If
End Sub
Public Sub SaveFormPosition(pfrmIn As Form)
Dim I As Long
If MaxForm > 0 Then
For I = 0 To (MaxForm - 1)
If FormRecord(I).Name = pfrmIn.Name Then
FormRecord(I).Top = pfrmIn.Top
FormRecord(I).Left = pfrmIn.Left
FormRecord(I).Height = pfrmIn.Height
FormRecord(I).Width = pfrmIn.Width
Exit Sub
End If
Next I
AddForm (pfrmIn)
End If
End Sub
Public Sub RestoreFormPosition(pfrmIn As Form)
Dim I As Long
If MaxForm > 0 Then
For I = 0 To (MaxForm - 1)
If FormRecord(I).Name = pfrmIn.Name Then
If FormRecord(I).Top < 0 Then
pfrmIn.WindowState = 2
ElseIf FormRecord(I).Top < 30000 Then
pfrmIn.WindowState = 0
pfrmIn.Move FormRecord(I).Left, FormRecord(I).Top, FormRecord(I).Width, FormRecord(I).Height
Else
pfrmIn.WindowState = 1
End If
Exit Sub
End If
Next I
End If
End Sub
Top
34 楼starsoulxp(星魂)回复于 2004-12-02 14:53:06 得分 10
在程序的使用中,如果用户点击最大化或调整窗体的时候,窗体的控件依然不变化,非常不好看,所以我将这段源码贴上,供参考!
非常方便!
Option Explicit
Private ObjOldWidth As Long '保存窗体的原始宽度
Private ObjOldHeight As Long '保存窗体的原始高度
Private ObjOldFont As Single '保存窗体的原始字体比
'在调用ResizeForm前先调用本函数
Public Sub ResizeInit(FormName As Form)
Dim Obj As Control
ObjOldWidth = FormName.ScaleWidth
ObjOldHeight = FormName.ScaleHeight
ObjOldFont = FormName.Font.Size / ObjOldHeight
On Error Resume Next
For Each Obj In FormName
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " "
Next Obj
On Error GoTo 0
End Sub
'按比例改变表单内各元件的大小,
'在调用ReSizeForm前先调用ReSizeInit函数
Public Sub ResizeForm(FormName As Form)
Dim Pos(4) As Double
Dim i As Long, TempPos As Long, StartPos As Long
Dim Obj As Control
Dim ScaleX As Double, ScaleY As Double
ScaleX = FormName.ScaleWidth / ObjOldWidth
'保存窗体宽度缩放比例
ScaleY = FormName.ScaleHeight / ObjOldHeight
'保存窗体高度缩放比例
On Error Resume Next
For Each Obj In FormName
StartPos = 1
For i = 0 To 4
'读取控件的原始位置与大小
TempPos = InStr(StartPos, Obj.Tag, " ", vbTextCompare)
If TempPos > 0 Then
Pos(i) = Mid(Obj.Tag, StartPos, TempPos - StartPos)
StartPos = TempPos + 1
Else
Pos(i) = 0
End If
'根据控件的原始位置及窗体改变大
'小的比例对控件重新定位与改变大小
Obj.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX, Pos(3) * ScaleY
Obj.Font.Size = ObjOldFont * FormName.ScaleHeight
Next i
Next Obj
On Error GoTo 0
End Sub
Private Sub Form_Resize()
'确保窗体改变时控件随之改变
Call ResizeForm(Me)
End Sub
Private Sub Form_Load()
'在程序装入时必须加入
Call ResizeInit(Me)
End Sub
Top
35 楼starsoulxp(星魂)回复于 2004-12-02 14:54:12 得分 5
如何根据显示器的分辨率的大小自动调整窗体以及窗体中的控件的大小和位置???- -
****使用方法*****'2003-5-02
'装以下内容放入工程的一个模块中
Option Explicit
Private FormOldWidth As Long
'保存窗体的原始宽度
Private FormOldHeight As Long
'保存窗体的原始高度
'在调用ResizeForm前先调用本函数
Public Sub ResizeInit(FormName As Form)
Dim Obj As Control
FormOldWidth = FormName.ScaleWidth
FormOldHeight = FormName.ScaleHeight
On Error Resume Next
For Each Obj In FormName
Obj.Tag = Obj.Left & " " & Obj.Top & " " & Obj.Width & " " & Obj.Height & " "
Next Obj
On Error GoTo 0
End Sub
'按比例改变表单内各元件的大小,在调用ReSizeForm前先调用ReSizeInit函数
Public Sub ResizeForm(FormName As Form)
Dim Pos(4) As Double
Dim i As Long, TempPos As Long, StartPos As Long
Dim Obj As Control
Dim ScaleX As Double, ScaleY As Double
ScaleX = FormName.ScaleWidth / FormOldWidth
'保存窗体宽度缩放比例
ScaleY = FormName.ScaleHeight / FormOldHeight
'保存窗体高度缩放比例
On Error Resume Next
For Each Obj In FormName
StartPos = 1
For i = 0 To 4
'读取控件的原始位置与大小
TempPos = InStr(StartPos, Obj.Tag, " ", vbTextCompare)
If TempPos > 0 Then
Pos(i) = Mid(Obj.Tag, StartPos, TempPos - StartPos)
StartPos = TempPos + 1
Else
Pos(i) = 0
End If
'根据控件的原始位置及窗体改变大小的比例对控件重新定位与改变大小
Obj.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX, Pos(3) * ScaleY
Next i
Next Obj
On Error GoTo 0
End Sub
'******在你的每一个窗体的load与resize事件中加入代码
Private Sub Form_Load()
Call ResizeInit(Me) '在程序装入时必须加入
End Sub
Private Sub Form_Resize()
Call ResizeForm(Me) '确保窗体改变时控件随之改变
End Sub
Top
36 楼lovelxs(初学)回复于 2004-12-02 15:46:02 得分 1
学习Top
37 楼pweixing(幸运星)回复于 2004-12-02 15:59:28 得分 1
好!Top
38 楼hellotzc(tzc)回复于 2005-01-21 11:46:39 得分 0
我要三分Top




