当前位置: 代码迷 >> PB >> 把other的lparam变换为结构类型
  详细解决方案

把other的lparam变换为结构类型

热度:74   发布时间:2016-04-29 07:10:10.0
把other的lparam转换为结构类型?
我在other收到一个消息后,已经知道lparam是某个结构的指针,但是lparam只是一个数字,如何把它转换为某个结构的值?

注意,我需要的是lparam里面的结构与定义的变量的地址相同(地址引用),而不是简单的值COPY。
------解决方案--------------------
pb处理不了指针,要么用API,定义成ref 变量
------解决方案--------------------

// 声明 API
Subroutine CopyMemory(ref s_rect destination, ulong source, ulong length) library "kernel32.dll" Alias for "RtlMoveMemory"
Subroutine CopyMemory(ulong destination, s_rect source, ulong length) library "kernel32.dll" Alias for "RtlMoveMemory"

// other 中截获 532
int li_widthLimit = 1800
long ll_wparam
s_rect lstr_rect // 矩形结构体

ll_wparam = wparam

li_widthLimit = UnitsToPixels(li_widthLimit, XUnitsToPixels!)
CopyMemory(lstr_rect, lparam, 16)

if lstr_rect.Right - lstr_rect.Left < li_widthLimit then
choose case ll_WParam
case 1,4,7
lstr_rect.Left = lstr_rect.Right - li_widthLimit

case 2,5,8
lstr_Rect.Right = lstr_Rect.Left + li_widthLimit

case else
//
end choose
end if

CopyMemory(lparam, lstr_rect, 16)