Solved Resize Navigation Form (1 Viewer)

Superpat

Member
Local time
Tomorrow, 00:00
Joined
Aug 15, 2020
Messages
96
Hello, I want to adapt a form to my different screens.
I can adapt the controls but not the screens.
I join a zip file.
Only the form f_operation interests me. I tried the code on the drop-down list box: "Lst_ChoixEcran".
The opening form is "_f_Navigation".
Nothing happens to change the screen.
What is my problem?
Thank you for your help.

access-2.jpg
 

Attachments

  • Database101_essai.zip
    985.6 KB · Views: 189

Superpat

Member
Local time
Tomorrow, 00:00
Joined
Aug 15, 2020
Messages
96
Hello and thank you isladogs for your link,
I tried your code on a simple screen it's perfect.
But with my 2 screens, it looks like your module considers them as a single screen.
I wish it only considers I have one screen, the screen where I open access.
On the other hand with my Navigation Form, I do not arrive at the expected result.

access-6.jpg
 

isladogs

MVP / VIP
Local time
Today, 23:00
Joined
Jan 14, 2017
Messages
18,221
I use two monitors as well and the resized forms only appear on whichever screen I am using for the Access application window.

What setting are you using in Windows for your dual monitors
Did my example app work correctly on your dual monitor setup?
If so and your own app doesn't then look again carefully at the form design and sizing.
What is the 'base' resolution it is designed in? Did you modify the settings in modResizeForm to match that base resolution?
Also please carefully read the article in order to understand how to make AFR work well...

After all that, if you're still having problems, please upload a cut down version of your database and I'll look into it when I have time.
 

Superpat

Member
Local time
Tomorrow, 00:00
Joined
Aug 15, 2020
Messages
96
Hello Isladogs,
I admit that I read the 3 chapters of the notice, but that I did not understand everything.
I am not an expert on Access, I make a small program for my pleasure.

My configuration for my screens: 1680x1050 and 1920x1080, landscape mode, extended display.
The main screen is that of 1680, but I start Access on that of 1920. Your application and a small application I created, with a simple form, have worked perfectly on my 2 screens.
Now, with the navigation form, the problem, (for me) seems more complex.

I changed my basic form (1680x1050) to take a smaller (1440x900). The result is conclusive, but not yet satisfactory.
I changed the screen dimension, to adjust on the new screen in the resize me file. I modulated with a dimension that worked correctly, but does not match the 1440x900 screen.

'-----------------------------MODULE CONSTANTS & VARIABLES------------------------------
'CR v4694 DESIGN_HORZRES changed from 800 to 850 to fix overstretching of some forms horizontally
Private Const DESIGN_HORZRES As Long = 1300 '800 '<- CHANGE THE VALUE ABOVE TO THE
'RESOLUTION YOU DESIGNED YOUR FORM IN.
'(e.g. 800 X 600 -> 800)
Private Const DESIGN_VERTRES As Long = 1050 '480 '<- CHANGE THIS VALUE TO THE RESOLUTION
'YOU DESIGNED YOUR FORMS IN.
'(e.g. 800 X 600 -> 600)
Private Const DESIGN_PIXELS As Long = 96 '96 '<- CHANGE THE VALUE ABOVE TO THE DPI
'SETTING YOU DESIGNED YOUR FORM IN.
I changed the screening of the screen size to have the size of the startup screen (my 2 screens not identical). See the file of Alexandro Alx Grimaldi and the discussion, or in the Monitor module.

Public Sub GetScreenResolution()

'Updated by Colin Riddington for 32-bit/64-bit - 26/01/2019
#If VBA7 Then
Dim hDCcaps As LongPtr
#Else
Dim hDCcaps As Long
#End If

Dim lngRtn As Long

On Error Resume Next

'API call get current resolution
hDCcaps = WM_apiGetDC(0) 'get display context for desktop (hwnd = 0)

With NewRes
' .Height = WM_apiGetDeviceCaps(hDCcaps, WM_VERTRES)
' .Width = WM_apiGetDeviceCaps(hDCcaps, WM_HORZRES)
.Height = ResVert
.Width = ResHor

.DPI = WM_apiGetDeviceCaps(hDCcaps, WM_LOGPIXELSX)
Problem at the start, with "Me Resize", the form F_Operation does not open during the first opening. I give myself in Create mode and open the form again. Everything is OK ????
The results :
- The _f_navigation form goes off for the dimensions of the screen but (it seems that from the police are only partially on the scale) on the 1920x1080 screen.
- The _f_navigation form is scaling badly for the dimensions of the screen (centering, dimension) on the 1680x1050 screen.
- The f_Operation form goes on the screen scale, but the controls do not go to scale or the police.
- Other forms do not properly be placed on a scale vertically and for the police, they even mask, partly, the browsing form.

If you can help me crop forms, I would be grateful for them.
 

Attachments

  • DatabasePetite21.zip
    311.3 KB · Views: 126
Last edited:

isladogs

MVP / VIP
Local time
Today, 23:00
Joined
Jan 14, 2017
Messages
18,221
Hi @Superpat
I'm having difficulty responding to this for various reasons:
1. Language issues. Clearly English isn't your first language & you have probably used Google Translate from your native French.
However I've no idea what 'the police' actually means in this context
2. The video link for Alessandro Grimaldi isn't working
3. There are several compilation errors in your file. First of all, it won't run in 64-bit because you forgot PtrSafe in the module Monitors:
Rich (BB code):
#If VBA7 Then
    Private Declare PtrSafe Function MonitorFromWindow Lib "user32.dll" (ByVal hwnd As LongPtr, ByVal dwFlags As Long) As LongPtr
    Private Declare PtrSafe Function GetMonitorInfo Lib "user32.dll" Alias "GetMonitorInfoW" (ByVal hMonitor As LongPtr, ByVal lpMonitorInfo As LongPtr) As Long

4. There are numerous errors in the BtnEnregistrer_Click event of form f_Operation. I started to work through these but it would make more sense for you to do so as its your app. So I can't test that form

5. The GetScreenResolution code you've quoted is a combination of my code and from your Monitor module. Please just use my code instead for this part to avoid issues.

6. If you have used 1440x900 as your 'base resolution for resizing then you need to use those values in modResizeForm - NOT 1300x1050
1624821024641.png


In design view, any forms you want to be full screen should be made to fill the screen horizontally & vertically at your 'base resolution'.
If you don't want them full screen reduce the form size by the same % in both directions

I think your forms are far too big horizontally & probably vertically. Compare with the design view size of the forms in my example database.
Having said that I can get reasonable results with all your forms EXCEPT the popup form f_Operation which is too tall when opened standalone in form view

Bear in mind that the form will resize by the same proportion in both directions.
It will fill the screen vertically and if, the form factor for each resolution is identical, also do so horizontally.
However, as 1440/900 and 1680/1020 = 1.6 BUT 1920/1080 = 1.778. So you will get blank space on the right edge at the latter resolution if your form is full height

7. You may get better results using Overlapping Windows display rather than Tabbed Documents

Please try to work through the above fixing:
a) compile errors and the other points listed in items 3-6 above
b) form sizes in design view at the base resolution.

When you have done all of the above, feel free to get back to me
Good luck.

Attached is my partly modified version BUT remember form f_Operation doesn't compile ...AND I haven't attempted to modify your form sizes.
You need to put in some more work on this yourself.

For info, many experienced Access developers, including myself, NEVER use the built in navigation form.
Whilst it can give good results fairly quickly, trying to make significant modifications can take up a lot of time to get right.
It is almost always better to create your own navigation forms instead
 

Attachments

  • DatabasePetite21A_CR.zip
    334.5 KB · Views: 218
Last edited:

Superpat

Member
Local time
Tomorrow, 00:00
Joined
Aug 15, 2020
Messages
96
Hi Isladog,
Thank you for answering me as long and detailed, as well as for the correction.

1. It's Google Translation which is currently my link with the English language, if I wrote directly in English would probably have worse. Police in French, must match font.
2. Link monitor, VBA Pill #23: Monitor info
3. Thank you for these remarks, I saw the correction.
4. I deleted forms to lighten the base.
The BTnenregistrer_Click does not exist, sorry, I forgot to delete the code.
5. It is true that I changed the GeCreenResolution code, four lines in red, it is to make the difference between my 2 screens (1980 and 1680). It seems to me that your code does not make the difference, it takes into account the Windows startup screen that is not necessarily the Access startup screen.
6 and 7. I will try to take into account your remarks.
8. I will try to change the navigation form by creating my own form.
I come back to you in a "good" moment...

Thanks again.
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 23:00
Joined
Jan 14, 2017
Messages
18,221
1. Still not sure what Police has to do with Access :) Policy? Property? Application window? Form? Sorry but I'm clueless
5. I've been using the screen resolution code I provided for over 15 years. It does allow for correct resizing in any other resolution.
My code does calculate the primary monitor resolution as it assumes the primary monitor will be used for the Access app
Alessandro's code gives exactly the same results for the primary monitor (as you would expect) but it does change with the monitor used

Have fun...

EDIT
For info, the displayed screen resolution in your navigation form doesn't update when the Access window is dragged to another screen with a different resolution
 
Last edited:

Superpat

Member
Local time
Tomorrow, 00:00
Joined
Aug 15, 2020
Messages
96
1.
police.jpg

2. Indeed, it does not recalculate during the change of monitor. But in the discussion lower, with me, it gives the resolution on which Access is launched whether the main or secondary monitor.
Which is not very important to me.
 

isladogs

MVP / VIP
Local time
Today, 23:00
Joined
Jan 14, 2017
Messages
18,221
Thanks .... Police = font (name).

In my experience its fairly unusual to always run Access from the secondary monitor. One problem with doing that is when someone opens the app on a single monitor workstation as I did originally with a 64-bit tablet. That meant your popup forms opened off screen so weren't visible.

Anyway, as long as it works for you that's fine
 

Superpat

Member
Local time
Tomorrow, 00:00
Joined
Aug 15, 2020
Messages
96
Hi Isladog,
Everything seems to me to take a good shape.
I rebuilt my browsing form and the code seems to apply. I have 2 problems left, which must be minor:
- If I leave Jeff Blomsom's code, I get a coefficient of 0.9722, a decrease in the screen. If I modify the coefficient in 1.2 everything is going well. I would like to know where the problem comes from ?
'modification by Jeff Blumsom 18/1/07
Select Case FormFactor
Case "4:3"
GetFactor = (NewRes.Width / DESIGN_HORZRES) * sngFactorP
Case "5:4"
GetFactor = (NewRes.Width / DESIGN_HORZRES) * sngFactorP
Case "Widescreen"
GetFactor = ((4 / 3) * NewRes.Height / DESIGN_HORZRES) * sngFactorP
Debug.Print GetFactor
'GetFactor = 1.2
End Select
- I wish that when launching the Form Navigation be able to make the masking of the sidebar.
Private Sub Form_Load()
Dim ResolutionEcran As String
' On masque les rubans
If FichierAppel <> "f_Equilibrage" Then
'DoCmd.ShowToolbar "Ribbon", acToolbarNo
'DoCmd.RunCommand acCmdWindowHide
 

Attachments

  • DatabasePetite30accdb.zip
    553.6 KB · Views: 173

isladogs

MVP / VIP
Local time
Today, 23:00
Joined
Jan 14, 2017
Messages
18,221
I think you need to go back and carefully review both the automatic form resizing (AFR) article and the code to make sure you understand it completely. At the moment. you seem to be using code from different sources without fully understanding what you are doing.

AFR works well when it scales up forms from a low resolution to a high resolution. If used properly it can handles screens of different shapes (form factors) as well as different sizes and resolutions. The secret to doing that is in getting the original form design correct in terms of both size & shape at the lower 'base' resolution. Unfortunately, it appears you haven't done that.

You have set the 'base resolution as 1440*900 so the form size needs to be such that it fills the screen at that resolution
Your navigation form in design view is 38.148cm wide which is too large. Similarly the total height = 24.298cm in design view - again too big

I tried viewing the navigation form on a 12 inch (30cm) tablet at 1920*1080. The form resized downwards to fit the screen but the font size was far too small to be legible. Even on a 22 inch screen, the font was still too small to read comfortably at both 1680x1050 & 1920x1080.

So to repeat, you need to modify the design of all your forms so they work correctly at whatever 'base resolution' you decide to use. That means both the form size (horizontally & vertically) as well as the font size.

- I wish that when launching the Form Navigation be able to make the masking of the sidebar.

Sidebar?
I think you mean that you want to either hide or minimize the navigation pane. That is easy to do but is totally unrelated to AFR
Functions to do both of those are included in the modNavPaneTaskbar module

To hide the navigation pane completely, add this code to Form_Load:
Code:
HideNavigationPane

Or to minimise it, use:
Code:
MinimizeNavigationPane

Or if preferred, use the 2 lines of code from those two functions instead.
 

Superpat

Member
Local time
Tomorrow, 00:00
Joined
Aug 15, 2020
Messages
96
Hello isladogs
My last version, I hope this time, I'm better.
Thanks again for your patience.
 

Attachments

  • DatabasePetite31.zip
    535.6 KB · Views: 158

isladogs

MVP / VIP
Local time
Today, 23:00
Joined
Jan 14, 2017
Messages
18,221
That seems much better. I've only looked at it on a 30cm tablet using 1920*1080 (at both 100% and 125% scaling) and at 1280x720 but it now fits quite well and the font size is now legible in each case.

I suggest a couple of minor changes.
1. Try slightly reducing the height of the main form and each subform by say 0.2cm as the bottom row of buttons are very close to the bottom edge of the screen.
2. Try making minor adjustments to the position of the tab control as clicking the tab control buttons is causing the control to shift and obscure the text on each tab. Unfortunately this is a known issue and trial and error will be needed to fix it.

Otherwise if it now works for you, then that's great.

Note that I haven't looked at the code so don't know what, if any, changes you have made
 

Superpat

Member
Local time
Tomorrow, 00:00
Joined
Aug 15, 2020
Messages
96
Hello,
I tried to modify my file taking into account your observations.
Bravo for your program.
Thank you again for your clear explanations and your precious help.
One last question, can I reduce the void in the clear blue zone?
Vide.jpg


For me everything seems solved and I go straight.
 

Attachments

  • Petite_33.zip
    314.8 KB · Views: 160

Superpat

Member
Local time
Tomorrow, 00:00
Joined
Aug 15, 2020
Messages
96
I come back, sorry !
I have an Option Group with a problem :
CadrePointe.jpg

Please, can you solve it ?
 

Attachments

  • Petite_33.zip
    243.4 KB · Views: 105

Users who are viewing this thread

Top Bottom