>>(snip)
>>
>>>
>>>>*DECLARE INTEGER FindWindow IN user32 STRING lpClassName, STRING lpWindowName
>>>>DECLARE INTEGER BringWindowToTop IN user32 INTEGER hWindow
>>>>
>>>>*hWnd = FindWindow(Null, Thisform.Caption)
>>>>BringWindowToTop(Thisform.HWnd)
>>>>
>>>>In a method called from a countdown time ( that just runs once for testing purposes) in a form. When it fires, and goes through this code, the window stays behind any other window and/or form ( I quickly cover the form up with other forms and exes before the time expires ).
>>>>
>>>>Any idea what I am doing incorrectly ??
>>>>
>>>
>>>I just looked at the application where I'm doing something like this and I see that I'm using SetForegroundWindow rather than BringWindowToTop,
>>>
>>>Tamar
>>
>>Sorry to bother you, Tamar.
>>
>>I am having some problems implementing this. Any chance I can peek at some of the code you are referring to that is working for you?
>>
>>Thanks a bunch!
>>
>>Tommy
>
>Hopefully you will find this program useful
>*forceforeground.prg
>Lparameters tnHWND
>
>Local lnAppThread As Number, ;
> lnForeThread As Number
>Declare Long BringWindowToTop In Win32API Long
>
>Declare Long ShowWindow In Win32API Long, Long
>
>Declare Integer GetCurrentThreadId;
> In kernel32
>
>Declare Integer GetWindowThreadProcessId In user32;
> Integer HWnd, ;
> Integer @ lpdwProcId
>
>Declare Integer GetCurrentThreadId;
> In kernel32
>
>Declare Integer AttachThreadInput In user32 ;
> Integer idAttach, ;
> Integer idAttachTo, ;
> Integer fAttach
>
>Declare Integer GetForegroundWindow In user32
>
>m.lnForeThread = GetWindowThreadProcessId(GetForegroundWindow(), 0)
>m.lnAppThread = GetCurrentThreadId()
>
>If m.lnForeThread != m.lnAppThread
> AttachThreadInput(m.lnForeThread, m.lnAppThread, .T.)
> BringWindowToTop(m.tnHWND)
> ShowWindow(m.tnHWND, 3)
> AttachThreadInput(m.lnForeThread, m.lnAppThread, .F.)
>Else
> BringWindowToTop(m.tnHWND)
> ShowWindow(m.tnHWND, 3)
>Endif
>
>return
I ran this code and it still won't let me put the EXE that is running as the current thread into the ForeGround of the screen. I am running under Windows 7 SP1 and I tested it also on windows XP to see if it works on the older operating system, but it did not work as expected there either.
I am passing the Window Handle of the current thread over to the code by using Thisform.Hwnd. I have a timer which runs every 5 seconds to run the code above to push this EXE over any other exe running on the screen.
I compiled the app as an EXE and ran it. When it runs, I have 2 instances of NOTEPAD.exe running, which I place on the screen also, When I place either of the Notepads over the running EXE, the running EXE form displays the Hwnds of the notepad and the running EXE (which are different and expected). But the code does not push the running EXE over the Notepad.
So, I am at a loss again. Any suggestions or ideas ?? Thanks again for your help !
Tommy Tillman A+ NetWork+ MCP