Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Managing Message using WindowProc

Re: Managing Message using WindowProc

From: Domenico Statuto <dstatuto_at_mbox.vol.it>
Date: 1997/12/11
Message-ID: <01bd060e$71b46b00$1ab01fc3@dstatuto>#1/1

If I understand your question, you have a reference to an object passed as lParam or wParam to a windowProcedure and want to set it to an actual object.

Put this declaration in your General section.

Declare Sub RtlMoveMemory Lib "kernel32" (dest As Any, Source As Any, ByVal Length As Long)

Then, in your window procedure,
Dim obj As MyObject

RtlMoveMemory obj, byval lParam, 4&

Now obj is an actual object of type MyObject, and set to the object whose reference was passed to the lParam of the Window Procedure. You may want some explanation: RtlMoveMemory takes whatever is in memory at the address Source, and copies it at the address dest. In this case you pass obj for dest, as VB will pass obj ByRef - i.e. its address, and pass lParam ByVal, as lParam already is a pointer, and if you passed it byref VB would make a copy of the value contained in lParam and pass the address of this copy. Last, you pass 4& as Length arg, because you are actually passing a pointer to an object and in Win32, the pointers are 4 bytes.

When you have finished using obj, *don't* Set obj = Nothing, or you will exprerience crashes. Instead, set it to nothing this way: RtlMoveMemory obj, byval 0&, 4&

Feel free to email if I can clarify something.

regards,
Domenico

-- 
Check the Common Control Replacement Project controls at:
http://www.zeode-sd.com/ccrp
Domenico Statuto

Marc Melancon <mmelanco_at_sfi-software.com> wrote in article
<66muf7$c8e$1_at_news.igs.net>...

> Is there a way in VB5 to get access to the objects (if objects are
passed)
> that are passed in WindowProc ?
>
> Function WindowProc(ByVal hw As Long, _
> ByVal uMsg As Long, _
> ByVal wParam As Long, _
> ByVal lParam As Long) As Long
>
> if a message is sent to VB via a posmessage and it passes pointer to
objects
> in wParam & lParam. I could not find a way ?????
>
>
>
Received on Thu Dec 11 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US