billcute
asked on
Code for Resizing forms to desktop resolution.
How do I resize multiple forms when opened in a db?
I do have code that will resize forms to a specific resolution if manually tweaked but I am trying to explore other possibilities.
But what I am hoping to achieve is that when a form is opened it should automatically resize the form to the Windows resolution which my be:
form 800 x 600 up to 1280 x 1024.
In any case, if a user set's his desktop resolution to 1024 x 768 for example, then the code in the db should adjust the form being opened to the desktop resolution.
Any help will be appreciated.
I do have code that will resize forms to a specific resolution if manually tweaked but I am trying to explore other possibilities.
But what I am hoping to achieve is that when a form is opened it should automatically resize the form to the Windows resolution which my be:
form 800 x 600 up to 1280 x 1024.
In any case, if a user set's his desktop resolution to 1024 x 768 for example, then the code in the db should adjust the form being opened to the desktop resolution.
Any help will be appreciated.
link on
Automatically resize forms to current screen resolution
http://www.mvps.org/access/general/gen0002.htm
Automatically resize forms to current screen resolution
http://www.mvps.org/access/general/gen0002.htm
there is a form resizer here also
http://jamiessoftware.tk/
Note, I have not tried these code snippets, I just know they exist
I tend to design my screens knowing what the min screen resolution is
Luckily for me, its all 1024 x 768
800x600 is a bit rare now. I cannot remember last time I saw someone using that resolution
http://jamiessoftware.tk/
Note, I have not tried these code snippets, I just know they exist
I tend to design my screens knowing what the min screen resolution is
Luckily for me, its all 1024 x 768
800x600 is a bit rare now. I cannot remember last time I saw someone using that resolution
ASKER
I have checked out the referred site...but dont think it addressed my concern.
The resizing code will always be to maximize the main forms to the desktop resolution. The referred site did not elaborate on different resolution.
If you wish I can post a link (later on this evening) to my own source code which can be modified further for different Window resolution.
Regards
Bill
The resizing code will always be to maximize the main forms to the desktop resolution. The referred site did not elaborate on different resolution.
If you wish I can post a link (later on this evening) to my own source code which can be modified further for different Window resolution.
Regards
Bill
ASKER
sorry...we missed each other during cross posting..I will checkout these other ones and let you know later
Regards
Bill
Regards
Bill
ASKER
This referred site is my current code;
http://jamiessoftware.tk/
the code requires manually changes to function to Windows rsolution. I will check the other later on.
http://jamiessoftware.tk/
the code requires manually changes to function to Windows rsolution. I will check the other later on.
ASKER
The other is peter's software, one has to buy it. Is it possible to amend this one further if licensing allows it?
http://jamiessoftware.tk/
Regards
Bill
http://jamiessoftware.tk/
Regards
Bill
ASKER
rockiroads,
I have checked out these links. hat would you recommend in light of my comments above.
Regards
Bill
I have checked out these links. hat would you recommend in light of my comments above.
Regards
Bill
Bill, Ive not tried any one of them. I just supplied you some links which I felt may help you.
I will try one out now and let you know
I will try one out now and let you know
**A)
Bill, I take it you have tried the Access form resizer from jamiesoftware?
It gives u the code, u can export to your own DB, then just call the method ReSizeForm, passing in form object
e.g.
private sub Form_Load()
ReSizeForm Me
end sub
this resizes forms and controls
**B)
Peter's software is an MDE, you cannot export that code so Im not aware of its use.
**C)
If you want to get the current screen resolution, here is some code that u can use
Add this code into a module
Public Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long
Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1
Sub GetScreenSize()
Dim x As Long, Y As Long, sYourMessage, iConfirm As Integer
x = GetSystemMetrics(SM_CXSCRE EN)
Y = GetSystemMetrics(SM_CYSCRE EN)
MsgBox "Current screen size is " & x & " x " & Y & vbCrLf
End Sub
Now if u run the procedure getscreensize, it comes up with a msgbox
Bill, I take it you have tried the Access form resizer from jamiesoftware?
It gives u the code, u can export to your own DB, then just call the method ReSizeForm, passing in form object
e.g.
private sub Form_Load()
ReSizeForm Me
end sub
this resizes forms and controls
**B)
Peter's software is an MDE, you cannot export that code so Im not aware of its use.
**C)
If you want to get the current screen resolution, here is some code that u can use
Add this code into a module
Public Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As Long
Const SM_CXSCREEN = 0
Const SM_CYSCREEN = 1
Sub GetScreenSize()
Dim x As Long, Y As Long, sYourMessage, iConfirm As Integer
x = GetSystemMetrics(SM_CXSCRE
Y = GetSystemMetrics(SM_CYSCRE
MsgBox "Current screen size is " & x & " x " & Y & vbCrLf
End Sub
Now if u run the procedure getscreensize, it comes up with a msgbox
ASKER
rockiroads,
How or where should I call your above suggested Sub
Regards
Bill
How or where should I call your above suggested Sub
Regards
Bill
alright bill,
is it the get screen resolution u want?
simply place anywhere, probably better in a module
it will return 1024 x 768 or whatever resolution it is
i.e.
x = 1024 or 800
y = 768 or 600
I guess u can then return these values to the caller
e.g
public Sub GetScreenSize(byref x as long, byref y as long)
Dim iConfirm As Integer
x = GetSystemMetrics(SM_CXSCRE EN)
y = GetSystemMetrics(SM_CYSCRE EN)
End Sub
you then call it in your form code or wherever like this
dim x as long
dim y as long
GetScreenSize x,y
that is one method, the other method is to pass the form in, thats if the code you are calling requires the form
e.g.
public Sub GetScreenSize(frm As Form)
Dim x As Long, Y As Long, sYourMessage, iConfirm As Integer
x = GetSystemMetrics(SM_CXSCRE EN)
Y = GetSystemMetrics(SM_CYSCRE EN)
'Now call your code
'CALL YOUR resize code here passing in frm as the form and x and y if thats what it takes
End Sub
u then call this example from form simply by
GetScreenSize Me
I dont know the code you are calling to resize forms, what type of parameters does it take?
is it the get screen resolution u want?
simply place anywhere, probably better in a module
it will return 1024 x 768 or whatever resolution it is
i.e.
x = 1024 or 800
y = 768 or 600
I guess u can then return these values to the caller
e.g
public Sub GetScreenSize(byref x as long, byref y as long)
Dim iConfirm As Integer
x = GetSystemMetrics(SM_CXSCRE
y = GetSystemMetrics(SM_CYSCRE
End Sub
you then call it in your form code or wherever like this
dim x as long
dim y as long
GetScreenSize x,y
that is one method, the other method is to pass the form in, thats if the code you are calling requires the form
e.g.
public Sub GetScreenSize(frm As Form)
Dim x As Long, Y As Long, sYourMessage, iConfirm As Integer
x = GetSystemMetrics(SM_CXSCRE
Y = GetSystemMetrics(SM_CYSCRE
'Now call your code
'CALL YOUR resize code here passing in frm as the form and x and y if thats what it takes
End Sub
u then call this example from form simply by
GetScreenSize Me
I dont know the code you are calling to resize forms, what type of parameters does it take?
ASKER
I think I will stick to http://jamiessoftware.tk/ example.
The section in the module for manipulating the resolution is at:
Private Const DESIGN_HORZRES As Long = 800 ' 640 '<- CHANGE THIS VALUE TO THE RESOLUTION
'YOU DESIGNED YOUR FORMS IN.
'(e.g. 800 X 600 -> 800)
Private Const DESIGN_VERTRES As Long = 600 '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 '<- CHANGE THIS VALUE TO THE DPI
' ************
' Call is on the Form's On Load:
ReSizeForm Me
Note: Form designed at 800 x 600 resolution
Regards
Bill
The section in the module for manipulating the resolution is at:
Private Const DESIGN_HORZRES As Long = 800 ' 640 '<- CHANGE THIS VALUE TO THE RESOLUTION
'YOU DESIGNED YOUR FORMS IN.
'(e.g. 800 X 600 -> 800)
Private Const DESIGN_VERTRES As Long = 600 '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 '<- CHANGE THIS VALUE TO THE DPI
' ************
' Call is on the Form's On Load:
ReSizeForm Me
Note: Form designed at 800 x 600 resolution
Regards
Bill
ok, hang on
there is this current code, look for it, we are going to change this one
this code uses the constants, it now going to be tweaked
Private Function getFactor(blnVert As Boolean) As Single
Dim sngFactorP As Single
On Error Resume Next
If getScreenResolution.DPI <> 0 Then
sngFactorP = DESIGN_PIXELS / getScreenResolution.DPI
Else
sngFactorP = 1 'Error with dpi reported so assume 96 dpi.
End If
If blnVert Then 'return vertical resolution.
getFactor = (getScreenResolution.Heigh t / DESIGN_VERTRES) * sngFactorP
MsgBox "h=" & getFactor
Else 'return horizontal resolution.
getFactor = (getScreenResolution.Width / DESIGN_HORZRES) * sngFactorP
MsgBox "w=" & getFactor
End If
End Function
this code uses the constants, it now going to be tweaked
Private Function getFactor(blnVert As Boolean) As Single
Dim sngFactorP As Single
On Error Resume Next
If getScreenResolution.DPI <> 0 Then
sngFactorP = DESIGN_PIXELS / getScreenResolution.DPI
Else
sngFactorP = 1 'Error with dpi reported so assume 96 dpi.
End If
If blnVert Then 'return vertical resolution.
getFactor = (getScreenResolution.Heigh
MsgBox "h=" & getFactor
Else 'return horizontal resolution.
getFactor = (getScreenResolution.Width
MsgBox "w=" & getFactor
End If
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hope this makes sense
good luck
I tried by hardcoding the values lWidth and lHeight
good luck
I tried by hardcoding the values lWidth and lHeight
ASKER
rockiroads,
After the amendments were pasted there were no errors and the fiunctions worked as was designed for 800 x 600.
When I changed the desktop screen resolution to 1024 x 768, the code's msgbox reported the same resolution except that the form was expected to stretch (maximize) to full screen resolution. The form was sma and condensed rather than stretching to the screen resolution.
It was suggested in the Readme files of the download that the best way is to design with the lowest resolution, in my case the lowest resolution I chose to design was 800 x 600 since most pc monitors nowadays are from 800 x 600 and up to 1280 x 1024 for newer LCD or plasma flat screen monitors.
Currently the resolution I configured the ReSizeForm Me function - my idea is if there is a way to include the following resolution that would be detected by the form upon loading of the appropriate form.
800 x 600; 1024 x 768 and 1280 x 1024 respectively.
Regards
Bill
After the amendments were pasted there were no errors and the fiunctions worked as was designed for 800 x 600.
When I changed the desktop screen resolution to 1024 x 768, the code's msgbox reported the same resolution except that the form was expected to stretch (maximize) to full screen resolution. The form was sma and condensed rather than stretching to the screen resolution.
It was suggested in the Readme files of the download that the best way is to design with the lowest resolution, in my case the lowest resolution I chose to design was 800 x 600 since most pc monitors nowadays are from 800 x 600 and up to 1280 x 1024 for newer LCD or plasma flat screen monitors.
Currently the resolution I configured the ReSizeForm Me function - my idea is if there is a way to include the following resolution that would be detected by the form upon loading of the appropriate form.
800 x 600; 1024 x 768 and 1280 x 1024 respectively.
Regards
Bill
ASKER
.....correction for 2nd paraagraph of my last comment>
The form was small and condensed rather than stretching (maximizing) to the screen resolution. ^^^
The form was small and condensed rather than stretching (maximizing) to the screen resolution. ^^^
ASKER
I also conducted other test such as changing the resolution manually to 1024 x 768 and 1280 x 1024 respectively.
I noticed that maximum expandability of the module is 1024 x 768. any resolution that is higher that than is defaulted to 1024 x 768.
In that case, if the form can at least maximize up to the 1024 x 768 with your amendment, it would be great.
Regards
Bill
I noticed that maximum expandability of the module is 1024 x 768. any resolution that is higher that than is defaulted to 1024 x 768.
In that case, if the form can at least maximize up to the 1024 x 768 with your amendment, it would be great.
Regards
Bill
Bill, have u tried JamieSoftware code without my changes and changing the constant values?
what results do you get?
I have not changed anything in his code except to specify the current user's screen resolution.
what results do you get?
I have not changed anything in his code except to specify the current user's screen resolution.
ASKER
rockiroads,
I have just tested JamieSoftware code without your changes and found that the code has limitation - it doesn't work with a resolution greater than 800 x 600.
Regards
Bill
I have just tested JamieSoftware code without your changes and found that the code has limitation - it doesn't work with a resolution greater than 800 x 600.
Regards
Bill
ASKER
rockiroads,
Any other idea or thoughts on this matter?
Regards
Bill
Any other idea or thoughts on this matter?
Regards
Bill
I dont know to tell u the truth
I also dont know what kind of results you are after
What I suggest is u try out others till u find one u like
then we can try work that to your needs
I also dont know what kind of results you are after
What I suggest is u try out others till u find one u like
then we can try work that to your needs
ASKER
ok
ASKER
rockiroads,
I have decided to award you for this post....due to the limitation of the sample code itself. I can always re-open this post in the future if needed.
Thanks for your assistance.
Regards
Bill
I have decided to award you for this post....due to the limitation of the sample code itself. I can always re-open this post in the future if needed.
Thanks for your assistance.
Regards
Bill
ok, thanks
u should define your form to the lowsest resolution of your users
http://www.mvps.org/access/forms/frm0042.htm