ScreenWidth_Position 
Author Message
 ScreenWidth_Position

I'm resizing a form at runtime using Screen.Width /2 etc. I can get a
Listbox to take up a fifth of the screen by calculation, but what's the way
to position it? (Still searching the database). Ideally I want a ListBox at
the right hand side of a form which I've just told to resize itself to the
full screen width and height. Help appreciated.


Wed, 08 Sep 2004 00:18:06 GMT  
 ScreenWidth_Position
Rob,

How about this - one fifth of available screen width, and the
full height of the form ...

Sub Form_Resize( ...
    . . .
    List1.Move Me.ScaleWidth * ( 4 / 5 ) _
        , 0 _
        , Me.ScaleWidth * ( 1 / 5 ) _
        , Me.ScaleHeight
    . . .
End Sub

HTH,
    Phill  W.


Quote:
> I'm resizing a form at runtime using Screen.Width /2 etc. I can get a
> Listbox to take up a fifth of the screen by calculation, but what's
the way
> to position it? (Still searching the database). Ideally I want a
ListBox at
> the right hand side of a form which I've just told to resize itself to
the
> full screen width and height. Help appreciated.



Tue, 07 Sep 2004 18:22:44 GMT  
 ScreenWidth_Position

Quote:

> I'm resizing a form at runtime using Screen.Width /2 etc. I can get a
> Listbox to take up a fifth of the screen by calculation, but what's the way
> to position it? (Still searching the database). Ideally I want a ListBox at
> the right hand side of a form which I've just told to resize itself to the
> full screen width and height. Help appreciated.

Here is a generalized resizing routine....
Hope this helps
George
----------------------------------------------------
Option Explicit

Dim Scaler!, AllScale!
Dim Form1W%, Form1H%
Dim CtlL%(), CtlT%(), CtlW%(), CtlH%(), CtlF%()
Dim Ctl As Control
'Const Larger% = 43      'Plus on NumPad
'Const Smaller% = 45     'Minus on NumPad
Const Larger% = 38      'Up arrow on NumPad
Const Smaller% = 40     'Down arrow on NumPad
'
' All lines should have the form Linexx
' where xx is numeric
' example Line5, Line12
'

Private Sub Form_Load()
    Dim i%

    KeyPreview = True

    Scaler = 1.1
    AllScale = 1

'   Get number of controls
    For Each Ctl In Me.Controls
        i = i + 1
    Next

    ReDim CtlL(i), CtlT(i), CtlW(i), CtlH(i), CtlF(i)

'   Save locations
    i = 0
    For Each Ctl In Me.Controls
        i = i + 1
        If Left$(Ctl.Name, 4) = "Line" Then
            CtlL(i) = Ctl.X1
            CtlT(i) = Ctl.Y1
            CtlW(i) = Ctl.X2
            CtlH(i) = Ctl.Y2
        Else
            CtlL(i) = Ctl.Left
            CtlT(i) = Ctl.Top
            CtlW(i) = Ctl.Width
            CtlH(i) = Ctl.Height
            CtlF(i) = Ctl.FontSize
        End If

    Next

'   Save form values
    Form1W = Me.Width
    Form1H = Me.Height

End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = Larger Then
        KeyCode = 0
        If AllScale * Form1W >= Screen.Width Or AllScale * Form1H >=
Screen.Height Then Exit Sub

'   New scale
        AllScale = Scaler * AllScale
        FormReScale
    ElseIf KeyCode = Smaller Then
        KeyCode = 0
        If AllScale <= 1 Then Exit Sub

'   New scale
        AllScale = AllScale / Scaler
        FormReScale
    End If
End Sub
Private Sub FormReScale()
    Dim i%

    Me.Width = AllScale * Form1W
    Me.Height = AllScale * Form1H

' Rescale all controls
    For Each Ctl In Me.Controls
        i = i + 1

        If Left$(Ctl.Name, 4) = "Line" Then
            Ctl.X1 = CtlL(i) * AllScale
            Ctl.Y1 = CtlT(i) * AllScale
            Ctl.X2 = CtlW(i) * AllScale
            Ctl.Y2 = CtlH(i) * AllScale
        Else
            Ctl.Left = CtlL(i) * AllScale
            Ctl.Top = CtlT(i) * AllScale
            Ctl.Width = CtlW(i) * AllScale
            Ctl.Height = CtlH(i) * AllScale
            Ctl.FontSize = CtlF(i) * AllScale
        End If
    Next
End Sub



Tue, 07 Sep 2004 23:12:19 GMT  
 
 [ 3 post ] 

 Relevant Pages 
 

 
Powered by phpBB® Forum Software