Click to See Complete Forum and Search --> : window pop up
jan s.
September 6th, 2001, 06:01 AM
Hi.
I´m wrinting on a programm thats mostly working in the background, but on some events it shall pop up.
I´m currently usiong the following code to do this:
Form1.Visible = True
Form1.SetFocus
But sometimes the window only appears the back behind other windows.
Does anyone know a solution?
Thank you
Cakkie
September 6th, 2001, 06:33 AM
The SetWindowPos API can do this for you
' This will bring your form to the front
private 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_TOP = 0
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
jan s.
September 6th, 2001, 07:18 AM
Thanks for your answer.
But the code doesnt seem to work!?
The window still appears somewhere in the back.
Are there any other functions i could try?
Cakkie
September 6th, 2001, 07:21 AM
Try changing HWND_TOP into HWND_TOPMOST,
Also, change the line Const HWND_TOP = 0 into Const HWND_TOPMOST = -1
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
jan s.
September 7th, 2001, 04:19 AM
Hi.
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
works really good, but i´m not able to bring another window in front of my program. It always stay on the top.
I tried the following code:
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
SetWindowPos Me.hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
But it doesnt show any effect.
When using this code:
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
SetWindowPos Me.hwnd, 1, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
The program shortly appears on top and then hides behind other windows again.
What i´m actually want to do is to let my pogram
appear on top of all windows but one should still be able to bring other windows in front of it.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
phunkydude
September 7th, 2001, 05:34 AM
Try setting forms zorder property. Much easier than the API and will fulfill the requirement.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.