[comp.windows.ms.programmer] API calls from Smalltalk/V Windows

korcuska@plato.ils.nwu.edu (Michael Korcuska) (05/24/91)

Newsgroups: comp.lang.smalltalk
Subject: API calls in Smalltak/V Windows
Summary: 
Expires: 
Sender: 
Reply-To: korcuska@plato (Michael Korcuska)
Followup-To: 
Distribution: comp.lang.smalltalk
Organization: The Institute for the Learning Sciences
Keywords: 

  I'm new to Smalltalk and Windows so forgive (and correct) and vocabulary
mistakes...

  I'm writing code to access IBM's MMotion board, which is a pretty nifty
video digitizer.  This is done by making calls to some DLLs IBM provides to
control the board.  So far, everything works just fine except for a call named
 'captureBitmap' which (big suprise) creates a bitmap from the incoming
video signal.  I was hoping to get some hints...

  All of the commands to control the board are send with 'send(post)Message'
where the lparam is a handle to a structure containing information for the
DLL.  In most cases I only stuff an integer or boolean into the structrue and
everything works.  The 'captureBitmap' message, however, requires me to pass
a pointer to a bitmap handle.  The C example code looks like this:

	data.mpCmdParam1 = MPFROMP(&hbmMono)
      
where 'data.mpCmdParam1' is the field I need to fill in the structure who's
handle I pass in 'sendMessage'.  

  Here is the Smalltalk code I'm currently using:

hbmMono := WinHandle new.
 "Create the command structure from the MMotion DLL"
cmdHandle := MMotionLibrary createCmdStruct: MvwnCmdCapturebitmap.
anAddress := WinAddress fromBytes: (Kernel Library globalLock: cmdHandle).
pmvwnCmd := WinMVWNCmd fromAddress: anAddress.
mvwnData := WinMVWNData new.  "This is a sub-structure of cmdStruct"

 "The above code works.  I use it for my other calls.
  Now, copy the handle into the structure"

  "this puts an address into the high word of a field in the struct"
mvwnData mpCmdParam1High: (WinAddress memoryHandleFrom: hbmMVWN).
pmvwnCmd data: mvwnData.  "Put the sub-struct into the real struct"
KernelLibrary globalUnlock: commandHandle.
UserLibrary
	sendMessage: self asParameter
	msg: (mvwnCommandMsg uShortAtOffset: 0) "ignore this garbage!"
	wparam: self owner responsePane asParameter "as well as this"
	lparam: commandHandle.

"Now I try to look at the handle I passed in and create a bitmap"
newAddress := WinAddress fromBytes: (KernelLibrary globalLock: cmdHandle).
pmvwncmd2 := WinMVWNCmd fromAddress: newAddress.
mvwnData := pmvwncmd data.
hbmMono := mvwnData mpCmdParam1High.
newHandle := WinHandle fromInteger: hbmMVWN.
aBmp := Bitmap fromHandle: newHandle.
^aBmp.

Now, it should be obvious that I'm groping here at the bottom, but if someone
would set me straight I'd appreciate it.  The code above actually seems
fairly close to me and it does create a bitmap, albeit an empty one.

Any help is appreciated.  Thanks in advance....

Michael
--
-----------------------------------------------------------------------------
Michael Korcuska                      The Institute for the Learning Sciences
korcuska@ils.nwu.edu                                  Northwestern University
-----------------------------------------------------------------------------