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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetForeGroundWindow

Status
Not open for further replies.

CFA

Programmer
Oct 10, 2000
9
US
We are using the SetForeGroundWindow to pull a program to the fore front.

It works inconsistently. When it does not work it makes the icon flash.

Am I missing something?

TIA

Clyde [sig][/sig]
 

Can you share the part of the code that does this? [sig]<p> Tarek<br><a href= > </a><br>The more I learn, the more I need to learn![/sig]
 
Sure Thing, 2 API defines,

Public Declare Function FindWindow Lib &quot;user32&quot; Alias &quot;FindWindowA&quot; _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SetForegroundWindow& Lib &quot;user32&quot; (ByVal hwnd As Long)

then

Public Function ShowWindow(ByVal sWindowName As String)

Dim lWindowHandle As Long
lWindowHandle = FindWindow(vbNullString, Trim(sWindowName))

If lWindowHandle <> 0 Then
SetForegroundWindow (lWindowHandle)
Else
' Error Message
End If

End Function


sWindow name = the title bar of the programs window to be pulled forward.

It works, but inconsistently.

Clyde
[sig][/sig]
 

Could it be that the title bar text is not consistent and that's why it won't work? [sig]<p> Tarek<br><a href= > </a><br>The more I learn, the more I need to learn![/sig]
 
Or --- is it that you're calling SetForeGroundWindow on an app that is minimised? (I'm guessing) [sig][/sig]
 
VB400 and Mike,

A little more info:

The program to be brought forward is a DOS app, therefore the title bar is constant. Something like &quot;RUNFORM - RUNFORM&quot;.

The DOS box is not minimised. I checked this one myself. I set the property of the link to Maximized and the screen came forward 3 times. On the fourth attempt it just flashs on the taskbar.

I do appriciate the ideas, keep 'em coming.

Clyde
[sig][/sig]
 
Can you reproduce the problem in a minimalist app? Post the code if you can; I hate things that sometimes work and sometimes not.... [sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top