The function also retrieves the 32-bit (long) value at the specified offset into the extra window memory. 
大侠们知道这句话的意思吗?望指点一下!在下先谢过!`(0∩_∩0)′——纯字面意思我知道,但不能理解!

解决方案 »

  1.   

    这是哪个API的帮助啊,能提示一下吗:)
      

  2.   

    当然,这时一个很常用的API (0∩_∩0)′
    GetWindowLong
    The GetWindowLong function retrieves information about the specified window. The function also retrieves the 32-bit (long) value at the specified offset into the extra window memory. If you are retrieving a pointer or a handle, this function has been superseded by the GetWindowLongPtr function. (Pointers and handles are 32 bits on 32-bit Windows and 64 bits on 64-bit Windows.) To write code that is compatible with both 32-bit and 64-bit versions of Windows, use GetWindowLongPtr. 
      

  3.   

    还是不太明白,我的理解是,从窗口地址开始有一个数据段,存储了窗口的一些数据!从这个数据段的不同位置开始可以取得对应的窗口数据!这个offset就是为了设置起点的!不知这样理解是否正确?
      

  4.   

    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long【操作系统】
    Win9X:Yes
    WinNT:Yes
    【说明】
      从指定窗口的结构中取得信息 
    【返回值】
      Long,由nIndex决定。零表示出错。会设置GetLastError 
    【其它】
    【参数表】
      hwnd -----------  Long,欲为其获取信息的窗口的句柄
      nIndex ---------  Long,欲取回的信息,可以是下述任何一个常数:
      GWL_EXSTYLE
      扩展窗口样式
      GWL_STYLE
      窗口样式
      GWL_WNDPROC
      该窗口的窗口函数的地址
      GWL_HINSTANCE
      拥有窗口的实例的句柄
      GWL_HWNDPARENT
      该窗口之父的句柄。不要用SetWindowWord来改变这个值
      GWL_ID
      对话框中一个子窗口的标识符
      GWL_USERDATA
      含义由应用程序规定
      DWL_DLGPROC
      这个窗口的对话框函数地址
      DWL_MSGRESULT
      在对话框函数中处理的一条消息返回的值
      DWL_USER
      含义由应用程序规定
    'Example Name: Maintaining Form Aspect Ratio During Resizing'------------------------------------------------------------------------------
    ' BAS Module Code 
    '------------------------------------------------------------------------------
     
    Option Explicit
    Public defWindowProc As Long
    Private Const GWL_WNDPROC As Long = (-4)
    Private Const WM_DESTROY = &H2
    Private Const WM_SIZING = &H214'wParam for WM_SIZING message
    Private Const WMSZ_LEFT = 1
    Private Const WMSZ_RIGHT = 2
    Private Const WMSZ_TOP = 3
    Private Const WMSZ_TOPLEFT = 4
    Private Const WMSZ_TOPRIGHT = 5
    Private Const WMSZ_BOTTOM = 6
    Private Const WMSZ_BOTTOMLEFT = 7
    Private Const WMSZ_BOTTOMRIGHT = 8Private Type RECT
       Left As Long
       Top As Long
       Right As Long
       Bottom As Long
    End TypePrivate Declare Function GetWindowLong Lib "user32" _
        Alias "GetWindowLongA" _
       (ByVal hwnd As Long, _
        ByVal nIndex As Long) As Long
        
    Private Declare Function SetWindowLong Lib "user32" _
        Alias "SetWindowLongA" _
       (ByVal hwnd As Long, _
        ByVal nIndex As Long, _
        ByVal dwNewLong As Long) As Long
       
    Private Declare Function CallWindowProc Lib "user32" _
        Alias "CallWindowProcA" _
       (ByVal lpPrevWndFunc As Long, _
        ByVal hwnd As Long, _
        ByVal uMsg As Long, _
        ByVal wParam As Long, _
        ByVal lParam As Long) As LongPrivate Declare Sub CopyMemory Lib "kernel32" _
       Alias "RtlMoveMemory" _
       (hpvDest As Any, _
        hpvSource As Any, _
        ByVal cbCopy As Long)Public Sub Unhook(fhwnd As Long)    
       If defWindowProc Then
          Call SetWindowLong(fhwnd, GWL_WNDPROC, defWindowProc)
          defWindowProc = 0
       End IfEnd SubPublic Sub Hook(fhwnd As Long)    
       defWindowProc = SetWindowLong(fhwnd, _
                                     GWL_WNDPROC, _
                                     AddressOf WindowProc)                            
    End SubFunction WindowProc(ByVal hwnd As Long, _
                        ByVal uMsg As Long, _
                        ByVal wParam As Long, _
                        ByVal lParam As Long) As Long   Dim rc As RECT   
       Select Case uMsg
       
          Case WM_SIZING
             CopyMemory rc, ByVal lParam, LenB(rc)
             Select Case wParam
             
                Case WMSZ_LEFT
                   rc.Bottom = (rc.Right - rc.Left) + rc.Top
                   CopyMemory ByVal lParam, rc, LenB(rc)
                   WindowProc = 1
       
                Case WMSZ_RIGHT
                   rc.Bottom = (rc.Right - rc.Left) + rc.Top
                   CopyMemory ByVal lParam, rc, LenB(rc)
                   WindowProc = 1
       
                Case WMSZ_TOP
                   rc.Right = (rc.Bottom - rc.Top) + rc.Left
                   CopyMemory ByVal lParam, rc, LenB(rc)
                   WindowProc = 1
       
                Case WMSZ_BOTTOM
                   rc.Right = (rc.Bottom - rc.Top) + rc.Left
                   CopyMemory ByVal lParam, rc, LenB(rc)
                   WindowProc = 1
       
                Case WMSZ_TOPLEFT
                   rc.Left = (rc.Top - rc.Bottom) + (rc.Right)
                   CopyMemory ByVal lParam, rc, LenB(rc)
                   WindowProc = 1
                   
                Case WMSZ_TOPRIGHT
                   rc.Right = (rc.Bottom - rc.Top) + rc.Left
                   CopyMemory ByVal lParam, rc, LenB(rc)
                   WindowProc = 1
       
                Case WMSZ_BOTTOMLEFT
                   rc.Bottom = (rc.Right - rc.Left) + (rc.Top)
                   CopyMemory ByVal lParam, rc, LenB(rc)
                   WindowProc = 1
                   
                Case WMSZ_BOTTOMRIGHT
                   rc.Bottom = (rc.Right - rc.Left) + rc.Top
                   CopyMemory ByVal lParam, rc, LenB(rc)
                   WindowProc = 1
       
                End Select
          
             Case WM_DESTROY:
                If defWindowProc <> 0 Then
                   Call Unhook(form1.hwnd)
                End If
          
        End Select
        
      '处理windows消息
       WindowProc = CallWindowProc(defWindowProc, _
                                   hwnd, _
                                   uMsg, _
                                   wParam, _
                                   lParam)End Function
     
    '------------------------------------------------------------------------------
    ' Form Code 
    '------------------------------------------------------------------------------ 
    '在Form中需要一个Command Button(Command1)
    Option ExplicitPrivate Sub Form_Load()
       With form1      
          .Width = 6000
          .Height = 6000
          Call Hook(.hwnd)   
       End With   
    End SubPrivate Sub Command1_Click()
       Unload Me  
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
        Call Unhook(Me.hwnd)
    End Sub
      

  5.   

    当用 RegisterClass 注册窗口类时,在结构 WNDCLASS.cbWndExtra 属性可以指定用该窗口类创建的窗口会多申请指定字节数的内存作为 extra window memory。
    这些内存的访问就要通过 GetWindowLong 和 SetWindowsLong 进行。