那,估计我的你也不会要看了。因为里面也有代码!呵呵!你不是不看代码嘛!不用代码,我也没法做到改变菜单颜色。要是VB是个工人就好了,你对它说:“喂!你那菜单颜色怎么那么差,害我一点胃口都没有了,把它弄点颜色上去吧!”,VB就乖乖的给你弄颜色就好了!呵呵。我没那么厉害,只知道用API去弄,还得自己动手。
解决方案 »
- 据说这样可以提高帖子的点击率, 我来测试一下...《警告:本网站 内容收集于全世界的互联网,网站在美国进行维护,受美国法律保护》
- SQL语句
- 为什么窗体缷载后,属性还存在?
- 这次要问的很详细,要不所答就非所问了!还是关于API的问题啊!
- 如何在VB中得到系统的活动窗口句柄?
- 关于MID子窗体中,如何能显示MDIFrmMain主窗体菜单?
- 用wise installer 902來打包vb6+Crystal Reports8.5的程序,執行程序時出錯?
- 谢谢阿笨,我一天的问题解决了,终于可以休息喽,^_^
- 数据库调试时出现问题,请大师帮忙看看,谢谢
- 如何判别一字符串是GB码或是BIG5码?
- 有没有关于操作Toolbar按钮的例子
- 有一个WORD文挡,里边有几个表格,要把ACCESS记录插入到表格的单元格里边.急急急!!
只能是自绘菜单。在WM_DRAWITEM消息的响应程序里。
自绘菜单是这样的。
先是WM_MEASUREITEM消息,在这个消息里你要把菜单的高度宽度返还给系统。
然后是WM_DRAWITEM消息,在这个消息里你可以自己画出你想要的菜单。
所以,你把zyl910的代码看明白后自然就会了。
--------------------------------------------------------------------
注:
WM:Windows Message,Windows消息
CTL:Controls,控件
SCROLLBAR:滚动条
--------------------------------------------------------------------
但是菜单栏不是控件!
没有WM_CtlColorMenu!
SetWindowLong只是设置窗口样式
与颜色无关!
根本没有所谓的“简单方法”
只能自己画!
The WM_CTLCOLORSCROLLBAR message is sent to the parent window of a scroll bar control when the control is about to be drawn. By responding to this message, the parent window can use the given display context handle to set the background color of the scroll bar control. WM_CTLCOLORSCROLLBAR
hdcSB = (HDC) wParam; // handle to scroll-bar display context
hwndSB = (HWND) lParam; // handle to scroll bar
Parameters
hdcSB
Value of wParam. Handle to the device context for the scroll bar control.
hwndSB
Value of lParam. Handle to the scroll bar.
Return Values
If an application processes this message, it must return the handle to a brush. The system uses the brush to paint the background of the scroll bar control. Default Action
The DefWindowProc function selects the default system colors for the scroll bar control. Res
The system does not automatically destroy the returned brush. It is the application's responsibility to destroy the brush when it is no longer needed.The WM_CTLCOLORSCROLLBAR message is never sent between threads; it is only sent within the same thread. If a dialog box procedure handles this message, it should cast the desired return value to a BOOL and return the value directly. If the dialog box procedure returns FALSE, then default message handling is performed. The DWL_MSGRESULT value set by the SetWindowLong function is ignored. QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 2.0 or later.
Header: Declared in winuser.h.
▲▲▲听说Slider等Win95新增控件也能自绘
但我没有见到这方面的资料
如果谁有的话请告诉我方法
但我没有见到这方面的资料
如果谁有的话请告诉我方法-------------------------------------
这些不再是wm_drawitem了......以前的控件叫owner draw,现在叫Custom Draw了...
Customizing a Control's Appearance Using Custom Draw
Custom draw is not a common control; it is a service that many common controls provide. Custom draw services allow an application greater flexibility in customizing a control's appearance. Your application can harness custom draw notifications to easily change the font used to display items or manually draw an item without having to do a full-blown owner draw. About Custom DrawCustom Draw With List-View and Tree-View Controls
Using Custom DrawCustom Draw ReferenceAbout Custom Draw
This section contains general information about custom draw functionality and provides a conceptual overview of how an application can support custom draw. Currently, the following controls support custom draw functionality: Header controls
List-view controls
Rebar controls
Toolbar controls
ToolTip controls
Trackbar controls
Tree-view controls
Note Custom draw is implemented in version 4.70 and later of Comctl32.dll.
其中的Trackbar controls 指的就是Slider
处理WM_CTLCOLORSCROLLBAR
判断lParam参数是否是所需要的hWnd
再用SetBkColor设置背景颜色
Private Declare Function CallWindowProc Lib "user32" Alias _
"CallWindowProcA" (ByVal lpPrevWndFunc As Long, _
ByVal hwnd As Long, ByVal Msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As LongDeclare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As LongDeclare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As LongPrivate Const GWL_WNDPROC = -4
Private lpPrevWndProc As Long
Private IsHooked As BooleanPublic Sub Hook()
If IsHooked Then
Else
lpPrevWndProc = SetWindowLong(Form1.hWnd, GWL_WNDPROC, _
AddressOf WindowProc)
IsHooked = True
End If
End SubPublic Sub Unhook()
Dim temp As Long
If IsHooked Then
temp = SetWindowLong(Form1.hWnd, GWL_WNDPROC, lpPrevWndProc)
IsHooked = False
End If
End SubFunction WindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const WM_CTLCOLORSCROLLBAR = &H137
If WM_CTLCOLORSCROLLBAR = uMsg Then
If Form1.Vscroll1.hWnd = lParam Then
' SetBkColor hDC, vbWhite
End If
Else
WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
End If
End Function
Private Sub Form_Load()
Hook
End SubPrivate Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Unhook
End Sub