|
-
September 6th, 2001, 06:01 AM
#1
window pop up
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
-
September 6th, 2001, 06:33 AM
#2
Re: window pop up
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
private Sub Command1_Click()
SetWindowPos me.hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
End Sub
Tom Cannaerts
[email protected]
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
-
September 6th, 2001, 07:18 AM
#3
Re: window pop up
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?
-
September 6th, 2001, 07:21 AM
#4
Re: window pop up
Try changing HWND_TOP into HWND_TOPMOST,
Also, change the line Const HWND_TOP = 0 into Const HWND_TOPMOST = -1
Tom Cannaerts
[email protected]
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
-
September 7th, 2001, 04:19 AM
#5
Re: window pop up
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.
Thank you
-
September 7th, 2001, 04:41 AM
#6
Re: window pop up
SetWindowPos Me.hwnd, -1, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
SetWindowPos Me.hwnd, -2, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE
Tom Cannaerts
[email protected]
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
-
September 7th, 2001, 05:34 AM
#7
Re: window pop up
Try setting forms zorder property. Much easier than the API and will fulfill the requirement.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|