VB 如何在运行时在控件内加载控件
比如在运行时在一个图片框内加载一个图片框事实上A框就是用控件数组加载上去的,所以。。。。。。而且即使A框本来有B框,但控件数组加载的A框也是没有B框的...
比如在运行时在一个图片框内加载一个图片框
事实上A框就是用控件数组加载上去的,所以。。。 。。。
而且即使A框本来有B框,但控件数组加载的A框也是没有B框的 展开
事实上A框就是用控件数组加载上去的,所以。。。 。。。
而且即使A框本来有B框,但控件数组加载的A框也是没有B框的 展开
展开全部
你想要在A图片框里加载B 你不如在写程序时 直接拖个B图片框放在A里 B的visible属性设置为false 就好了 你想什么时候加载B 就让visible=true 不就好了
或者 动态加载Picture控件组数
添加一个按钮 一个picturebox 控件name属性改为PicZu index属性为0
点按钮一次会添加图片框 点第二次会删除添加
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Sub Command1_Click()
If PicZu.Count > 1 Then
For i = 1 To 2
Unload PicZu(i)
Next
Exit Sub
End If
For i = 1 To 2
Load PicZu(i)
PicZu(i).Visible = True
PicZu(i).Height = PicZu(0).Height - 400 * i
PicZu(i).Width = PicZu(0).Width - 400 * i
ncl = SendMessage(PicZu(i).hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
PicZu(i).Move PicZu(0).Left + 100, PicZu(0).Top + 200
PicZu(i).Picture = LoadPicture("d:\" & i & ".jpg")'加载图片
Next
End Sub
========================这样应该可以了吧???
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Sub Command1_Click() '在A框加载B框
Load Picture1(4)
Picture1(2).Print "a"
Picture1(4).Visible = True
Picture1(4).Height = Picture1(2).Height - 400
Picture1(4).Width = Picture1(2).Width - 400
ncl = SendMessage(Picture1(4).hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
Picture1(4).Move Picture1(2).Left + 100, Picture1(2).Top + 100
Me.Show
Picture1(4).Print "b"
End Sub
Private Sub Command2_Click() '创建pic数组包含A框,假设2为A框
For i = 1 To 3
Load Picture1(i)
Picture1(i).Visible = True
Picture1(i).Height = Picture1(0).Height
Picture1(i).Width = Picture1(0).Width
Picture1(i).Move Picture1(i).Width * i * 1.1 + Picture1(i).Left, Picture1(0).Top
Next i
End Sub
Private Sub Form_Load()
With Picture1(i)
.Width = 1695
.Top = 120
.ScaleWidth = 1635
.ScaleHeight = 915
.Left = 120
.Height = 1000
End With
Command2.Caption = "先点"
Command1.Caption = "后点"
End Sub
或者 动态加载Picture控件组数
添加一个按钮 一个picturebox 控件name属性改为PicZu index属性为0
点按钮一次会添加图片框 点第二次会删除添加
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Sub Command1_Click()
If PicZu.Count > 1 Then
For i = 1 To 2
Unload PicZu(i)
Next
Exit Sub
End If
For i = 1 To 2
Load PicZu(i)
PicZu(i).Visible = True
PicZu(i).Height = PicZu(0).Height - 400 * i
PicZu(i).Width = PicZu(0).Width - 400 * i
ncl = SendMessage(PicZu(i).hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
PicZu(i).Move PicZu(0).Left + 100, PicZu(0).Top + 200
PicZu(i).Picture = LoadPicture("d:\" & i & ".jpg")'加载图片
Next
End Sub
========================这样应该可以了吧???
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Sub Command1_Click() '在A框加载B框
Load Picture1(4)
Picture1(2).Print "a"
Picture1(4).Visible = True
Picture1(4).Height = Picture1(2).Height - 400
Picture1(4).Width = Picture1(2).Width - 400
ncl = SendMessage(Picture1(4).hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
Picture1(4).Move Picture1(2).Left + 100, Picture1(2).Top + 100
Me.Show
Picture1(4).Print "b"
End Sub
Private Sub Command2_Click() '创建pic数组包含A框,假设2为A框
For i = 1 To 3
Load Picture1(i)
Picture1(i).Visible = True
Picture1(i).Height = Picture1(0).Height
Picture1(i).Width = Picture1(0).Width
Picture1(i).Move Picture1(i).Width * i * 1.1 + Picture1(i).Left, Picture1(0).Top
Next i
End Sub
Private Sub Form_Load()
With Picture1(i)
.Width = 1695
.Top = 120
.ScaleWidth = 1635
.ScaleHeight = 915
.Left = 120
.Height = 1000
End With
Command2.Caption = "先点"
Command1.Caption = "后点"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询