Visual Basic下工具条的制作之六
2008-02-23 07:04:27来源:互联网 阅读 ()
下面给出窗体form1的程序代码。 private sub form_load()
’ create object variable for the imagelist.
dim imgx as listimage
’ load pictures into the imagelist control.
set imgx = imagelist1.listimages. _
add(, "open", loadpicture("graphics\bitmaps\tlbr_w95\open.bmp"))
set imgx = imagelist1.listimages. _
add(, "save", loadpicture("graphics\bitmaps\tlbr_w95\save.bmp"))
toolbar1.imagelist = imagelist1
’ create object variable for the toolbar.
dim btnx as button
’ add button objects to buttons collection using the
’ add method. after creating each button, set both
’ description and tooltiptext properties.
toolbar1.buttons.add , , , tbrseparator
set btnx = toolbar1.buttons.add(, "open", , tbrdefault, "open")
btnx.tooltiptext = "open file"
btnx.description = btnx.tooltiptext
set btnx = toolbar1.buttons.add(, "save", , tbrdefault, "save")
btnx.tooltiptext = "save file"
btnx.description = btnx.tooltiptext
set btnx = toolbar1.buttons.add(, , , tbrseparator)
’ the next button has the placeholder style. a
’ combobox control will be placed on top of this button.
set btnx = toolbar1.buttons.add(, "combo1", , tbrplaceholder)
btnx.width = 1500 ’ placeholder width to accommodate a combobox.
show ’ show form to continue configuring combobox.
’ configure combobox control to be at same location as the
’ button object with the placeholder style (key = "combo1").
with combo1
.width = toolbar1.buttons("combo1").width
.top = toolbar1.buttons("combo1").top
.left = toolbar1.buttons("combo1").left
.additem "black" ’ add colors for text.
.additem "blue"
.additem "red"
.listindex = 0
end with
end sub
private sub form_resize()
’ configure combobox control.
with combo1
.width = toolbar1.buttons("combo1").width
.top = toolbar1.buttons("combo1").top
.left = toolbar1.buttons("combo1").left
end with
end sub
private sub toolbar1_buttonclick(byval button as button)
’ use the key property with the selectcase statement to specify
’ an action.
select case button.key
case is = "open" ’ open file.
msgbox "add code to open file here!"
case is = "save" ’ save file.
msgbox "add code to save file here!"
end select
end sub
private sub combo1_click()
’ change backcolor of form using the combobox.
select case combo1.listindex
case 0
form1.backcolor = VBblack
case 1
form1.backcolor = vbblue
case 2
form1.backcolor = vbred
end select
end sub
上一篇: 用Win2000 Active Directory保护应用程序之一
下一篇: 用Win2000 Active Directory保护应用程序之二
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash