Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trapping a windows message
Message
 
À
10/12/1997 15:25:47
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00064837
Message ID:
00065124
Vues:
33
>>>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
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform