*** >*** dcappfocus.prg >*** > >* 2006/09/16 10:11:05 >* Visual FoxPro 09.00.0000.3504 for Windows > >*** based on Doug Hennig's article >*** ---------------------------------- >*** > >#include include\WinEvents.H > > >DEFINE CLASS frmwinevents AS form > Height = 214 > Width = 494 > ShowWindow = 2 > Caption = "Windows Events Test" > stevka="" > noldproc = 0 > nshnotify = 0 > Name = "frmWinEvents" > > PROCEDURE Init > * Declare the Windows API functions we'll use. > 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') > > ENDPROC > >******************************* > PROCEDURE Destroy > * Unregister us from receiving shell events, unbind all events from our > * window and _vfp, and redisplay VFP. > > with This > unbindevents(_vfp.hWnd) > endwith > ENDPROC > >******************************* > PROCEDURE HandleWindowsMessage > lparameters hWnd, ; > Msg, ; > wParam, ; > lParam > local lnResult > lnResult = CallWindowProc(This.nOldProc, hWnd, Msg, wParam, lParam) > return lnResult > ENDPROC > > >******************************* > PROCEDURE HandleEvents > lparameters hWnd, ; > Msg, ; > wParam, ; > lParam > local lcCaption, ; > lnParm, ; > lcPath > do case > > * Handle an activate or deactivate event. > case Msg = WM_ACTIVATE > do case > > * Handle a deactivate event. > case wParam = WA_INACTIVE > this.stevka=_cliptext > _cliptext="" > > * Handle an activate event (task switch or clicking on the title bar). > case wParam = WA_ACTIVE > IF !EMPTY(_cliptext) > ELSE > _cliptext=this.stevka > endif > * Handle an activate event (clicking in the client area of the window). > case wParam = WA_CLICKACTIVE > IF !EMPTY(_cliptext) > ELSE > _cliptext=this.stevka > endif > endcase > ENDCASE > *-- this plays the role of dodefault(): > return This.HandleWindowsMessage(hWnd, Msg, wParam, lParam) > ENDPROC > >ENDDEFINE >* >