Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trapping a windows message
Message
From
10/12/1997 15:25:47
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00064837
Message ID:
00065104
Views:
38
>>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;
}
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform