标题:[求助]VB做出来的菜单背景色可否设为黑色?
只看楼主
海蓝啸
Rank: 5Rank: 5
来 自:安徽
等 级:贵宾
威 望:17
帖 子:1611
专家分:0
注 册:2006-4-3
结帖率:100%
 问题点数:0 回复次数:3 
[求助]VB做出来的菜单背景色可否设为黑色?
VB做出来的菜单背景色默认是那种灰色的。。。可不可以更改为其它颜色呢。。。比如黑色?

[此贴子已经被作者于2007-1-2 15:30:21编辑过]


搜索更多相关主题的帖子: 菜单背景 黑色 灰色 颜色 
2007-01-02 14:54
海蓝啸
Rank: 5Rank: 5
来 自:安徽
等 级:贵宾
威 望:17
帖 子:1611
专家分:0
注 册:2006-4-3
得分:0 

怎么没人帮忙解决下。。。呼唤版主出现。。。


这个社会太复杂。。。
2007-01-02 18:07
清澂居士
Rank: 6Rank: 6
等 级:贵宾
威 望:28
帖 子:1237
专家分:7
注 册:2006-12-19
得分:0 

偶不是版主````不過偶齣現叻```歡迎麼?1```

首先设计好你的菜单
然后在窗体上加入菜单
代码如下:
Option Explicit
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Const MIM_BACKGROUND As Long = &H2
Private Const MIM_APPLYTOSUBMENUS As Long = &H80000000
Private Type MENUINFO
cbSize As Long
fMask As Long
dwStyle As Long
cyMax As Long
hbrBack As Long
dwContextHelpID As Long
dwMenuData As Long
End Type
Private Declare Function DrawMenuBar Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function GetSubMenu Lib "user32" _
(ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function GetMenu Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function SetMenuInfo Lib "user32" _
(ByVal hMenu As Long, _
mi As MENUINFO) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" _
(ByVal crColor As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Sub Command1_Click()
Dim itemnum As Long
Dim hMenu As Long
Dim mi As MENUINFO
Dim i As Long
hMenu = GetMenu(Me.hWnd)
itemnum = GetMenuItemCount(hMenu)
With mi
.cbSize = Len(mi)
.fMask = MIM_BACKGROUND Or MIM_APPLYTOSUBMENUS
.hbrBack = CreateSolidBrush(vbYellow)
End With
SetMenuInfo GetMenu(Me.hWnd), mi 'main menu bar
DrawMenuBar Me.hWnd
'其实上面的程序就可以满足你的要求了,不过,加上下面的语句,显得更有意思一些
For i = 0 To itemnum - 1
With mi
.cbSize = Len(mi)
.fMask = MIM_BACKGROUND Or MIM_APPLYTOSUBMENUS
Randomize Timer
.hbrBack = CreateSolidBrush(CLng(&HFFFFFF * Rnd(i)))
End With
SetMenuInfo GetSubMenu(hMenu, i), mi
Next
End Sub


[此贴子已经被作者于2007-1-4 0:05:32编辑过]


佛曰:\"前世的500次回眸才换来今生的一次擦肩而过\".我宁愿用来世的一次擦肩而过来换得今生的500次回眸.
2007-01-02 18:17
海蓝啸
Rank: 5Rank: 5
来 自:安徽
等 级:贵宾
威 望:17
帖 子:1611
专家分:0
注 册:2006-4-3
得分:0 
当然欢迎。。。。谢谢

这个社会太复杂。。。
2007-01-02 18:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-113716-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.110465 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved