The function also retrieves the 32-bit (long) value at the specified offset into the extra window memory.
大侠们知道这句话的意思吗?望指点一下!在下先谢过!`(0∩_∩0)′——纯字面意思我知道,但不能理解!
大侠们知道这句话的意思吗?望指点一下!在下先谢过!`(0∩_∩0)′——纯字面意思我知道,但不能理解!
解决方案 »
- 间隔时间运行???
- 关于时间比较难的问题,大家来看看呀!
- 大家好 谁有关于Collection集合的例子?这个Collection集合对象怎么使用?
- 如何判断sqlserver登陆的用户类型?谢谢
- 在不改变打印机进纸方向的前提下如何让打印的字旋转90度?
- 兄弟们,做一份调查,请大家谈谈关于自已想开发什么样的软件,以及市场上会需要什么软件(内详)
- 能帮忙吗?谢谢!着急!
- 谁有多列下拉框并有抬头 的控件源代码,若有再送200分
- 一个图象很大(19寸的屏幕都不能完全显示),我想变成辉度图后。。。但????
- 请问各位老大!!!!!!!!!!!!!!!!!!!!
- pc与单片机通信mscomm发送问题!
- 怎样实现vb让窗体隐藏,显示功能
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.
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
这些内存的访问就要通过 GetWindowLong 和 SetWindowsLong 进行。