用代码实现toolbar弹出ButtonMenus(VB)
2010-02-28 16:29
134 查看
代码如下: Option Explicit Private Type TBBUTTON iBitmap As Long idCommand As Long fsState As Byte fsStyle As Byte bReserved1 As Byte bReserved2 As Byte dwData As Long iString As Long End Type Private Type NMHDR hwndFrom As Long idfrom As Long code As Long End Type Private Type NMTOOLBAR hdr As NMHDR iItem As Long tbBtn As TBBUTTON cchText As Long lpszString As Long End Type Private Const TBN_FIRST = -700& Private Const TBN_DROPDOWN = (TBN_FIRST - 10) Private Const WM_USER = &H400 Private Const TB_GETBUTTON As Long = (WM_USER + 23) Private Const WM_NOTIFY As Long = &H4E& 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 Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) If Button.Index = 4 Then '假如toolbar上的第4个按钮有buttonmenu,同时其样式为5 showbuttonmenu Toolbar1, Button.Index - 1 End If End Sub Private Sub showbuttonmenu(Toolbar1 As MSComctlLib.Toolbar, ByVal Buttonindex As Long) 'buttonindex从0开始 Dim tButton As TBBUTTON Dim tNotify As NMTOOLBAR Dim lResult As Long Dim mhwnd As Long Dim lCommandId As Long mhwnd = FindWindowEx(Toolbar1.hwnd, 0, "msvb_lib_toolbar", vbNullString) lResult = SendMessage(mhwnd, TB_GETBUTTON, Buttonindex, tButton) lCommandId = tButton.idCommand With tNotify .hdr.code = TBN_DROPDOWN .hdr.hwndFrom = mhwnd .iItem = lCommandId End With lResult = SendMessage(Toolbar1.hwnd, WM_NOTIFY, 0, tNotify) End Sub 本文转自:http://rainstormmaster.cnblogs.com/archive/2006/03/24/357795.html
相关文章推荐
- VB:如何实现在代码中弹出toolbar的ButtonMenu
- JS实时弹出新消息提示框并有提示音响起的实现代码
- [ASP.NET]实现在执行完服务端代码后弹出提醒对话框
- Jquery实现鼠标移上弹出提示框、移出消失思路及代码
- vb 纯代码实现NT下隐藏进程
- 设置点击文本框或图片弹出日历控件的实现代码
- 数据加载等待页面的VB.NET代码实现
- jQuery实现点击弹出背景变暗遮罩效果实例代码
- VB代码实现屏幕截图(Screenshot功能)
- VB 实现大文件的分割与恢复,引用 ADODB.Stream 提供一个过程代码
- VB实现抓屏/截图的代码
- 点击下载链接 弹出页面实现代码
- 利用vb向网页提交表单数据的实现代码
- ASP.NET(VB)写的后台发送短信实现代码
- 用C#用C#实现窗体在规定时间弹出,例如:10:00.弹出后关闭。并在5分钟后再次弹出。5次后停止。最好有具体代码实现窗体在规定时间弹出,例如:10:00.弹出后关闭。并在5分钟后再次弹出。5次后停止。最好有具体代码
- bootstrap实现点击删除按钮弹出确认框的实例代码
- 基于Jquery+div+css实现弹出登录窗口(代码超简单)
- php弹出对话框实现重定向代码
- JavaScript实现网页右下角弹出窗口代码