Solved Centers a form (1 Viewer)

Superpat

Member
Local time
Today, 22:04
Joined
Aug 15, 2020
Messages
96
Hello,
It's still me and I'm sorry.
I want to focus a form that has already been expanded using the Mendip Data Systems code.
I saw that there were "Gettopoffset / Getleftoffset" functions to focus the forms.
But of course, after 50 tests I'm still so bad and I cannot do there.
Could you help me once again (if it is possible).
Thank you
Agrandir.jpg
 

Attachments

  • Essai_Petite_4021.zip
    646.9 KB · Views: 99

Ranman256

Well-known member
Local time
Today, 16:04
Joined
Apr 9, 2015
Messages
4,337
in the form RESIZE event, stretch the control:

'to stretch the list (subform?) to fill the form:
Code:
Private Sub Form_Resize()
   objName.Width = Me.Width
End Sub

or center:
objName.left = (me.width - objName.width) /2
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:04
Joined
Feb 19, 2002
Messages
43,280
Here is code that I use to enlarge a subform proportionally when the outer form resizes. Fiddle with the values in the constants until you get the right settings for your resolution and monitor size.
Code:
Private Sub Form_Resize()
Const LeftRightPadding = (0.125 + 0.25) * 1440
Const TopBottomPadding = (0.25 + 0.375) * 1440

Me.sfrmMemberList.Height = Me.InsideHeight - TopBottomPadding
Me.sfrmMemberList.Width = Me.InsideWidth - LeftRightPadding
End Sub
 

isladogs

MVP / VIP
Local time
Today, 21:04
Joined
Jan 14, 2017
Messages
18,229
You can't do what @Ranman suggested as it won't work with the automatic form resizing code

The problem is partly that you haven't retained the original form template size that I provided.
I've modified it slightly
I've also moved the following line from Form_Open to Form_Load as stated in my website article
Code:
Private Sub Form_Load()
       'auto resize form
    ReSizeForm Me
      
End Sub

If you use overlapping windows display then add DoCmd.Maximize to Form_Open
The form now looks like this which is I think slightly better:
1628542022424.png


Can you see the changes I've made? I could have tweaked it further but its your form and only you can decide what looks OK.

If that's still not what you want, you will need to modify the original form design size and/or tweak the DESIGN_HORZRES constant in modResizeForm
 

Attachments

  • Essai_Petite_4022_CR.zip
    193 KB · Views: 79

Superpat

Member
Local time
Today, 22:04
Joined
Aug 15, 2020
Messages
96
Thank you all for your responses.
Sorry, I was slow to answer, between the tests and the translation of Google ...
Isladogs, I originally thought, serve me twice from the same subform ("f_Operation") to:
- In Navigation, returning data, then, by closing navigation and all its subforms balance my accounts by reopening ("f_Operation").
The only problem, which is not a big problem, it is that by opening it alone, now ("f_Operation") is no longer centered.

Reflecting, I think I can add a tab where I would turn ("f_Operation") and hide one or the others, as they will always be centered in navigation.

However, If I modify "DESIGN_HORZRES constant in modResizeForm", it will be for all the forms, so it is not the desired purpose.
I join the complete file:
- Start on "f_Navigation",
- Click on "Equilibrer ce compte",
- Click on "Suivant"
(And there the form is not centered horizontally)
- Click on "Sortir" to go out to return to "f_navigation",
 

Attachments

  • Essai_Petite_4023.zip
    866.6 KB · Views: 95
Last edited:

isladogs

MVP / VIP
Local time
Today, 21:04
Joined
Jan 14, 2017
Messages
18,229
First of all was there any improvement in my changes last time?

Sorry but I'm really not clear what your question is. Blame Google translate!

I tried opening your app but didn't know what to look at so I tried the Navigation form.
That led to a series of errors then Access crashed.
I reopened and tried a different form then got another error as I am using 64-bit Access and some of your APIs aren't 64-bit compatible.

So I'm going to answer according to what I think your question is ...
You are using my automatic form resizing (AFR) code but the form(s) you are using aren't filling the screen horizontally.
You are using tabbed documents so the form is automatically maximised...unless its a popup.

AFR code enlarges forms and controls then moves them across/down proportionately according to screen size/shape/resolution.
Everything moves relative to the top left ....NOT from the screen centre.

So you have several choices
1. Increase the width of your form(s) in design view and move your controls to the right slightly so they are spread across the width.
Save and reopen the form normally. Does it now fill the screen horizontally? Make minor adjustments until you are happy
2. Change it to a popup form. After resizing, add code to centre the form. Either try the code already suggested or look at my article Centre Form On Screen - Mendip Data Systems
3. Change to overlapping windows display and add the line DoCmd.Restore in Form_Open. Then centre the form after resizing as in option 2
4. Scrap the AFR code and handle everything yourself without it.

I suggest you try option 1 first and go from there.
Hope that helps clarify things though it doesn't give you an instant solution

Good luck
 

Superpat

Member
Local time
Today, 22:04
Joined
Aug 15, 2020
Messages
96
Hello Isladogs,
No, your change had changed nothing for what I was looking for.
I corrected my previous mail for clicks in French.
I deleted the unnecessary modules in my files and I think it should be better for the 64 bits.
I think you understood what I was looking for, I'll try tonight ... with the time I'll have to understand.
Thank you again for your patience
 

Attachments

  • Essai_Petite_4024.zip
    922.1 KB · Views: 59

isladogs

MVP / VIP
Local time
Today, 21:04
Joined
Jan 14, 2017
Messages
18,229
It still didn't work in 64-bit. I've added PtrSafe to the Monitor module to fix that but not checked the APIs are working correctly.
There are also several other compilation errors you need to fix - unrelated to APIs.

Anyway, I've just spent about 20 minutes doing what I described in option 1 above - widening the form and various controls as well as shifting several controls to the right. The form f_Operation now looks approximately correct on my screen.
1628685917849.png


However, its your form and only you can say what works for you. I'll leave you to continue tweaking that process to suit your needs.

For info the form f_Navigation is slightly to wide on my monitor - part of the tab control content is cut off on each side.
I haven't done anything to that - will leave it to you as well
1628685845884.png


Over to you to work on further as necessary
Good luck.
I do think you need to re-study the details of my AFR article in order to use the feature more effectively
 

Attachments

  • Essai_Petite_4024 - CR.zip
    706.9 KB · Views: 71

Superpat

Member
Local time
Today, 22:04
Joined
Aug 15, 2020
Messages
96
Hello isladogs,
I spent time to put my forms as I wanted. I hope you can see it in your access version.
I still have a weird problem:
- When I open "_f_Navigation", I have this screen, with right and down a white bar:
Ecran 1.jpg


- When I move it by reducing it slightly and then repositioning it to its initial size, the band disappears.
Ecran 2.jpg
Ecran 3.jpg


Do you have an idea ?

For me, apart from that everything is perfect in the positioning of the forms.
Thanks again.
 

Attachments

  • Database10 -14.zip
    905.2 KB · Views: 123

isladogs

MVP / VIP
Local time
Today, 21:04
Joined
Jan 14, 2017
Messages
18,229
Just looked at it on 2 monitors in both 1680*1050 & 1920*1080
The vertical white line isn't visible in either case so I can't really suggest a solution other than what you have already done.

Is your monitor wider than the maximum possible form width of 22.75 inches?
Does the problem still occur if you change to overlapping windows display or change to a popup form?
 

Superpat

Member
Local time
Today, 22:04
Joined
Aug 15, 2020
Messages
96
I have the same monitor as you.
In popup form, It is good but I have a problem, the controls have moved :
Ecran 4.jpg

I think it's a configuration of the screens. This is not a problem.
I thank you for your patience and sharing your skills.
I go straight.
 

isladogs

MVP / VIP
Local time
Today, 21:04
Joined
Jan 14, 2017
Messages
18,229
You may have the same resolution as me but the screen dimensions can still be slightly different.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:04
Joined
Feb 19, 2002
Messages
43,280
@isladogs I haven't been following the discussion so I'm sorry if I am intruding but did the suggestion I posted not fit into your scheme of things?
 

isladogs

MVP / VIP
Local time
Today, 21:04
Joined
Jan 14, 2017
Messages
18,229
Hi @Pat Hartman
Thank you for your suggestion.
When using automatic form resizing, all form controls are resized and repositioned proportionately.
That also applies to subforms as they are controls on the main form.
Applying additional code would disproportionately alter the subform and its controls
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:04
Joined
May 7, 2009
Messages
19,245
When using automatic form resizing, all form controls are resized and repositioned proportionately.
then why this trial and error?
 

Users who are viewing this thread

Top Bottom