288794 ,~{2;4m#,2;4m#,C;?4WPO8#,=qLlIO~}MSDN~{8z~}Delphi~{T4BkU[LZAK4s0kLl#,;X9}H%R;?4#,:G:G#,Tg?4Ge>M2;SC7Q>"AK#:#)~}~{5+JG#,Hg9{NRC;TY4N?44m#,DcDG6N4zBkJG8D1d~}Toolbar~{5D~}Style~{#,2;OTJ>~}Image~{#,NRR*Wv5D6+Nw;9:\6`#:~} 1.~{2;OTJ>OB@-<}M7#,<4HCVwLe04E%:MOB@-<}M704E%R;Le#,RQJ5OV#:~} SendMessage hToolbar, TB_SETEXTENDEDSTYLE, 0, BTNS_WHOLEDROPDOWN 2.~{=+KySP5D2K5%04E%~}Style~{<S@`KFSZ~}Delphi~{VP~}Grouped~{JtPT#,2ED\1mOV5CUfOs2K5%#,7qTrTZ~}hover~{W4L,W*5=AmR;8v04E%2;1d;/!#8z~}Delphi~{T4Bk#,JGSC~}TB_SETBUTTONINFO~{#,FdVP~} Private Type TBBUTTONINFO cbSize As Long dwMask As Long idCommand As Long iImage As Long fsState As Byte fsStyle As Byte cx As Integer lParam As Long pszText As String cchText As Long End Type ~{=a995D~}fsStyle or TBSTYLE_GROUP(&H4)~{NR2ISCOH~}TB_GETBUTTONINFO~{#,H;:sP^8D8C=a99#,TY7"KM~}TB_SETBUTTONINFO~{#,2;3IOkTuC46<V4PP2;3I9&#:#(~}~{E<6T~}VB~{Uf5D2;Jl#,8USCAK<8Ll#,8DFp@4J5TZM74s#,;9Gk~}288794~{@O4s6`6`0oC&#,6`P;6`P;#!~}
288794,~{2;4m#,2;4m#,C;?4WPO8#,=qLlIO~}MSDN~{8z~}Delphi~{T4BkU[LZAK4s0kLl#,;X9}H%R;?4#,:G:G#,Tg?4Ge>M2;SC7Q>"AK#:#)~}~{5+JG#,Hg9{NRC;TY4N?44m#,DcDG6N4zBkJG8D1d~}Toolbar~{5D~}Style~{#,2;OTJ>~}Image~{#,NRR*Wv5D6+Nw;9:\6`#:~} 1.~{2;OTJ>OB@-<}M7#,<4HCVwLe04E%:MOB@-<}M704E%R;Le#,RQJ5OV#:~} SendMessage hToolbar, TB_SETEXTENDEDSTYLE, 0, BTNS_WHOLEDROPDOWN 2.~{=+KySP5D2K5%04E%~}Style~{<S@`KFSZ~}Delphi~{VP~}Grouped~{JtPT#,2ED\1mOV5CUfOs2K5%#,7qTrTZ~}hover~{W4L,W*5=AmR;8v04E%2;1d;/!#8z~}Delphi~{T4Bk#,JGSC~}TB_SETBUTTONINFO~{#,FdVP~} Private Type TBBUTTONINFO cbSize As Long dwMask As Long idCommand As Long iImage As Long fsState As Byte fsStyle As Byte cx As Integer lParam As Long pszText As String cchText As Long End Type ~{=a995D~}fsStyle or TBSTYLE_GROUP(&H4)~{NR2ISCOH~}TB_GETBUTTONINFO~{#,H;:sP^8D8C=a99#,TY7"KM~}TB_SETBUTTONINFO~{#,2;3IOkTuC46<V4PP2;3I9&#:#(~}~{E<6T~}VB~{Uf5D2;Jl#,8USCAK<8Ll#,8DFp@4J5TZM74s#,;9Gk~}288794~{@O4s6`6`0oC&#,6`P;6`P;#!~}
~{2;4m#,2;4m#,C;?4WPO8#,=qLlIO~}MSDN~{8z~}Delphi~{T4BkU[LZAK4s0kLl#,;X9}H%R;?4#,:G:G#,Tg?4Ge>M2;SC7Q>"AK#:#)~}~{5+JG#,Hg9{NRC;TY4N?44m#,DcDG6N4zBkJG8D1d~}Toolbar~{5D~}Style~{#,2;OTJ>~}Image~{#,NRR*Wv5D6+Nw;9:\6`#:~} 1.~{2;OTJ>OB@-<}M7#,<4HCVwLe04E%:MOB@-<}M704E%R;Le#,RQJ5OV#:~} SendMessage hToolbar, TB_SETEXTENDEDSTYLE, 0, BTNS_WHOLEDROPDOWN 2.~{=+KySP5D2K5%04E%~}Style~{<S@`KFSZ~}Delphi~{VP~}Grouped~{JtPT#,2ED\1mOV5CUfOs2K5%#,7qTrTZ~}hover~{W4L,W*5=AmR;8v04E%2;1d;/!#8z~}Delphi~{T4Bk#,JGSC~}TB_SETBUTTONINFO~{#,FdVP~} Private Type TBBUTTONINFO cbSize As Long dwMask As Long idCommand As Long iImage As Long fsState As Byte fsStyle As Byte cx As Integer lParam As Long pszText As String cchText As Long End Type ~{=a995D~}fsStyle or TBSTYLE_GROUP(&H4)~{NR2ISCOH~}TB_GETBUTTONINFO~{#,H;:sP^8D8C=a99#,TY7"KM~}TB_SETBUTTONINFO~{#,2;3IOkTuC46<V4PP2;3I9&#:#(~}~{E<6T~}VB~{Uf5D2;Jl#,8USCAK<8Ll#,8DFp@4J5TZM74s#,;9Gk~}288794~{@O4s6`6`0oC&#,6`P;6`P;#!~}
taking over almost any new application which has toolbars - and I can see why. I mean, it's got style, a simple look and adds an attractive side to your application. Visual Basic 5.0 didn't bring these controls in as a part of its new control set, but you can do it yourself with the old Common Controls Toolbar, and an API call. 1. Create a new project, and add the Common Controls ActiveX control to it. 2. Draw the Toolbar onto a form. Add your buttons. 3. Place the following into the General Declarations section: Private Declare Function FindWindowEx Lib "user32" _ Alias "FindWindowExA" (ByVal hWndParent As Long, ByVal _ hWndChildWindow As Long, ByVal lpClassName As String, _ ByVal lpsWindowName As String) As Long Const TB_SETSTYLE = WM_USER + 56 Const TB_GETSTYLE = WM_USER + 57 Const WM_USER = &H400 Const TBSTYLE_FLAT = &H800 4. Add this Sub to the General Declarations Section as well: Public Sub SetTBar97(TBar As Toolbar) Dim lTBarStyle As Long, lTBarHwnd As Long lTBarHwnd = FindWindowEx(TBar.hWnd, 0&, _ "ToolbarWindow32", vbNullString) lTBarStyle = SendMessage(lTBarHwnd, TB_GETSTYLE, _ 0&, 0&) lTBarStyle = lTBarStyle Or TBSTYLE_FLAT SendMessage lTBarHwnd, TB_SETSTYLE, 0, lTBarStyle TBar.Refresh End Sub 5. Add a Module and add this to it: Declare Function SendMessage Lib "user32" Alias _ "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As _ Long, ByVal wParam As Long, lParam As Any) As Long 6. You can make the Toolbars Office 97 Style with: SetTBar97 Toolbar1 Toolbar1, of course, being your toolbar control's name.
288794,不错,不错,没看仔细,今天上MSDN跟Delphi源码折腾了大半天,回过去一看,呵呵,早看清就不用费劲了:)但是,如果我没再次看错,你那段代码是改变Toolbar的Style,不显示Image,我要做的东西还很多: 1.不显示下拉箭头,即让主体按钮和下拉箭头按钮一体,已实现: SendMessage hToolbar, TB_SETEXTENDEDSTYLE, 0, BTNS_WHOLEDROPDOWN 2.将所有的菜单按钮Style加类似于Delphi中Grouped属性,才能表现得真象菜单,否则在hover状态转到另一个按钮不变化.跟Delphi源码,是用TB_SETBUTTONINFO,其中 Private Type TBBUTTONINFO cbSize As Long dwMask As Long idCommand As Long iImage As Long fsState As Byte fsStyle As Byte cx As Integer lParam As Long pszText As String cchText As Long End Type结构的fsStyle需要or一下TBSTYLE_GROUP(&H4)我采用先TB_GETBUTTONINFO,然后修改该结构,再发送TB_SETBUTTONINFO,不成想怎么都执行不成功:(偶对VB不熟,刚用了几天,改起来实在头大,还请288794老大多多帮忙,多谢多谢!
http://pinmo.com.cn/vbsite/down/ocx/form/ab2eval.EXE
http://www.bestcracks.com/hjlkjhHJKiuy56j2khGkjg/d/vb4_actbar2.zip
您要的功能
please
http://www.csdn.net/expert/topic/596/596127.xml?temp=.3724787
在FrmMenu上建立好菜单
在在FrmMain的CoolBar中连接一个PictureBox运行时:
用“SetWindowRgn”使FrmMenu只显示菜单区域
用“SetParent”把FrmMenu的父设为 FrmMain的CoolBar中的PictureBox
你看过 MSDN 没有,里面介绍的就是 Coolbar + Toolbar 来做这种菜单的,
不信你可以使用 Spy++ 来查看 Explorer 的菜单条,看它是不是 Toolbar,zyl910(910:分儿,我来了!)
你的思路不错,可是效果就不敢恭维,我曾经做过的。
1.~{2;OTJ>OB@-<}M7#,<4HCVwLe04E%:MOB@-<}M704E%R;Le#,RQJ5OV#:~}
SendMessage hToolbar, TB_SETEXTENDEDSTYLE, 0, BTNS_WHOLEDROPDOWN
2.~{=+KySP5D2K5%04E%~}Style~{<S@`KFSZ~}Delphi~{VP~}Grouped~{JtPT#,2ED\1mOV5CUfOs2K5%#,7qTrTZ~}hover~{W4L,W*5=AmR;8v04E%2;1d;/!#8z~}Delphi~{T4Bk#,JGSC~}TB_SETBUTTONINFO~{#,FdVP~}
Private Type TBBUTTONINFO
cbSize As Long
dwMask As Long
idCommand As Long
iImage As Long
fsState As Byte
fsStyle As Byte
cx As Integer
lParam As Long
pszText As String
cchText As Long
End Type
~{=a995D~}fsStyle or TBSTYLE_GROUP(&H4)~{NR2ISCOH~}TB_GETBUTTONINFO~{#,H;:sP^8D8C=a99#,TY7"KM~}TB_SETBUTTONINFO~{#,2;3IOkTuC46<V4PP2;3I9&#:#(~}~{E<6T~}VB~{Uf5D2;Jl#,8USCAK<8Ll#,8DFp@4J5TZM74s#,;9Gk~}288794~{@O4s6`6`0oC&#,6`P;6`P;#!~}
1.~{2;OTJ>OB@-<}M7#,<4HCVwLe04E%:MOB@-<}M704E%R;Le#,RQJ5OV#:~}
SendMessage hToolbar, TB_SETEXTENDEDSTYLE, 0, BTNS_WHOLEDROPDOWN
2.~{=+KySP5D2K5%04E%~}Style~{<S@`KFSZ~}Delphi~{VP~}Grouped~{JtPT#,2ED\1mOV5CUfOs2K5%#,7qTrTZ~}hover~{W4L,W*5=AmR;8v04E%2;1d;/!#8z~}Delphi~{T4Bk#,JGSC~}TB_SETBUTTONINFO~{#,FdVP~}
Private Type TBBUTTONINFO
cbSize As Long
dwMask As Long
idCommand As Long
iImage As Long
fsState As Byte
fsStyle As Byte
cx As Integer
lParam As Long
pszText As String
cchText As Long
End Type
~{=a995D~}fsStyle or TBSTYLE_GROUP(&H4)~{NR2ISCOH~}TB_GETBUTTONINFO~{#,H;:sP^8D8C=a99#,TY7"KM~}TB_SETBUTTONINFO~{#,2;3IOkTuC46<V4PP2;3I9&#:#(~}~{E<6T~}VB~{Uf5D2;Jl#,8USCAK<8Ll#,8DFp@4J5TZM74s#,;9Gk~}288794~{@O4s6`6`0oC&#,6`P;6`P;#!~}
1.~{2;OTJ>OB@-<}M7#,<4HCVwLe04E%:MOB@-<}M704E%R;Le#,RQJ5OV#:~}
SendMessage hToolbar, TB_SETEXTENDEDSTYLE, 0, BTNS_WHOLEDROPDOWN
2.~{=+KySP5D2K5%04E%~}Style~{<S@`KFSZ~}Delphi~{VP~}Grouped~{JtPT#,2ED\1mOV5CUfOs2K5%#,7qTrTZ~}hover~{W4L,W*5=AmR;8v04E%2;1d;/!#8z~}Delphi~{T4Bk#,JGSC~}TB_SETBUTTONINFO~{#,FdVP~}
Private Type TBBUTTONINFO
cbSize As Long
dwMask As Long
idCommand As Long
iImage As Long
fsState As Byte
fsStyle As Byte
cx As Integer
lParam As Long
pszText As String
cchText As Long
End Type
~{=a995D~}fsStyle or TBSTYLE_GROUP(&H4)~{NR2ISCOH~}TB_GETBUTTONINFO~{#,H;:sP^8D8C=a99#,TY7"KM~}TB_SETBUTTONINFO~{#,2;3IOkTuC46<V4PP2;3I9&#:#(~}~{E<6T~}VB~{Uf5D2;Jl#,8USCAK<8Ll#,8DFp@4J5TZM74s#,;9Gk~}288794~{@O4s6`6`0oC&#,6`P;6`P;#!~}
2. Draw the Toolbar onto a form. Add your buttons.
3. Place the following into the General Declarations section: Private Declare Function FindWindowEx Lib "user32" _
Alias "FindWindowExA" (ByVal hWndParent As Long, ByVal _
hWndChildWindow As Long, ByVal lpClassName As String, _
ByVal lpsWindowName As String) As Long Const TB_SETSTYLE = WM_USER + 56
Const TB_GETSTYLE = WM_USER + 57 Const WM_USER = &H400 Const TBSTYLE_FLAT = &H800
4. Add this Sub to the General Declarations Section as well: Public Sub SetTBar97(TBar As Toolbar)
Dim lTBarStyle As Long, lTBarHwnd As Long
lTBarHwnd = FindWindowEx(TBar.hWnd, 0&, _
"ToolbarWindow32", vbNullString)
lTBarStyle = SendMessage(lTBarHwnd, TB_GETSTYLE, _
0&, 0&)
lTBarStyle = lTBarStyle Or TBSTYLE_FLAT
SendMessage lTBarHwnd, TB_SETSTYLE, 0, lTBarStyle
TBar.Refresh
End Sub
5. Add a Module and add this to it: Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As _
Long, ByVal wParam As Long, lParam As Any) As Long
6. You can make the Toolbars Office 97 Style with: SetTBar97 Toolbar1 Toolbar1, of course, being your toolbar control's name.
你还可以去下载一个spdbdock.ocx控件,它是一个被称作“入坞”的控件,
这样你可以把菜单放在一个窗体中,然后在程序启动时让它“入坞”即可。
1.不显示下拉箭头,即让主体按钮和下拉箭头按钮一体,已实现:
SendMessage hToolbar, TB_SETEXTENDEDSTYLE, 0, BTNS_WHOLEDROPDOWN
2.将所有的菜单按钮Style加类似于Delphi中Grouped属性,才能表现得真象菜单,否则在hover状态转到另一个按钮不变化.跟Delphi源码,是用TB_SETBUTTONINFO,其中 Private Type TBBUTTONINFO
cbSize As Long
dwMask As Long
idCommand As Long
iImage As Long
fsState As Byte
fsStyle As Byte
cx As Integer
lParam As Long
pszText As String
cchText As Long
End Type结构的fsStyle需要or一下TBSTYLE_GROUP(&H4)我采用先TB_GETBUTTONINFO,然后修改该结构,再发送TB_SETBUTTONINFO,不成想怎么都执行不成功:(偶对VB不熟,刚用了几天,改起来实在头大,还请288794老大多多帮忙,多谢多谢!
我是在网吧上的网回去帮你测试一下,等着吧......
二、怎样是它能像真正的菜单一样:可以用左右方向键移动菜单?
wwfang(方耀东):
lTBarHwnd = FindWindowEx(TBar.hWnd, 0&, "ToolbarWindow32", vbNullString)
288794():
htool=findwindowEX(Toolbar1.hwnd,0&,"msvb_lib_toolbar",vbNullstring)经过我机器上测试,288794()的参数是可行的,即"msvb_lib_toolbar",照一些资料上说的"ToolbarWindow32"不行;即使第三个参数也设置成vbNullstring,也能得到正确的句柄。
了的,要用到的技术很多,子类化,鼠标钩子,键盘钩子......
我靠!看来有时间要花时间来封装它......
同志们,多多努力吧......ToolbarWindow32 是版本 5 的 ToolBar 使用。
1.发送TB_GETBUTTONINFO,得到TBBUTTONINFO结构
2.TBBUTTONINFO.fsStyle中加入TBSTYLE_GROUP风格
3.发送TB_SETBUTTONINFO,重设TBBUTTONINFO结构ayuu(ayuu),伙计,就是用coolbar和toolbar,做Menu Bar。
你用Coolbar + Toolbar跟Delphi中是一样的
引用 mircrosoft windows comman ctroal 5.0版
我的信箱:[email protected]
并不需要 你说的 <<avant(千寻) "考虑用于控制菜单的重画等等">>
不需要重画!
至于模仿效果还有人写出程序了,忘记他名字和帖子了..做得不错.确实是子类化窗体以后做到的...至于点击菜单以后移动鼠标要模拟菜单那样自动弹出.好像是hitTest来做的..SetCapture和ReleaseCapture也是必须的..