Popup form gets moved, closed, want to reopen popup in same location it was moved to

Rx_

Nothing In Moderation
Local time
Today, 16:44
Joined
Oct 22, 2009
Messages
2,795
My guess is that in the form close event, there are a couple of run time x,y parameters to save to a forms's variable.
Then reuse those numbers the next time the popup is opened again.

Guessing in the popup form's close event, save the left and top into the parent form's level variable using.
Debug.Print Me.WindowLeft, Me.WindowTop

Then pass them back into the pop-up as openarg or some other process.
Me.Move Left:=220, Top:=545

Anyone have any suggestions?
 
Save the form's Me.WindowLeft and Me.WindowTop property values to a table on Form_Close or Form_Unload().

Then, in Form_Open(), check for these values in the table, and if they are valid, do . . .
Code:
Me.Move[I] <left>, <top>[/I]
 
That worked on our developer monitor (dual monitors)
It works on Citrix the same on the developer monitors.

When the user tried it on the larger hi-resolution, larger Triple monitors...
It worked if the popup box stayed close.
The test values were in a text box to make the values visible.
It seems that if the values were over 32,000, then the value saved was Negative. Then the pop was invisible.

we just sent the values directly to a text box. Maybe some kind of implicit convertions to Int?
Wrapped the values with a cLng
DoCmd.OpenForm "frmsr_PopSHL_BHL" ' Popup form for all Wells SHLNBHL listing
Forms!frmsr_PopSHL_BHL.Move Left:=CLng(Me.txtLeftPop), Top:=CLng(Me.txtTopPop)

Private Sub Form_Close()
On Error Resume Next
[Forms]![frmsr_NewWellEntry_cjc]![txtTopPop].ControlSource = "=" & Me.WindowTop
[Forms]![frmsr_NewWellEntry_cjc]![txtLeftPop].ControlSource = "=" & Me.WindowLeft
DoEvents
End Sub
Do you think the above performs some kind of implicit conversion that is limited to 32,000?
 
I think WindowsTop gives an integer and is limited to 32600 approx ( 2^16/2 ). Maybe a higher value on the hi res screens is returning the higher value as a negative integer. Try adding 2 ^16 to the negative value. (I don't have suitable test gear to check). HTH but I would be interested in hearing of results please.
 
I use code to store a form's position and size within the registry. The code I use was originally taken from the Access cookbook. It's a bit more complicated , as it positions the form relative to the access desktop parent window.
 
Thanks, I use to store it in the registry in the VB programming days.
if it is the Top value itself that is Limited to an Integer, would it matter if it was saved to the registry, variable or text box?
 
Its not importent where you save it.
Saving to registery will save it over sessions.

WindowsLeft as nd WindowdTop will give the position relative to the Access main window.
 
Private Sub lst_ID_SHLBHL_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Debug.Print "Pop up top is : " & CLng(Me.WindowTop) & " Left: "; Me.WindowLeft
End Sub

With dual Monitors, it is actually the LEFT that exceeds 32,000
It is what MSACCESS Me.WindowLeft is reporting.
Once the location (relative to the main window) exceeds 32,000 - it turns into a negative number (my guess is an overflow)

Perhaps this is Microsoft's way of selling single monitor Tablets? LOL
But, it is a failure of the MSAccess Development group keeping up with basic technology.
 
RX

the code I referred to actually used api calls as follows, and uses 4 byte longs rather than integers. This might work transparently with bigger windows.

Code:
 Type acbTypeRect
    lngX1 As Long
    lngY1 As Long
    lngX2 As Long
    lngY2 As Long
End Type
 Declare Function acb_apiGetParent Lib "user32" Alias "GetParent" (ByVal hwnd As Long) As Long
Declare Sub acb_apiMoveWindow Lib "user32" Alias "MoveWindow" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long)
Declare Sub acb_apiGetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Long, lpRect As acbTypeRect)
Declare Function GetWindowLongW Lib "User32.dll" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
it uses 4 co-ordinates for a window, to resize as well as reposition.

hope this helps

here's a link

http://www.icodeguru.com/database/access.cookbook/0596006780_accesscook2-chp-2-sect-10.html
 
Thanks, now that (the API) I totally get. Would agree that it would solve the problem.
(still... c'mon Microsoft - why do you have to leave a bug in the system in the first place?)

One other wrinkle for me. My Access Development is 32 bit, my Citrix Access is 64 bit.
Some of my API work on the desktop, but not on the Citrix deployment.

Will let this idea simmer while we iron out some wrinkles in today's release.
I am tempted to just keep the popup 10% contained in the parent form. In other words, not let the user move the popup to another monitor. People have 3 or 4 monitors.

Thanks for your code! I saw it elsewhere.
I prefer one from a known source.
Guess at this point, I will mark the question solved.
We know what is broken, we know what has to be done.
 

Users who are viewing this thread

Back
Top Bottom