PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV 2024 → How to Handle WM_COPYDATA
How to Handle WM_COPYDATA
Iniciado por meikl, jul., 28 2022 11:49 AM - 1 resposta
Membro registado
118 mensagems
Publicado em julho, 28 2022 - 11:49 AM
Hi all,

i want forward from a not PCSoft-Application structured Data to a WinDEV-Application using the Windows-Message WM_COPYDATA.

I am able to catch this Message using the Event-Function. The LParam is a Pointer (an Address) to a COPYDATASTRUCT
COPYDATASTRUCT is structure
dwData is int //Type C : DWORD - FormatType
cbData is int //Type C : DWORD - Size
lpData is system int //Type C : PVOID - Pointer to Data
END


This Structure itself has the Member lpData also a Pointer (an Address) to the needed structured Data.

How to access the COPYDATASTRUCT and then the lpData-Member there?

thanks in advance

meikl ;)
Membro registado
118 mensagems
Publicado em julho, 29 2022 - 9:01 AM
Hi all,

found the solution myself :)

will provide a small sceleton, if someone have a similar question:

//Handle Messages from Partner-App
Procedure ManagePartnerEvents(pEvent is int, pWParam is int, pLParam is system int)
//If the Message was sent from Partner-App
IF pWParam = gnCommunicationPartnerHandle THEN
//Examine Event
SWITCH pEvent

//WM_Close (Partner wants to Terminate myself)
CASE WM_CLOSE
Close() //close myself
RESULT 1 //Message handled

//WM_USER + 1300 (Partner wants a Live-Signal)
CASE WM_ISALIVE
//TargetHandle provided in pLParam
//Signal Back, still alive, returning receiving Handle in LParam
PostMessage(pLParam,WM_USER+1,0,Handle(STC_MessageHandlerControl))
RESULT 1 //Message handled

//WM_SETTEXT (Partner sends a string)
CASE WM_SETTEXT
//String in this event is UniCode
sText is string = StringRetrieve(pLParam,srUNICODEAddress)

//Process sText ...

RESULT 1 //Message handled
//WM_COPYDATA (Partner sends structured Data)
CASE WM_COPYDATA
//Variable of COPYDATASTRUCT-Type
cds is COPYDATASTRUCT
//Copy content from Pointer pLParam
Transfer(&cds,pLParam,Dimension(cds))
//Switch on the Structure-Type
SWITCH cds.dwData
//in Case of Structure A
CASE nDataSructureAType
//Variable of Structure A
stStructA is ST_DataStructureA
//Copy content from Pointer cds.lpData
Transfer(&stStructA,cds.lpData,cds.cbData)

//Process stStructA

RESULT 1 //Message handled

//in Case of Structure B
CASE nDataSructureBType
//Variable of Structure B
stStructB is ST_DataStructureB
//Copy content from Pointer cds.lpData
Transfer(&stStructB,cds.lpData,cds.cbData)

//Process stStructB

RESULT 1 //Message handled

//Maybe more Cases

OTHER CASE

END
OTHER CASE

END
END


Thanks for reading
meikl ;)
Mensagem modificada, julho, 29 2022 - 9:09 AM