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

Position of Popup form

Status
Not open for further replies.

Digsys

Technical User
Jun 27, 2002
170
0
0
AU
Is there a way to specify the position of a popup form relative to the main form. At the moment, when I move the main form to another position on the screen, the popup form does not move with it. Thanks
 
Digsys,

Certainly. You can use the Top and Left properties to determine a reference point (the location of a control on your form, for instance), and the MoveSize method to specify the placement of the popup form.

HTH,

Ken S.
 
Thanks Eupher. I am not too familiar with this area, can you give me a few lines of code that might get me started
 
Digsys,

I'm at home right now, but I'll be at the office this evening and will post some code for you.

Ken S.
 
Digsys,

In this example I have a popup calendar form which I want to always open immediately below a textbox on my main form. To do this, I created two public variables in a module to hold the desired Top and Left positions, then call these in the Move method in the popup form's Open event.

In a module:
Code:
Public p_TopPos As Integer
Public p_LeftPos As Integer

Then in the Click event of the command button that opens the popup form:
Code:
p_TopPos = Me.WindowTop + (Me.WindowHeight - Me.Section(acDetail).Height - 40) + Me.DateBox.Top + _
           Me.DateBox.Height
p_LeftPos = Me.WindowLeft + Me.DateBox.Left

Then in the popup form's Open event:
Code:
Me.Move Left:=p_LeftPos, Top:=p_TopPos

The only complex part of this is the calculation in the second code snippet above; you'll just have to experiment with the different elements of the window and/or control and/or sections to position your popup where you want it. But that should give you the general idea.

HTH,

Ken S.
 
How are ya Digsys . . .

Bear in mind that access is [blue]event driven![/blue] Although you can move the popup in code [blue]there's no event to tell you when the mainform is moved[/blue] so you can take action!

Best I can think of here is to set the mainforms timer to check the position of the mainform and adjust the popup accordingly. This also requires holding the mainforms position in a [blue]static variable[/blue] . . .

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks for all your suggestions. I can now determine the position of the Pop-up ok, but it is really the probelm of not being able to lock the popup to the main form, so that when it is moved about the screen, the popup moves with it. Thanks for your suggestions Aceman1. It looks messy though!!
 
Did you have a chance to look at the link I posted?
 
Yes Remou. It seems to provide the correct positioning info for the popup at the time it is run, but does not change that position as the main form is repositioned. I am really looking for a way to lock the forms together once the popup has been positioned correctly
 
So, you want not only for the popup to open in the same position relative to the main form when it opens, you want the popup (when both popup and main form are already open) to move with the main form if the form is moved? Yes, much more difficult. Of course, if you open the popup in dialog mode, the user can't drag the main form around until the popup closes. Is there a reason you need popup mode but not dialog mode?

Ken S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top