Search code examples
pointersvb6subclassingcopymemory

Copy data from an lParam value to a RECT structure in VB6


I am trying to get the rect from lParam while subclassing WM_MOVING.

My code currently is

Public Declare Function CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal dwLength As Long) As Long

Public Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Dim r As RECT
CopyMemory r, lParam, Len(r)

But the values of r are so absurd (like left: 1633872, right: 219218039, bottom: 1) that I think I am doing something wrong.

Does anybody see my error?

Thank you!


Solution

  • I am now using the fool-safe

    Private Declare Function CopyFromLParamToRect Lib "user32" Alias "CopyRect" (lpDestRect As RECT, ByVal lpSourceRect As Long) As Long
    

    It works fine.