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

Bring window to forefront

Status
Not open for further replies.

AppSpecialist

Programmer
Jul 6, 2001
64
CA
Can some help please???... I have tried everthing to force a window to the front, but having no luck.

I have used AppActivate, ShowWindow etc... but it does not work.

I see the title bar flash in the taskbar, but the window does not come to the front.

The odd thing is if I log in as an administrator on the PC, it does work? When I log in as a regular user with no as much privs it does not work? Running XP Service pack 2.
 
App,

Try this;

Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long


Const HWND_TOPMOST = -1
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const HWND_TOP = 0
Const HWND_BOTTOM = 1

Sub TopMost(f As Form)

'put form on top
SetWindowPos f.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE

End Sub

Sub NotTopMost(f as Form)

'make it behave normally after being put on top
SetWindowPos f.hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
SetWindowPos f.hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE

End Sub

Hugh,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top