Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture Window Message

Status
Not open for further replies.

cnguyen

Programmer
Dec 15, 2002
21
0
0
US
I want to capture window message in VFP, could someone please point me to the right direction..
I ran to one of the VB example below but got stuck on one of the function and don't know how to convert it to VFP code.
"AddressOf WindowProc" = ??? in VFP should it be WindowProc()???
please help.


VB code:
Declare Function SetWindowLong Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function CallWindowProc Lib "user32" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long,
Public Const GWL_WNDPROC = (-4)

Dim PrevProc As Long
Public Sub HookForm(F As Form)
PrevProc = SetWindowLong(F.hwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
WindowProc = CallWindowProc(PrevProc, hwnd, uMsg, wParam, lParam)
If uMsg = WM_DRAWCLIPBOARD Then
MsgBox "Clipboard changed ..."
End If
End Function


VFP Code:
DECLARE INTEGER SetWindowLong IN user32;
INTEGER hWnd,;
INTEGER nIndex,;
INTEGER dwNewLong
DECLARE INTEGER CallWindowProc IN user32;
INTEGER lpPrevWndFunc,;
INTEGER hwnd,;
INTEGER Msg, ;
INTEGER wParam
Public GWL_WNDPROC = -4

PrevProc = SetWindowLong(THISFORM.hwnd, GWL_WNDPROC, AddressOf WindowProc)
 
Cnguyen,

You may be able to do this in VFP 9 using VFP 9's ability to BindEvent() to Windows messages.

I believe you can still download the VFP 9 beta for free - might be worth checking out.

Malcolm
 
Malcom,

I believe you can still download the VFP 9 beta for free

My understanding is that it expires today.

But the Help file should still be on line.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top