>>>>>Is there a way to trap the a WM_USER message sent to the main foxpro window?
>>>>
>>>>Albert,
>>>>
>>>>There's no way to "trap" (as you would with a keystroke), but setting a timer up to call the PeekMessage API function will allow you to simulate this behavior.
>>>>
>>>>
>>>>hth,
>>>>
>>>>George
>>>
>>>Thanks,
>>>
>>>What about hooking the system messages with SetWindowsHookEx()?
>>>
>>>The following is a skelleton of what I am considering:
>>>
>>>HHOOK SetWindowsHookEx(
>>>
>>> int idHook, // type of hook to install
>>> HOOKPROC hkprc, // address of hook procedure
>>> HINSTANCE hMod, // handle of application instance
>>> DWORD dwThreadID // identity of thread to install hook for
>>> );
>>>
>>>typedef struct tagCWPSTRUCT { // cwps
>>>
>>> // Specifies additional information about the message.
>>> // The exact meaning depends on the message value.
>>> LPARAM lParam;
>>> // Specifies additional information about the message.
>>> // The exact meaning depends on the message value.
>>> WPARAM wParam;
>>> // Specifies the message.
>>> UINT message;
>>> // Identifies the window to receive the message.
>>> HWND hwnd;
>>>} CWPSTRUCT;
>>>
>>>myHook(WH_CALLWNDPROC, &myCallback, VFP_HInstance, VFP_ThreadID);
>>>
>>>// VFP_HInstance, VFP_ThreadID : How do I get these?
>>>
>>>LRESULT CALLBACK myCallback(
>>>
>>> int nCode, // hook code
>>> WPARAM wParam, // current-process flag
>>> LPARAM lParam // address of structure with message data
>>> )
>>>{
>>> if (lParam->message == MESSAGE_TO_TRAP && lParam->hwnd == VFP_hwnd)
>>> {
>>> PASS MESSAGE BACK TO FOXPRO CODE
>>> }
>>>
>>> if (nCode == HC_Action)
>>> {
>>> PROCESS THE MESSAGE
>>> }
>>>
>>> return (nCode < 0) ? CallNextHookEx(), 0;
>>>}
>>
>>Albert,
>>
>>I'll plead ignorance about this. I'm not sure that you can implement a hook without using native code. Further, I think I remember from somewhere that you can't access callbacks from VFP. I could very well be wrong about either or both of these. Maybe someone else can clarify this for you.
>>
>>Without knowing exactly what you're trying to do here, it's a little tough for me to comment further. However, enabling FoxPro's DDE features could serve the same purpose without running into the biggest potential problem associated with hooks: system performance degradation.
>>
>>hth,
>>
>>George
>
>I would write an .FLL and interface through the VFP API. The callback would be written in C.
>
>The code in the callback would be minimal, but there would still be call and processing overhead. I am planning to use DDE for this application, but I may be forced to use this technique in the future when I don't have a say. Another plus for DDE is the option of NetDDE. DDE is slow for transfering large blocks of data and you often have to parse the data block, but all I need is a connection to notify my App of the message. The reason I began investigating the Windows message communication is because it is currently implemented for a set of C++ Apps whith which the VFP Apps work.
Albert,
This is just an FYI thing, that I got from the Microsoft Win32.hlp file.
"Hooks tend to slow down the system because they increase the amount of processing the system must perform for each message. You should install a hook only when necessary, and remove it as soon as possible."
George
George
Ubi caritas et amor, deus ibi est