Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make it look pretty on screen regardless of vdu size??

Status
Not open for further replies.

jajm

Technical User
Sep 16, 2000
1
GB
is there anyway of setting up the forms i create so that they look good on whatever size monitor they are looked at on, rather than just a 17", ive tried things like centre etc in properties but it doesnt work any ideas???? [sig][/sig]
 
Hi,

Look at the Feb 18th posting for "Window Size?" --it may help you--

[sig]<p>jgarnick<br><a href=mailto:jgarnick@aol.com>jgarnick@aol.com</a><br><a href= > </a><br> [/sig]
 
I have tried ShrinkerStretcher - that's what you get at the Softseek site. I didn't like it.
I was writing my own but that is on hold (it's quite hard really!).
Try the above - we have also been looking at a resizer written by Ken Getz (subject to copywrite) but have not made our minds up on this one yet... [sig][/sig]
 
I have a book\CD written by Getz that has the code to scale your forms to the resolution being used. If anyone still needs help with this, send me an email.
[sig]<p>Terry M. Hoey<br><a href=mailto:th3856@txmail.sbc.com>th3856@txmail.sbc.com</a><br><a href= > </a><br>Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?[/sig]
 
I've looked at the Getz code too and it looks pretty complex.

I think I'll just keep sizing my screens to the lowest common demoninator. [sig]<p>Larry De Laruelle<br><a href=mailto:larry1de@yahoo.com>larry1de@yahoo.com</a><br><a href= > </a><br> [/sig]
 
I sent out an email today to jgarnick with the steps and the source code. There was only about five steps to make it work using the source. I haven't tried it myself, maybe jgarneck can tell us if it was as easy as it seemed... [sig]<p>Terry M. Hoey<br><a href=mailto:th3856@txmail.sbc.com>th3856@txmail.sbc.com</a><br><a href= > </a><br>Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?[/sig]
 
Create a module with the following code. You the need to call the following functions on the form on open event!

Resizeform Me
ResetWindowSize Me

The first call sets the screen resolution and the second call is used for Pop Up forms. Please note that you should use True Type fonts on your forms or they may seem very blocky when you upsize your form. The only problem with this module is that any pop up forms do not always centre correctly. If you can help then E-mail me on Jon.pugh@racalfieldforce.com

'Module by Jamie Czernik 31st March 2000 {JSCzernik@Hotmail.com} and Jonathan Pugh 14/09/00 (jonpugh@callnetuk.com)
'Please feel free to use or distribute this module as you see fit.'
'If you have any useful code that you wish to share then please email it to us'

'USE: Design your form to fit 640 * 480 resolution and import this module into your project.'
'Call as &quot;Resizeform Me&quot; and then &quot;ResetWindowSize Me&quot; on the form's On Open event'
'You might use Form.Visble=False before and Form.Visible=true after the call to stop the '
'Screen flicker when the controls resize. Email me and let us know how you get on'

Option Compare Database
Option Explicit

'Module Declarations'
Global Const WM_HORZRES = 8
Global Const WM_VERTRES = 10

Dim Width As Integer
Dim Factor As Single 'Used as multiplier for current size properties'

Declare Function WM_apiGetDeviceCaps _
Lib &quot;gdi32&quot; Alias &quot;GetDeviceCaps&quot; _
(ByVal hdc As Long, ByVal nIndex As Long) As Long
Declare Function WM_apiGetDesktopWindow _
Lib &quot;user32&quot; Alias &quot;GetDesktopWindow&quot; () As Long
Declare Function WM_apiGetDC _
Lib &quot;user32&quot; Alias &quot;GetDC&quot; _
(ByVal hwnd As Long) As Long
Declare Function WM_apiReleaseDC _
Lib &quot;user32&quot; Alias &quot;ReleaseDC&quot; _
(ByVal hwnd As Long, ByVal hdc As Long) As Long
Declare Function WM_apiGetSystemMetrics _
Lib &quot;user32&quot; Alias &quot;GetSystemMetrics&quot; _
(ByVal nIndex As Long) As Long

Function GetScreenResolution() As String

'returns the height and width'
Dim DisplayHeight As Integer
Dim DisplayWidth As Integer
Dim hDesktopWnd As Long
Dim hDCcaps As Long
Dim iRtn As Integer

'API call get current resolution'
hDesktopWnd = WM_apiGetDesktopWindow() 'get handle to desktop
hDCcaps = WM_apiGetDC(hDesktopWnd) 'get display context for desktop
DisplayHeight = WM_apiGetDeviceCaps(hDCcaps, WM_VERTRES)
DisplayWidth = WM_apiGetDeviceCaps(hDCcaps, WM_HORZRES)
iRtn = WM_apiReleaseDC(hDesktopWnd, hDCcaps) 'release display context

GetScreenResolution = DisplayWidth & &quot;x&quot; & DisplayHeight
Width = DisplayWidth

End Function

Public Sub ResizeForm(frm As Form)

Dim ctl As Control
Dim I As Integer
Dim intTotalFormHeight As Integer
Dim intHeightHeader As Integer
Dim intHeightDetail As Integer
Dim intHeightFooter As Integer


On Error Resume Next
SetFactor 'Call to procedure SetFactor'
' Determine form's height.
intHeightHeader = frm.Section(acHeader).Height * Factor
intHeightDetail = frm.Section(acDetail).Height * Factor
intHeightFooter = frm.Section(acFooter).Height * Factor
intTotalFormHeight = intHeightHeader + intHeightDetail + intHeightFooter
With frm
.Width = frm.Width * Factor
.Section(acHeader).Height = frm.Section(acHeader).Height * Factor
.Section(acDetail).Height = frm.Section(acDetail).Height * Factor
.Section(acFooter).Height = frm.Section(acFooter).Height * Factor

End With
For Each ctl In frm.Controls
With ctl
.Height = ctl.Height * Factor
.Left = ctl.Left * Factor
.Top = ctl.Top * Factor
.Width = ctl.Width * Factor
.FontSize = ctl.FontSize * Factor
End With
Next ctl
End Sub

Sub SetFactor()

GetScreenResolution 'Call to function GetScreenResolution'
If Width = 800 Then
Factor = 1.25
Else
If Width = 1024 Then
Factor = 1.6
Else
If Width = 1152 Then
Factor = 1.8
Else: Factor = 1
End If
End If
End If

End Sub
Sub ResetWindowSize(frm As Form)
Dim intWindowHeight As Integer
Dim intWindowWidth As Integer
Dim intTotalFormHeight As Integer
Dim intTotalFormWidth As Integer
Dim intHeightHeader As Integer
Dim intHeightDetail As Integer
Dim intHeightFooter As Integer

' Determine form's height.
intHeightHeader = frm.Section(acHeader).Height
intHeightDetail = frm.Section(acDetail).Height
intHeightFooter = frm.Section(acFooter).Height
intTotalFormHeight = intHeightHeader + intHeightDetail + intHeightFooter
' Determine form's width.
intTotalFormWidth = frm.Width
' Determine window's height and width.
intWindowHeight = frm.InsideHeight
intWindowWidth = frm.InsideWidth

If intWindowWidth <> intTotalFormWidth Then
frm.InsideWidth = intTotalFormWidth
End If
If intWindowHeight <> intTotalFormHeight Then
frm.InsideHeight = intTotalFormHeight
End If
End Sub


I hope this helps you out!!
[sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top