Results 1 to 12 of 12
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re-sizing pop up forms (Access 97 SR2)

    Hi all,

    I have a database which is designed to be run in a maximized window. I have a pop up form in the database and i'd like to be able to adjust the properties on 1 of the controls if the pop up box is re-sized.
    I tried to use the on-resize event and it works fine when the forms are er... in restored down mode (not maximized but not minimized), however, it will not work when the forms in the database are maximized.
    Can anyone tell me how to capture if a pop-up form has been/is being resized while in maximized mode?

    Any help would be much appreciated.

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Re-sizing pop up forms (Access 97 SR2)

    Not sure what you mean by "when the forms in the database are maximized"; using the form's Resize event should be triggered whenever you maximize, minimize, or restore form. Here are some functions which may or may not be helpful, which use the Windows IsIconic and IsZoomed API functions to determine window state of either open form or Access application window:

    Option Compare Database
    Option Explicit

    Private Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function IsZoomed Lib "user32" (ByVal hwnd As Long) As Long

    Private Function IsMaximized(hwnd As Long) As Boolean
    If IsZoomed(hwnd) = 0 Then
    IsMaximized = False
    Else
    IsMaximized = True
    End If
    End Function

    Private Function IsMinimized(hwnd As Long) As Boolean
    If IsIconic(hwnd) = 0 Then
    IsMinimized = False
    Else
    IsMinimized = True
    End If
    End Function

    Private Function IsRestored(hwnd As Long) As Boolean
    If IsMaximized(hwnd) = False And IsMinimized(hwnd) = False Then
    IsRestored = True
    Else
    IsRestored = False
    End If
    End Function

    Private Function GetWindowState(hwnd As Long) As String

    If IsMaximized(hwnd) Then
    GetWindowState = "Maximized"
    ElseIf IsMinimized(hwnd) Then
    GetWindowState = "Minimized"
    Else
    GetWindowState = "Restored"
    End If

    End Function

    When using these functions with form, use form's hwnd property, for Access application window use Application.hWndAccessApp function to return app window's hwnd. (The hwnd is a 32-bit number (Long Integer in VB) used by Windows to keep tabs on all open windows.) I've attached sample db with simple test form that demonstrates these functions. The form's Resize event:

    Private Sub Form_Resize()

    Dim strMsg As String

    strMsg = "Form: " & GetWindowState(Me.hwnd) & vbCrLf & _
    "Application: " & GetWindowState(Application.hWndAccessApp)

    MsgBox strMsg, vbInformation, "FORM RESIZE EVENT"

    End Sub

    This triggered whenever form resized using either form's Option Group or the standard buttons in upper right corner. The window state shown in msgbox will reflect the state AFTER resizing has taken place. You can test for current form/app window state and perform some action based on whether form and/or app window is maximized, minimized, or restored ("normal" in Windows-ese) state. Remember you can enable/disable form's Min & Max buttons. Don't know of simple way to capture the db container window's hwnd (rather than application window) but the db window should not be visible to end users in any event.

    Note: The API & other functions declared as Private in form module in sample db, to use these for any form in db move functions to standard code module and declare all as Public vice Private. Sample db converted to A97 format from A2K.

    HTH
    Attached Files Attached Files

  3. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Re-sizing pop up forms (Access 97 SR2)

    Thanks for that Mark, looks quite involved compared with the on-event resize so before I do, can I just clarify my post. It is not really to do with the minimize/maximize buttons in the corner and more to do with when you click on a forms border and drag it.

    Im not talking about the database applications min/max either.

    If you click the button in between min & max (2 boxes) then that sets all of the objects that are in the database to be the same (no idea what this state is called, sorry).
    If maximized then obviously you can't move the border, and if its in the above state you can size it as you please.
    However, if the form is set to be a popup then you CAN move the border even if the form is in maximize mode - doing this does not trigger the on-resize event though!

    Does the code in your post pick up on manually dragging a pop up forms border even when the databases forms are in the floating window mode?

    If its still unclear, pls reply and ill make an example and attach it.

    Regards,
    Phil

  4. #4
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Re-sizing pop up forms (Access 97 SR2)

    I'm still not clear on the problem. If a form is restored, if you resize by dragging border with mouse, the Resize event is triggered when you release the mouse button. If the form is maximized, whether popup or not, I am unable to resize or reposition by dragging border if the application window is also maximized. If the application window is restored, the maximized form will fill the application window, not the entire screen. If you resize application window, you are also resizing form, and Resize event is triggered. This only applies to a non-popup form. A popup form "floats" above the application window and if maximized will fill entire screen and cannot be resized by dragging border.

    Recommend check these MSKB articles that explain how windows interact in Access:

    ACC2000: Maximizing One Form Maximizes All Forms

    ACC2000: Resize Event Fires Unexpectedly When Changing Form Focus

    ACC2000: How to Determine If a Form Is Maximized or Minimized

    As noted in Art 210123:

    SYMPTOMS
    When you maximize a form, all other forms that are open are also maximized. You cannot maximize one form independent of the other open forms.

    CAUSE
    Microsoft Access is a multiple document interface (MDI) application. The default behavior for an MDI document is for all child windows to be maximized when one is maximized. This behavior occurs in many applications. For example, if you maximize a document window in Microsoft Excel 2000, all other document windows will also be maximized.

    The article has some suggestion "solutions" which are a bit convoluted in nature. Article 208358 notes:

    "When the form that is losing focus is in a maximized state and you are changing focus to another maximized object, the form's Resize event occurs. All multiple-document interface (MDI) objects that do not have focus are automatically restored to a windowed state behind the maximized MDI form that has focus. When the current form loses focus, Windows automatically restores it to a windowed state, causing the Resize event to occur. "

    I'm not sure if that clarifies or confuses the issue. Anyway the behavior described in these articles is what I think you referring to. You may be able to use form Activate event to prevent this behavior in some cases. If I have a form that I want to "stay put" when another form closes & focus moves back to this form, I may use something like:

    Private Sub Form_Activate()
    DoCmd.Maximize
    End Sub

    This'll cause form to maximize when it gets focus back. If you want the form to stay restored, use DoCmd.Restore. Note that the Activate event takes place AFTER the Resize event.

    HTH

  5. #5
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Re-sizing pop up forms (Access 97 SR2)

    Thanks for that Mark, I will have a look at the links and give the on activate a go.

    Id still like to clarify my problem, therefore I have attached a database to hopefully explain.

    If you open the attached access 97 database it should open a form in maximised mode. There is a button which opens a pop up form. If you resize this, the form resizes as it should. If you then press the restore button (on the first form), and then resize the popup form, the textbox will resize as well (code behind the on resize trigger).

    In making this database I have also noticed that if I maximize then restore the popup form without restoring the original form, it has the same effect without setting all maximised forms to restore mode so ill see if I can get away with coding a maximise then restore into the on open event of the popup form. Ill still have a look at on activate though.

    Thanks again for you help Mark.
    Attached Files Attached Files

  6. #6
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Re-sizing pop up forms (Access 97 SR2)

    I had a go with on activate but it doesn't get triggered when re-sizing (manually dragging the forms border) occurs.

    Regarding minimizing then restoring the popup form to get the resize trigger working, I attempted to program it in, but unfortunately that didn't work either. If I use docmd.maximise, I can then manually restore it and the resize event then works. If I try and use docmd.restore it doesn't have the same effect and continues not to trigger the on resize event.

    Back to the drawing board it is then.

  7. #7
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Re-sizing pop up forms (Access 97 SR2)

    I looked at db you attached. Whenever the popup form was resized, whether by dragging border when in restored state, or by using buttons to maximize or restore, the textbox was resized along with form. It didn't matter if the other form or the database window or the application window were maximized or restored, the popup form's behavior was the same in all cases. The popup form's Resize event looks like this:

    Private Sub Form_Resize()
    Me.Text0.Height = (Me.InsideHeight - 200)
    Me.Text0.Width = (Me.InsideWidth - 200)
    End Sub

    So is the behavior I'm seeing (textbox resized whenever form resized) what it's supposed to be doing? Or is it supposed to be doing something else?? Note that I'm using A2K not A97 (had to convert attachment) but don't know if that would make a difference in this case.

  8. #8
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Re-sizing pop up forms (Access 97 SR2)

    It may well have been changed since the release of Access 2K. When our test machine is rebuilt ill try testing it on it but that PC died a sorry death [img]/forums/images/smilies/sad.gif[/img]

    When I open the database, click the button to open the popup form and drag a border, nothing happens to the control i'm trying to resize. I must first either restore the maximized form that was first loaded, OR maximize the popup form then restore that.

    Thanks for having a look though Mark, much appreciated.

    I tried doing it in code. Maximizing through code, then restoring manually had the desired effect (the on event kicked off when I dragged the border), but restoring through code did not have any effect.

  9. #9
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Re-sizing pop up forms (Access 97 SR2)

    Hi Phil... <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Just wanted to let you know that I took a look at your sample db and saw what you were talking about... (I'm using Access 97 SR-2 at work...)

    If I opened the database, clicked the button, clicked and dragged the edge of the popup form to resize, the textbox stayed the original size....
    If I clicked the Restore Down button from the main form, it minimized the main form and when the popup form is resized the same way as previously stated, the textbox grew or shrunk with the window itself...

    Call me slow, but I'm still not positive what you actually want it to do... Always resize the textbox with the popup window?

  10. #10
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Re-sizing pop up forms (Access 97 SR2)

    Yep, you've got it in one. I want it to always resize the textbox (or any control) if I drag the borders.

    If there is an option somewhere that miraculously does this then i'd be very interested in hearing about it (in VB or Access), as i'm sure having you're control resize with your window must be a very handy facility!

    Thanks for looking at the db.

  11. #11
    3 Star Lounger
    Join Date
    May 2002
    Location
    Toronto, Ontario, Canada
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Re-sizing pop up forms (Access 97 SR2)

    Hi Phil...

    I had never tried to do this before but I played around with your sample and I managed to (almost) simultaneously resize the control with the form... <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

    I added a couple of module level variables... which will be set to the original Inside height and width on form load...
    Then I used the form timer event to test the variables against the current size of the inside height and width and call the resize event accordingly...
    I tried different timer intervals and decided that 100 was pretty good for making sure the form's getting updated quickly...
    I also used an IF condition in the timer event procedure so that it's not always performing the resize process (ie if the inside height and width haven't changed)...

    I've re-attached the sample with the the changes I made....
    HTH...
    Attached Files Attached Files

  12. #12
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Re-sizing pop up forms (Access 97 SR2)

    This is apparently an issue with Access 97. Problem does not occur in A2K or AXP. MS acknowledges this: "Microsoft has confirmed this to be a problem in Microsoft Access 97." See MSKB Article 194114:

    ACC: Resize Event on Pop-Up Form Does Not Occur as Expected

    To quote from article:

    SYMPTOMS
    When you assign code to the Resize event of a pop-up form, the code may not run.

    CAUSE
    In Microsoft Access, if you have any other object maximized at the same time, the Resize event of a pop-up form occurs only when the form is opened.

    RESOLUTION
    If you have a pop-up form that uses the Resize event, make sure no maximized objects are open when you resize it.

    I do not use ACC 97 so am unable to duplicate this behavior. One obvious solution, as noted in some of the MSKB articles, is to not allow forms to be maximized by setting the MinMaxButtons property so user cannot maximize form, and to "simulate maximizing a form by sizing it as large as possible in a restored state." This article provides sample code for this technique in ACC 95/97:

    ACC: Maximizing One Form Maximizes All Forms (95/97)

    This code involves the use of various Windows API's for sizing and positioning form window. Your other option would be to upgrade to A2K or AXP.

    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •