重载是hook, 不是sendmessage, sendmessage只能调用,和直接call 没有区别。

解决方案 »

  1.   

    hook(钩子)?什么地方的hook?请问Un1.
      

  2.   

    当然是获得combobox.hwnd以后用setwindowlong设置winproc啦!
      

  3.   

    Un1能否给我具体讲一讲如何在这个winproc中实现ComboBox的DrawItem,另DRAWITEMSTRUCT再次起什么作用?谢谢!希望其他全国各路VC、VB高手也来讨论!
      

  4.   

    Un1能否给我具体讲一讲如何在这个winproc中实现ComboBox的DrawItem,另DRAWITEMSTRUCT再此起什么作用?谢谢!希望其他全国各路VC、VB高手也来讨论!
      

  5.   

    诸位大虾们,sendmessage函数的高手们,快来轻松地取走这100分吧!
      

  6.   

    这个例子演示了如何强制重画窗口某一区域.有时这是很需要的,例如当你使用LockWindowUpdate API 函数来加快某一控件的数据加载速度时. 新建一个工程,添加一个模块,代码如下: Private Type RECT
      Left As Long
      Top As Long
      Right As Long 
      Bottom As Long 
    End Type 
    Private Type POINTAPI
      X As Long
      Y As Long 
    End Type 
    Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long 
    Private Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long 
    Private Declare Function InvalidateRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT, ByVal bErase As Long) As Long 
    Private Declare Function ScreenToClient Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long 
    Public Sub RepaintWindow( ByRef objThis As Object, Optional ByVal bClientAreaOnly As Boolean = True )
      Dim tR As RECT
      Dim tP As POINTAPI
      If (bClientAreaOnly) Then
        GetClientRect objThis.hWnd, tR
      Else
        GetWindowRect objThis.hWnd, tR
        tP.X = tR.Left: tP.Y = tR.Top
        ScreenToClient objThis.hWnd, tP
        tR.Left = tP.X: tR.Top = tP.Y
        tP.X = tR.Right: tP.Y = tR.Bottom
        ScreenToClient objThis.hWnd,
        tP tR.Right = tP.X: tR.Bottom = tP.Y
      End If
      InvalidateRect objThis.hWnd, tR, 1 
    End Sub 
    在窗体上放置一个按钮和列表框.使列表框足够大以便观察效果.然后添加以下代码: 
    Private Sub Command1_Click()
      RepaintWindow List1 
    End Sub 
    Private Sub Form_Load()
      Dim i As Long
      For i = 1 To 200
       List1.AddItem "TestItem " & I
      Next i 
    End Sub
      

  7.   

    我只知道对于菜单是:
       SendMeesage hwnd, WM_DRAWITEM, 0, lParam   lParam好像等于
       Dim DrawInfo As DRAWITEMSTRUCT
       Call CopyMem(ByVal lParam, DrawInfo, LenB(DrawInfo))我是参考下列源代码得来的,我不知道这样这样反过来用对不对
    ------------------------------------------------------
    Private Declare Sub CopyMem Lib "kernel32" Alias _
         "RtlMoveMemory" (pDest As Any, pSource As Any, _
         ByVal ByteLen As Long)Dim DrawInfo As DRAWITEMSTRUCTIf wMsg = WM_DRAWITEM Then
         If wParam = 0 Then 'It was sent by the menu
              'Get DRAWINFOSTRUCT -- copy it to our
              'empty structure from the pointer in lParam
              Call CopyMem(DrawInfo, ByVal lParam, LenB(DrawInfo))
              IsSep = IsSeparator(DrawInfo.itemID)          '===Set the menu font through its hDC...===
              MyFont = SendMessage(Me.hWnd, WM_GETFONT, 0&, 0&)
              OldFont = SelectObject(DrawInfo.hdc, MyFont)
              ...........................
         End If
         ........................ 
    End If
      

  8.   

    shines:你说的方法好象不行吧,当然你参考的源代码可以,因为Call CopyMem(DrawInfo, ByVal lParam, LenB(DrawInfo))已将lParam的值赋予了DrawInfo,而你的菜单代码为:
    Dim DrawInfo As DRAWITEMSTRUCT
    Call CopyMem(ByVal lParam, DrawInfo, LenB(DrawInfo))
    SendMeesage hwnd, WM_DRAWITEM, 0, lParam
    DRAWITEMSTRUCT为不可预料值,lParam则会是什么呢?
    注:上面是我个人意见,不一定对,仅供参考!
      

  9.   

    你应该去参考MSDN的Win32 API SDK,那里有完整的文档说明及示例,你会搞定的!