Window Always On Top

G

Guest

I have a pop-up window that will call another pop-up. I want to have the
child pop-up remain on top of the parent when the parent has the focus.

Does anyone know how to do this using the API or some other method?

Note: both forms must be pop-up.

Thanks

J.
 
S

Stefan Hoffmann

hi,
I have a pop-up window that will call another pop-up. I want to have the
child pop-up remain on top of the parent when the parent has the focus.
Does anyone know how to do this using the API or some other method?
Note: both forms must be pop-up.
SetWindowPos and HWND_TOP / HWND_TOPMOST should work.


mfG
--> stefan <--
 
G

Guest

I played around with SetWindowPos yesterday but was unsuccessful in getting
the desired results.

From the parent:

Docmd.open MyChildPopUp
Me.SetFocus
SetWindowPos Forms("MyChildPopUp").hWnd, [1/0], 0, 0, 0, 0, NOSIZE +
NOMOVE + SHOWWINDOW + NOACTIVE
 
T

TC

AFAIK, you can't. In the MS window management model, if a popup form
has the focus, it will necessarily appear on top of any other popup
form(s) that /do not/ have the focus. Your question is a bit like
asking, "how can I drive a car while simultanously being asleep in
bed?" Answer: you can't.

But I am not 100% sure of this. So feel free to post back, if you get
it to work!

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
A

Albert D.Kallal

Jezzepi said:
I have a pop-up window that will call another pop-up. I want to have the
child pop-up remain on top of the parent when the parent has the focus.

Does anyone know how to do this using the API or some other method?

Note: both forms must be pop-up.

Are you sure they both need to be?

A popup form is a form that stays on top of the existing forms, but DOES NOT
HAVE THE FOCUS!!!

So, use of the popup setting is ONLY needed if you need to display the popup
form, but CONTINUE TO EDIT AND USE existing forms. For some types if
information display or wizard forms, or even training mode help, you would
use a popup. For general data entry forms, you do NOT need a popup form.

So, why does the first form need to be popup? Why not use a model form? (do
NOT use a acDialog form!!..they are different!!).

If you make a form model, and it calls another form (also model), then that
2nd form will have to either launch more forms...or be closed to return tot
he previous form. The popup setting is NOT required here.

I have often seen a stray popup setting in a applications. Then, because it
stays on top..the developer starts a wild goose chase as they begin to set
form after form as a popup. I don't think your original main form that
launches the popup needs to be popup.....

Can't all of the regular forms be model...and then the popup form setting
can be correctly used to stay on top when you need other forms to have the
focus...but the popup form remain on top?

Correct use of acDiaog forms, model forms, and popup forms should give you
what you need here...but you have to use the right form at the right time,
or the whole thing becomes a mess......
 
G

Guest

Well TC I have to tell you that you are mistaken today. SetWindowPos does
the trick as I just took another shot at it. I'm not sure what I didn't do
yesterday, but today it works just as desired.

By the way, what is "AFAIK?"

Anyway, thanks to all!
 
G

Guest

Sorry Albert, modal does provide the desired effect. Try it and you find the
same. Someone else suggested this to me and between the two of us got the
same result.

As a stroke of luck I went back and played once more with the API call
SetWindowPos and got it to work.

So the end result is that you can have a pop-up without focus remain on top.

Again... Thanks to all
 
A

Albert D.Kallal

Jezzepi said:
Sorry Albert, modal does provide the desired effect. Try it and you find
the
same. Someone else suggested this to me and between the two of us got the
same result.

Well, in fact, it does exactly he behaviors I describe, and also what you
ask
I have a pop-up window that will call another pop-up. I want to have the
child pop-up remain on top of the parent when the parent has the focus.

The problem in the above is does the first window need to be popup? Why
can't it be model?
So the end result is that you can have a pop-up without focus remain on
top.

That is exactly what popup forms are for. Your problem is that you have two
forms set to popup..and you don't need that.....

Unless there is some reason for the first form to be popup, you don't need
to use a api here.
 
G

Guest

Hate to argue with you, but making either form modal does not keep the called
form on top.

If the child form is modal then focus can not be returned to the caller
until the child/called form is closed.

If the parent is modal or not and child is not, the child will be displayed
on top when called, but when focus returns to the parent, the child is sent
to the background.

So, again, it does not provide the desired result.

SetWindowPos is the answer to the problem and I thank you.
 
G

Guest

Post an email where you would like to see this and I will be happy meet your
request. If you want, create a yahoo email and I will send it there.

Best

J.
 
S

Stefan Hoffmann

hi,
So now you have a pop-up window 'A', that is visibly on top of another
popup window 'B', but window 'B' has the focus?

I'm keen to see that. Can you post a screenshot somewhere? The
screenshot would need to show the cursor in a field of 'B', even though
'A' was visibly on top of 'B'.
Create a pop-up window with a button to launch a second pop-up window.
The second pop-up has also an button with the following code:

PopUp

Option Compare Database
Option Explicit

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

Private Sub Befehl0_Click()
SetWindowPos Forms("PopUp1").hwnd, -1, 0, 0, 0, 0, &H53
End Sub

This will change the Z-order of the windows. See http://ste5an.de/popup.jpg


mfG
--> stefan <--
 
T

TC

But are you saying that the *non topmost* popup window can have the
focus? I'm not disagreeing that the OP can launch a series of popup
windows. I'm not disagreeing that he can change their Z-order via API
calls. I'm questioning whether one of the *non topmost* popup windows
can *have the focus*. Your example does not clarify that, on the face
of it, because you do not say what happens to the focus after the
SetWindowPos call.

The OP has offered to email me a screenshot. I will peruse that, & post
back here in due course :)

Cheers,
TC (MVP Access)
http://tc2.atspace.com
 
S

Stefan Hoffmann

hi,
But are you saying that the *non topmost* popup window can have the
focus?
Yes, PopUp2 is the second pop-up.

First PopUp1 is opened, then the command button 'Befehl0' is pressed to
open PopUp2. Up to here nothing unusual.
Pressing the command button 'Befehl0' on the PopUp2 sets PopUp1
topmost, but the focus remains on PopUp2.
I'm not disagreeing that the OP can launch a series of popup
windows. I'm not disagreeing that he can change their Z-order via API
calls. I'm questioning whether one of the *non topmost* popup windows
can *have the focus*. Your example does not clarify that, on the face
of it, because you do not say what happens to the focus after the
SetWindowPos call.
Take a closer look to the dotted frame on PopUp2.


mfG
--> stefan <--
 
A

Albert D.Kallal

If the child form is modal then focus can not be returned to the caller
until the child/called form is closed.

I did not say to make the child form model. You make the child form
popup...not model....
If the parent is modal or not and child is not, the child will be
displayed
on top when called, but when focus returns to the parent, the child is
sent
to the background.

So, again, it does not provide the desired result.

You don't need the main/parent form to be popup. You use model forms for the
parent form, and the child form simply needs to be a popup. If that child
form is popup...it will remain on top all forms at all times....

You api solution may work, but you did not need to waste all that time and
effort .....

The solution I suggest takes no code at all, but does take a simple
understanding of when to use what type of form....

We have 3 types of forms here, dialog, model, and popup. I explain the
difference between model and dialog forms here:

http://www.members.shaw.ca/AlbertKallal/Dialog/Index.html

Unfortunately, while the above explains the difference between model and
dialog forms..it does not explain popup forms...

I still don't see why a simply setting of model for the main form, and
having the child form set as poup will not work.....
 
G

Guest

Hey Al,

Listen, you make too many assumptions without knowing what the whole of the
problem or requirement is. I'm not some novice developer, OK. So lighten up
a little and have a better day. I've got what I need and it doesn't involve
anything that you have identified as a solution.

I appreciate all of your input, but you really shouldn't make such in depth
assumptions and presume to tell someone how go rework an entire application.
Some novice might just take you at your word.

Remember the first step in programming, determine the user's needs. You
skipped right over that and designed my application for me without any other
information than a simple question posed.

Just some food for thought.

J.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top