vb6: how do I size my main form (on startup)
so that it leaves the bottom line system tray
visible?.
If is do windowsize 2 for max. size it covers the tray up.
ShankarS
Nov 17th, 1999, 03:46 PM
Hi, I couldn't get u what u actually u r expecting Ok anyway. herewith i am sending some Procedures of script which is concern about the Resizing the form ,along with which will resize the controls accorindly.
Public Sub ResizeForm(pfrmIn As Form)
Dim FormControl As Control
Dim isVisible As Boolean
Dim StartX, StartY, MaxX, MaxY As Long
Dim bNew As Boolean
If Not bRunning Then
bRunning = True
If FindForm(pfrmIn) < 0 Then
bNew = True
Else
bNew = False
End If
If pfrmIn.Top < 30000 Then
isVisible = pfrmIn.Visible
On Error Resume Next
If Not pfrmIn.MDIChild Then
On Error GoTo 0
' ' pfrmIn.Visible = False
Else
If bNew Then
StartY = pfrmIn.Height
StartX = pfrmIn.Width
On Error Resume Next
For Each FormControl In pfrmIn
If FormControl.Left + FormControl.Width + 200 > MaxX Then
MaxX = FormControl.Left + FormControl.Width + 200
End If
If FormControl.Top + FormControl.Height + 500 > MaxY Then
MaxY = FormControl.Top + FormControl.Height + 500
End If
If FormControl.X1 + 200 > MaxX Then
MaxX = FormControl.X1 + 200
End If
If FormControl.Y1 + 500 > MaxY Then
MaxY = FormControl.Y1 + 500
End If
If FormControl.X2 + 200 > MaxX Then
MaxX = FormControl.X2 + 200
End If
If FormControl.Y2 + 500 > MaxY Then
MaxY = FormControl.Y2 + 500
End If
Next FormControl
On Error GoTo 0
pfrmIn.Height = MaxY
pfrmIn.Width = MaxX
End If
On Error GoTo 0
End If
For Each FormControl In pfrmIn
ResizeControl FormControl, pfrmIn
Next FormControl
On Error Resume Next
If Not pfrmIn.MDIChild Then
On Error GoTo 0
pfrmIn.Visible = isVisible
Else
If bNew Then
pfrmIn.Height = StartY
pfrmIn.Width = StartX
For Each FormControl In pfrmIn
ResizeControl formControl, pfrmIn
Next FormControl
End If
End If
On Error GoTo 0
End If
bRunning = False
End If
End Sub
**************
Private Sub ResizeControl(inControl As Control, pfrmIn As Form)
On Error Resume Next
Dim i As Long
Dim widthfactor As Single, heightfactor As Single
Dim minFactor As Single
Dim yRatio, xRatio, lTop, lLeft, lWidth, lHeight As Long
yRatio = PerHeight(pfrmIn)
xRatio = PerWidth(pfrmIn)
i = FindControl(inControl, pfrmIn.Name)
If inControl.Left < 0 Then
lLeft = CLng(((ControlRecord(i).Left * xRatio) \ 100) - 75000)
Else
lLeft = CLng((ControlRecord(i).Left * xRatio) \ 100)
End If
lTop = CLng((ControlRecord(i).Top * yRatio) \ 100)
lWidth = CLng((ControlRecord(i).Width * xRatio) \ 100)
lHeight = CLng((ControlRecord(i).Height * yRatio) \ 100)
If TypeOf inControl Is ListView Or TypeOf inControl Is SSTab Then 'attempting to adjust the font also RW
inControl.Font.Size = CLng((ControlRecord(i).FontSize * xRatio) \ 100)
inControl.Font.Bold = False
Else
inControl.FontSize = CLng((ControlRecord(i).FontSize * xRatio) \ 100)
inControl.FontBold = False
End If
If TypeOf inControl Is Line Then
If inControl.X1 < 0 Then
inControl.X1 = CLng(((ControlRecord(i).Left * xRatio) \ 100) - 75000)
Else
inControl.X1 = CLng((ControlRecord(i).Left * xRatio) \ 100)
End If
inControl.Y1 = CLng((ControlRecord(i).Top * yRatio) \ 100)
If inControl.X2 < 0 Then
inControl.X2 = CLng(((ControlRecord(i).Width * xRatio) \ 100) - 75000)
Else
inControl.X2 = CLng((ControlRecord(i).Width * xRatio) \ 100)
End If
inControl.Y2 = CLng((ControlRecord(i).Height * yRatio) \ 100)
Else
inControl.Move lLeft, lTop, lWidth, lHeight
inControl.Move lLeft, lTop, lWidth
inControl.Move lLeft, lTop
End If
End Sub
*****************
Private Function FindControl(inControl As Control, inName As String) As Long
Dim i As Long
FindControl = -1
For i = 0 To (MaxControl - 1)
If ControlRecord(i).Parrent = inName Then
If ControlRecord(i).Name = inControl.Name Then
On Error Resume Next
If ControlRecord(i).Index = inControl.Index Then
FindControl = i
Exit Function
End If
On Error GoTo 0
End If
End If
Next i
End Function
If u have any doubt feel free to ask me..
Aaron Young
Nov 17th, 1999, 08:12 PM
I'm assuming you want a Form that has no Border, Caption, etc..
In a Form with BorderStyle Set to Sizeable and ShowInTaskBar set to False and WindowState set to Maximized..
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000
Private Const WS_BORDER = &H800000
Private Sub Form_Load()
'A Maximized Sizable Form doesn't Cover the Taskbar
'So Just Remove the Caption and Border..
Call SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) Xor WS_CAPTION Xor WS_BORDER)
End Sub
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net