那,估计我的你也不会要看了。因为里面也有代码!呵呵!你不是不看代码嘛!不用代码,我也没法做到改变菜单颜色。要是VB是个工人就好了,你对它说:“喂!你那菜单颜色怎么那么差,害我一点胃口都没有了,把它弄点颜色上去吧!”,VB就乖乖的给你弄颜色就好了!呵呵。我没那么厉害,只知道用API去弄,还得自己动手。

解决方案 »

  1.   

    没有办法
    只能是自绘菜单。在WM_DRAWITEM消息的响应程序里。
    自绘菜单是这样的。
    先是WM_MEASUREITEM消息,在这个消息里你要把菜单的高度宽度返还给系统。
    然后是WM_DRAWITEM消息,在这个消息里你可以自己画出你想要的菜单。
    所以,你把zyl910的代码看明白后自然就会了。
      

  2.   

    我没有说不看代码。我只是想找找有没有简单的方法,例如某些控件可通过SetWindowLong来改变风格样式,希望能有比较通用的方法,直接就可以修改已有程序的菜单颜色。至于滚动条就没见过有人能改颜色了,希望大家不吝赐教。
      

  3.   

    滚动条可以通过处理父窗口的WM_CTLCOLORSCROLLBAR消息设置颜色
    --------------------------------------------------------------------
    注:
    WM:Windows Message,Windows消息
    CTL:Controls,控件
    SCROLLBAR:滚动条
    --------------------------------------------------------------------
    但是菜单栏不是控件!
    没有WM_CtlColorMenu!
    SetWindowLong只是设置窗口样式
    与颜色无关!
    根本没有所谓的“简单方法”
    只能自己画!
      

  4.   

    WM_CTLCOLORSCROLLBAR
    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.
      

  5.   

    最关键的部分就是自己画!
            ▲▲▲听说Slider等Win95新增控件也能自绘
    但我没有见到这方面的资料
    如果谁有的话请告诉我方法
      

  6.   

    听说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
      

  7.   

    不好意思了,如果是自己画的话那就不是我想问这个问题的初衷了。那还不如自己做Custom菜单。滚动条的我明天再试试,先多谢了。
      

  8.   

    不懂怎样做,如果真的可以,麻烦能否写出代码,我指的是改变滚动条颜色的。用SendMessage吗?具体在什么时候用,那几个参数怎样写?
      

  9.   

    用SubClassing技术处理滚动条的父窗口的消息
    处理WM_CTLCOLORSCROLLBAR
    判断lParam参数是否是所需要的hWnd
    再用SetBkColor设置背景颜色
      

  10.   

    前3个内容都可以做到了,但是怎样用SetBKcolor来设置呢?需要hDC这个参数,使用GetDC?GetWindowDC?好像完全没用,请再看看,以下是代码:Option Explicit
    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