FUNCTION init() > >declare integer GetWindowLong in Win32API integer hWnd, integer nIndex >declare integer CallWindowProc in Win32API ; > integer lpPrevWndFunc, integer hWnd, integer Msg, integer wParam, integer lParam > >* Get a handle for the VFP Windows event handler. >This.nOldProc = GetWindowLong(_screen.hWnd, GWL_WNDPROC) > >* Bind to the Windows events we're interested in. >bindevent(_vfp.hWnd, WM_ACTIVATE, This, 'HandleEvents') >RETURN > >*- > >FUNCTION HandleEvents >LPARAMETERS HWND, Msg, wParam, tlParam >LOCAL lcCaption, lnParm, lcPath > >IF Msg = WM_ACTIVATE > DO CASE > CASE wParam = WA_INACTIVE > * Handle a deactivate event. > THIS.lastwontop=WONTOP() > * Handle an activate event (task switch or clicking on the title bar, clicking in the client area of the window). > > CASE INLIST(wParam, WA_ACTIVE, WA_CLICKACTIVE) > IF NOT EMPTY(THIS.lastwontop) > ACTIVATE WINDOW (THIS.lastwontop) > ENDIF > this.lastwontop="" > ENDCASE >ENDIF >*-- this plays the role of dodefault(): >RETURN THIS.HandleWindowsMessage(HWND, Msg, wParam, tlParam) > >*- > >FUNCTION HandleWindowsMessage >LPARAMETERS hWnd, nMsg, wParam, lParam >LOCAL nResult > >nResult = CallWindowProc(This.nOldProc, hWnd, nMsg, wParam, lParam) >RETURN nResult>