>Public oForm >oForm = Newobject("ffw") >oForm.Show() > >Define Class ffw As Form > > DoCreate = .T. > Caption = "Form1" > Name = "Form1" > > Add Object timer1 As Timer With ; > Top = 204, ; > Left = 312, ; > Height = 23, ; > Width = 23, ; > Interval = 5000, ; > Name = "Timer1" > > Add Object text1 As TextBox With ; > Height = 23, ; > Left = 12, ; > Top = 24, ; > Width = 144, ; > Name = "Text1" > > Procedure forceforegroundwindow > Lparameters thWnd > > Declare Integer AttachThreadInput In user32; > INTEGER idAttach,; > INTEGER idAttachTo,; > INTEGER fAttach > > Declare Integer GetForegroundWindow In user32 > > Declare Integer GetWindowThreadProcessId In user32; > INTEGER HWnd,; > INTEGER lpdwProcessId > > Declare Integer IsIconic In user32; > INTEGER HWnd > > Declare Integer SetForegroundWindow In user32; > INTEGER HWnd > > Declare Integer ShowWindow In user32; > INTEGER HWnd,; > INTEGER nCmdShow > > #Define SW_RESTORE 9 > #Define SW_SHOW 5 > > Local lnThreadID1 > Local lnThreadID2 > > *!* > *!* Nothing to do if already in foreground. > *!* > If Not thWnd = GetForegroundWindow() > *!* > *!* First need to get the thread responsible for this window, > *!* and the thread for the foreground window. > *!* > m.lnThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0) > m.lnThreadID2 = GetWindowThreadProcessId(m.thWnd, 0) > *!* > *!* By sharing input state, threads share their concept of > *!* the active window. > *!* > If m.lnThreadID1 <> m.lnThreadID2 > AttachThreadInput(m.lnThreadID1, m.lnThreadID2, 1) > SetForegroundWindow(m.thWnd) > AttachThreadInput(m.lnThreadID1, m.lnThreadID2, 0) > Else > SetForegroundWindow(m.thWnd) > Endif > *!* > *!* Restore and repaint > *!* > If IsIconic(m.thWnd) <> 0 > ShowWindow(m.thWnd, SW_RESTORE) > Else > ShowWindow(m.thWnd, SW_SHOW) > Endif > Endif > Endproc > > Procedure timer1.Timer > Thisform.forceforegroundwindow(_vfp.HWnd) > Thisform.text1.SetFocus > Endproc > >Enddefine >>