您现在的位置: 天下网吧 >> 网吧天地 >> 天下码农 >> 编程界 >> 正文

VB中用第三方控件打造QQ菜单

2006-12-16天极网第七乐章

以上代码中,我们新添加了“陌生人”和“黑名单”两个分组,又在原先设置过的“我的好友”分组中添加了6个项目。

  提示:ctListBar1.AddListItem方法使用了3个参数,分别为nIndex(分组的Index值)、strText(项目的名称)、Picture(项目的图片)。
 
  ③在按钮控件cmd_AddList的Click事件中输入代码:

 

 



 

  strListName = ""
  strListName = InputBox("请输入要添加的分组名称", "添加分组")
  If strListName <> "" Then ctListBar1.AddList strListName

  在按钮控件cmd_DelList的Click事件中输入代码:

  intListNum = 0
  intListNum = Val(InputBox("请输入要删除的分组标识号", "删除分组"))
  If intListNum <> 0 Then ctListBar1.DeleteList intListNum
  
  在按钮控件cmd_AddItem的Click事件中输入代码:

  strItemName = ""
  intListNum = 0
  intListNum = Val(InputBox("请输入要添加的项目所在分组的标识号", "添加项目"))
  If intListNum <> 0 Then strItemName = InputBox("请输入要添加的项目的名称", "添加项目")
  If strItemName <> "" Then ctListBar1.AddListItem intListNum, strItemName, ctListBar1.Image1

  在按钮控件cmd_DelItem的Click事件中输入代码:

  intListNum = 0
  intItemNum = 0
  intListNum = Val(InputBox("请输入要删除的项目所在分组的标识号", "删除项目"))
  If intListNum <> 0 Then intItemNum = Val(InputBox("请输入要删除的项目的标识号", "删除项目"))
  If intItemNum <> 0 Then ctListBar1.DeleteItem intListNum, intItemNum

  在按钮控件cmd_Insert的Click事件中输入代码:

  intListNum = 0
  intItemNum = 0
  strItemName = ""
  intListNum = Val(InputBox("请输入要插入的项目所在分组的标识号", "插入项目"))
  If intListNum <> 0 Then intItemNum = Val(InputBox("请输入要插入的项目所在位置的标识号", "插入项目"))
  If intItemNum <> 0 Then strItemName = InputBox("请输入要插入的项目的名称", "插入项目")
  If strItemName <> "" Then ctListBar1.InsertListItem intListNum, intItemNum, strItemName, tListBar1.Image1

  提示:用AddListItem添加的项目只能添加在该分组末尾,而InsertListItem方法可以在一个分组中的指定位置插入一个新的项目。

  到这里,这个简单的实例程序就完成了,按下F5,看看效果(如图3),是不是很酷?和QQ象极了!CtListBar控件用处很多,它完全可以用来替代Visual Basic中菜单编辑器编辑出的古板菜单,很多著名软件都使用了类似的菜单效果。在你的程序中也用上这个控件,一定可以为你的程序增辉不少。

欢迎访问最专业的网吧论坛,无盘论坛,网吧经营,网咖管理,网吧专业论坛 https://bbs.txwb.com

关注天下网吧微信/下载天下网吧APP/天下网吧小程序,一起来超精彩

本文来源:天极网 作者:第七乐章

声明
声明:本站所发表的文章、评论及图片仅代表作者本人观点,与本站立场无关。若文章侵犯了您的相关权益,请及时与我们联系,我们会及时处理,感谢您对本站的支持!联系邮箱:support@txwb.com,系统开号,技术支持,服务联系QQ:1175525021本站所有有注明来源为天下网吧或天下网吧论坛的原创作品,各位转载时请注明来源链接!
天下网吧 网吧天下