From: MacDermott on
My client asked for functionality which would let his users save the
position of a form, so that the next time it's opened (on that system), it
returns to the saved position. I achieved this using the GetWindowPlacement
and SetWindowPlacement API calls.
That worked fine, until my client noticed that if the form being
repositioned (this occurs in the OnLoad event) has been opened acDialog, it
loses this property.
I haven't even been able to figure out a way to tell whether the form is
opened acDialog.

Any ideas?
TIA


From: Jon Lewis on
What may be happening here is that normally the SetWindowsPlacement call
will position the form relative to the main Access window but if the form is
opened acDialog then the form will be positioned relative to the Screen.

If a form is opened acDialog then it's presumably done with Docmd.OpenForm,
so you can use the OpenArgs parameter to indicate this. Then your Form's On
Load event can check the OpenArgs value and adjust the SetWindowPlacement
call accordingly to take into account the Access window position in the
acDialog case.

HTH
Jon




"MacDermott" <macdermott(a)NoSpam.com> wrote in message
news:u6GCPRs1KHA.1420(a)TK2MSFTNGP02.phx.gbl...
> My client asked for functionality which would let his users save the
> position of a form, so that the next time it's opened (on that system), it
> returns to the saved position. I achieved this using the
> GetWindowPlacement and SetWindowPlacement API calls.
> That worked fine, until my client noticed that if the form being
> repositioned (this occurs in the OnLoad event) has been opened acDialog,
> it loses this property.
> I haven't even been able to figure out a way to tell whether the form
> is opened acDialog.
>
> Any ideas?
> TIA
>


From: MacDermott on
Thank you so much for your input on this, Jon!

Perhaps I didn't explain the problem properly:
When I open a form with acDialog (yes, I'm using DoCmd.OpenForm), the
form placement is correct.
The problem is that after it has been repositioned, it's no longer modal;
although it's pop-up (always remains displayed as the top layer),
the user can work in the form below it.
The whole point of opening it acDialog was to prevent the user from
working in the other form until this one is closed.

Any ideas?
TIA

"Jon Lewis" <jon.lewis(a)cutthespambtinternet.com> wrote in message
news:endnngz1KHA.5816(a)TK2MSFTNGP04.phx.gbl...
> What may be happening here is that normally the SetWindowsPlacement call
> will position the form relative to the main Access window but if the form
> is opened acDialog then the form will be positioned relative to the
> Screen.
>
> If a form is opened acDialog then it's presumably done with
> Docmd.OpenForm, so you can use the OpenArgs parameter to indicate this.
> Then your Form's On Load event can check the OpenArgs value and adjust the
> SetWindowPlacement call accordingly to take into account the Access window
> position in the acDialog case.
>
> HTH
> Jon
>
>
>
>
> "MacDermott" <macdermott(a)NoSpam.com> wrote in message
> news:u6GCPRs1KHA.1420(a)TK2MSFTNGP02.phx.gbl...
>> My client asked for functionality which would let his users save the
>> position of a form, so that the next time it's opened (on that system),
>> it returns to the saved position. I achieved this using the
>> GetWindowPlacement and SetWindowPlacement API calls.
>> That worked fine, until my client noticed that if the form being
>> repositioned (this occurs in the OnLoad event) has been opened acDialog,
>> it loses this property.
>> I haven't even been able to figure out a way to tell whether the form
>> is opened acDialog.
>>
>> Any ideas?
>> TIA
>>
>
>


From: Jon Lewis on
Sorry - I misunderstood. I can't reproduce the problem though. I'm opening
frm2 from a Command Button on frm1:

On Error GoTo Err_Command0_Click
DoCmd.OpenForm "frm2", , , , , acDialog
MsgBox "frm2 closed!"
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

This is what's in frm2 On Load:

Dim WinEst As WINDOWPLACEMENT
Dim rtn As Long
Dim rct As RECT
Dim rct2 As RECT

rtn = GetWindowPlacement(Me.hwnd, WinEst)
rct = WinEst.rcNormalPosition
rct2.Bottom = (rct.Bottom - rct.Top) + 10
rct2.Left = 10
rct2.Right = (rct.Right - rct.Left) + 10
rct2.Top = 10

WinEst.Length = Len(WinEst)
WinEst.showCmd = SW_SHOWNORMAL
WinEst.rcNormalPosition = rct2

rtn = SetWindowPlacement(Me.hwnd, WinEst)

frm2's Modularity is preserved and the MsgBox from frm1 Command0 On Click
doesn't appear until after frm2 is closed.

Is this similar to what you are doing or do you have something else going on
to affect frm2's window mode? You mentioned "if the form ... has been
opened acDialog". Is it opened acWindowNormal sometimes? Could it be
already open (maybe hidden) when the OpenForm acDialog command is executed?

Jon

"MacDermott" <macdermott(a)NoSpam.com> wrote in message
news:esKRqE%231KHA.140(a)TK2MSFTNGP05.phx.gbl...
> Thank you so much for your input on this, Jon!
>
> Perhaps I didn't explain the problem properly:
> When I open a form with acDialog (yes, I'm using DoCmd.OpenForm), the
> form placement is correct.
> The problem is that after it has been repositioned, it's no longer modal;
> although it's pop-up (always remains displayed as the top layer),
> the user can work in the form below it.
> The whole point of opening it acDialog was to prevent the user from
> working in the other form until this one is closed.
>
> Any ideas?
> TIA
>
> "Jon Lewis" <jon.lewis(a)cutthespambtinternet.com> wrote in message
> news:endnngz1KHA.5816(a)TK2MSFTNGP04.phx.gbl...
>> What may be happening here is that normally the SetWindowsPlacement call
>> will position the form relative to the main Access window but if the form
>> is opened acDialog then the form will be positioned relative to the
>> Screen.
>>
>> If a form is opened acDialog then it's presumably done with
>> Docmd.OpenForm, so you can use the OpenArgs parameter to indicate this.
>> Then your Form's On Load event can check the OpenArgs value and adjust
>> the SetWindowPlacement call accordingly to take into account the Access
>> window position in the acDialog case.
>>
>> HTH
>> Jon
>>
>>
>>
>>
>> "MacDermott" <macdermott(a)NoSpam.com> wrote in message
>> news:u6GCPRs1KHA.1420(a)TK2MSFTNGP02.phx.gbl...
>>> My client asked for functionality which would let his users save the
>>> position of a form, so that the next time it's opened (on that system),
>>> it returns to the saved position. I achieved this using the
>>> GetWindowPlacement and SetWindowPlacement API calls.
>>> That worked fine, until my client noticed that if the form being
>>> repositioned (this occurs in the OnLoad event) has been opened acDialog,
>>> it loses this property.
>>> I haven't even been able to figure out a way to tell whether the form
>>> is opened acDialog.
>>>
>>> Any ideas?
>>> TIA
>>>
>>
>>
>
>


From: MacDermott on
Try this:
Put a second command button on frm1 - have it pop up some sort of
msgbox.
Now click Command0 to open frm2.
Go back and click the second button on frm1.
I get a msgbox in this scenario - do you?
In contrast, if I delete (or comment out) the code that changes the position
of frm2,
frm1 can't get the focus after frm2 has been opened.

Can you reproduce this?

TIA!


"Jon Lewis" <jon.lewis(a)cutthespambtinternet.com> wrote in message
news:uvMSHm%231KHA.2156(a)TK2MSFTNGP02.phx.gbl...
> Sorry - I misunderstood. I can't reproduce the problem though. I'm
> opening frm2 from a Command Button on frm1:
>
> On Error GoTo Err_Command0_Click
> DoCmd.OpenForm "frm2", , , , , acDialog
> MsgBox "frm2 closed!"
> Exit_Command0_Click:
> Exit Sub
> Err_Command0_Click:
> MsgBox Err.Description
> Resume Exit_Command0_Click
>
> This is what's in frm2 On Load:
>
> Dim WinEst As WINDOWPLACEMENT
> Dim rtn As Long
> Dim rct As RECT
> Dim rct2 As RECT
>
> rtn = GetWindowPlacement(Me.hwnd, WinEst)
> rct = WinEst.rcNormalPosition
> rct2.Bottom = (rct.Bottom - rct.Top) + 10
> rct2.Left = 10
> rct2.Right = (rct.Right - rct.Left) + 10
> rct2.Top = 10
>
> WinEst.Length = Len(WinEst)
> WinEst.showCmd = SW_SHOWNORMAL
> WinEst.rcNormalPosition = rct2
>
> rtn = SetWindowPlacement(Me.hwnd, WinEst)
>
> frm2's Modularity is preserved and the MsgBox from frm1 Command0 On Click
> doesn't appear until after frm2 is closed.
>
> Is this similar to what you are doing or do you have something else going
> on to affect frm2's window mode? You mentioned "if the form ... has been
> opened acDialog". Is it opened acWindowNormal sometimes? Could it be
> already open (maybe hidden) when the OpenForm acDialog command is
> executed?
>
> Jon
>
> "MacDermott" <macdermott(a)NoSpam.com> wrote in message
> news:esKRqE%231KHA.140(a)TK2MSFTNGP05.phx.gbl...
>> Thank you so much for your input on this, Jon!
>>
>> Perhaps I didn't explain the problem properly:
>> When I open a form with acDialog (yes, I'm using DoCmd.OpenForm), the
>> form placement is correct.
>> The problem is that after it has been repositioned, it's no longer modal;
>> although it's pop-up (always remains displayed as the top layer),
>> the user can work in the form below it.
>> The whole point of opening it acDialog was to prevent the user
>> from working in the other form until this one is closed.
>>
>> Any ideas?
>> TIA
>>
>> "Jon Lewis" <jon.lewis(a)cutthespambtinternet.com> wrote in message
>> news:endnngz1KHA.5816(a)TK2MSFTNGP04.phx.gbl...
>>> What may be happening here is that normally the SetWindowsPlacement call
>>> will position the form relative to the main Access window but if the
>>> form is opened acDialog then the form will be positioned relative to the
>>> Screen.
>>>
>>> If a form is opened acDialog then it's presumably done with
>>> Docmd.OpenForm, so you can use the OpenArgs parameter to indicate this.
>>> Then your Form's On Load event can check the OpenArgs value and adjust
>>> the SetWindowPlacement call accordingly to take into account the Access
>>> window position in the acDialog case.
>>>
>>> HTH
>>> Jon
>>>
>>>
>>>
>>>
>>> "MacDermott" <macdermott(a)NoSpam.com> wrote in message
>>> news:u6GCPRs1KHA.1420(a)TK2MSFTNGP02.phx.gbl...
>>>> My client asked for functionality which would let his users save the
>>>> position of a form, so that the next time it's opened (on that system),
>>>> it returns to the saved position. I achieved this using the
>>>> GetWindowPlacement and SetWindowPlacement API calls.
>>>> That worked fine, until my client noticed that if the form being
>>>> repositioned (this occurs in the OnLoad event) has been opened
>>>> acDialog, it loses this property.
>>>> I haven't even been able to figure out a way to tell whether the
>>>> form is opened acDialog.
>>>>
>>>> Any ideas?
>>>> TIA
>>>>
>>>
>>>
>>
>>
>
>