*======================================================================================== * Sends data to another program *======================================================================================== LParameter tnSrcHWND, tnDstHWND, tcData, tnIdentifier *-------------------------------------------------------------------------------------- * Declare API functions *-------------------------------------------------------------------------------------- Declare Long HeapAlloc in win32api Long, Long, Long Declare Long GetProcessHeap in win32api Declare Long HeapFree in win32api Long, Long, Long #define WM_COPYDATA 0x4A *-------------------------------------------------------------------------------------- * Create a COPYDATASTRUCT structure *-------------------------------------------------------------------------------------- Local lcStruct, lnMem lnMem = HeapAlloc( GetProcessHeap(), 0, Len(m.tcData)+12 ) lcStruct = ; toInt(m.tnIdentifier,4) + ; toInt(Len(m.tcData),4) + ; toInt(m.lnMem+12,4) + ; m.tcData Sys(2600,m.lnMem,Len(m.lcStruct),m.lcStruct) *-------------------------------------------------------------------------------------- * Send data to the other application *-------------------------------------------------------------------------------------- Local lnRetVal Declare Long SendMessage in win32api Long, Long, Long, Long lnRetVal = SendMessage( m.tnDstHWND, WM_COPYDATA, m.tnSrcHWND, lnMem ) *-------------------------------------------------------------------------------------- * Free up memory *-------------------------------------------------------------------------------------- HeapFree( GetProcessHeap(), 0, m.lnMem ) Return m.lnRetValThe receing side (inventory app):
*======================================================================================== * Set up a handler to receive data posted with WM_COPYDATA *======================================================================================== #define WM_COPYDATA 0x004A _Screen.WindowState =1 Public goCOPYDATA goCOPYDATA = CreateObject("COPYDATA_Handler") ? "handle: ", Transform(goCOPYDATA.hWND,"@0") Define Class COPYDATA_Handler as Form Procedure Init BindEvent( This.hWND, WM_COPYDATA, This, "WndProc" ) EndProc Function WndProc Lparameters tnHwnd, tnMsg, tnWParam, tnLParam Local lcStruct, lnIdentifier, lcData lcStruct = Sys(2600,m.tnLParam,12) lnIdentifier = FromInt(Left(m.lcStruct,4)) lcData = Sys(2600,FromInt(Right(m.lcStruct,4)),FromInt(SubStr(m.lcStruct,5,4))) _Screen.WindowState = 0 ? lnIdentifier, lcData Return 99 EndDefine