Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Working with sockets
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01339151
Message ID:
01339918
Views:
27
I have found some code you have posted a while ago:
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.lnRetVal
That code shows how to send a mesage to another application (.Net in my case).
But how do I know what m.tnDstHWND is? Is it my .Net program window handler?
Also I am bit confused: Does the c# progran need to search for a VFP window at all?
Or it is just:
protected override void WndProc(ref System.Windows.Forms.Message m)
{
switch (m.Msg)
{
case WM_COPYDATA:
// do something
break;
}
base.WndProc(ref m);
}
to process a message from VFP?


>Hi Mark,
>
>>Will I need an infinite loop in .Net in order to constantly pull data from that window?
>
>In .NET you create a simple form and then override the WndProc method:
>
>protected override void WndProc(ref System.Windows.Forms.Message m)
>{
>  switch (m.Msg)
>  {
>  case WM_COPYDATA:
>    // do something
>    break;
>  }
>base.WndProc(ref m);
>}
>
>This method is automatically called when the VFP application sends data. You don't need an infinite loop if you call Application.Run(form).
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform