Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003

    Question Unanswered: Questions About Form Windows and API Functions

    There are still a few niceties I don't quite understand about setting the sizes of form windows. Perhaps one of the other readers can set me straight.

    I normally set my user forms to a Thin border so they cannot be resized. However, if I change the size of the form's container window in Design view, this changes the size of the form when it opens. The form has extra blank material to the bottom or right, or some controls are hidden.

    I tried to come up with a way to automatically set the size of the container window whenever the form opens. The GetWindowPlacement API function did not work as I expected. It returned -1 as the value for all coordinates of the RECT structure.

    My goal is to store the form's coordinates in the code or a DB table so that no matter how much the size is changed in Design view, the form window will reopen with the stored dimensions. For now, I have to manually set the size of the container window to get the open form to show the desired margins.

    Is there a way to do this with code, or am I stuck with doing it manually? Is there a reason why GetWindowPlacement does not return the window parameters? Thanks.

  2. #2
    Join Date
    Oct 2003
    I too have encountered this...and posed the question to a colleague, we came up with a work around....(probably not flexible enough to be called a method!)

    Set the sizes you want in the form properties--
    in the form_load event insert this line:


    Like I said--it may or may not be what you are looking for but worth a try.

  3. #3
    Join Date
    May 2003

    Not Exactly

    DoCmd.Restore worked okay in a blank test form. But when I tried it in one of the real forms with subforms and pages, it failed to restore the previous dimensions of the overall form after I changed the size of the container window in Design view.

    I looked at using DoCmd.MoveSize. Unfortunately, the forms also use AutoCenter = True. It looks like MoveSize executes *after* the auto-centering happens. This causes the forms to display at unpredictable locations on the screen. To make this work, one would have to get the current screen dimensions and move the forms to the desired location. There are some Win API functions that can retrieve window dimensions and screen resolutions, but it's not worth the time to look them up. This particular application will only run on a single computer.

    Oh well. Unless someone suggests a better idea, I'll continue to set the container window dimensions by hand. It's just a shame that there is no procedure or function that can automatically set the correct size for a form's container window based on the current form dimensions.

Posting Permissions

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