vb控件怎么删除与添加

时间:2013-03-14 03:34来源:未知 作者:admin 点击:

标签:vb控件怎么删除与添加
VB本身不提供控件的添加与删除操作的(除非控件数组) 可以利用Windows API来完成这些操作: Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As
vb控件怎么删除与添加》文章地址:http://www.tfxk.com/zixun_shenghuo/03143501H013.htm
VB本身不提供控件的添加与删除操作的(除非控件数组)
可以利用Windows API来完成这些操作:
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, ByVal lpParam As Long) As Long

Dim h As Long

Private Sub Command1_Click()
h = CreateWindowEx(0, "BUTTON", "Saar Window", &H50000000, 0, 0, 100, 100, Me.hwnd, 0, App.hInstance, 0)
Debug.Print h
End Sub

Private Sub Command2_Click()
DestroyWindow h
End Sub

上面这种方法可以从内存中直接删除控件对象,如果无须进行内存删除操作的话,可以直接使用VB里控件自带的方法显示和隐藏控件
显示:控件名.Show
隐藏:控件名.Hide

补充回答: Sorry,第二点我说错了,VB自带的方法应该是 控件名.Visible = True 是显示, 控件名.Visible = False 是隐藏
(责任编辑:网站建设)
vb控件怎么删除与添加相关文章
上一篇:电饭锅怎么用 下一篇:BIOS升级失败怎么处理??
回到顶部