Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Code Samples & Tips Share your recent discoveries and ideas with other users.

Sample Resize function

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-03-2009, 05:20 PM
Junior Member
 
Join Date: Jun 2007
Posts: 17
Default Sample Resize function

' This repositions the controls adjusting height and width to the ratio to which the form has been changed.
' Stores initial control settings in InitControls() array

' Sample code to resize screen controls ....
'
Sub Globals
InitHeight = 0
InitWidth = 0

Dim Controls(0) ' Used by Change to VGA
Dim Type(Left,Top,Width,Height) InitControls(0) ' Used by Landscape / Port

End Sub

Sub App_Start
' Set Initial form Height and Width ..
InitHeight = Form1.Height
InitWidth = Form1.Width


frmLP.New1("Form1",B4PObject(1))


If form1.Height > 400 Then ChangeToVGA

Controls() = GetControls("") ' Get Controls Initial size and position
n = ArrayLen(Controls())
Dim InitControls(n,4)
For i = 0 To ArrayLen(Controls())-1
Select ControlType(Controls(i))
Case "ListBox","NumUpDown","Button","TextBox","Label"," ComboBox","Panel","RadioBtn","Table","ImageButton" ,"CheckBox","Image"
InitControls(i).Height = Control(Controls(i)).Height
InitControls(i).Top = Control(Controls(i)).Top
InitControls(i).Left = Control(Controls(i)).Left
InitControls(i).Width = Control(Controls(i)).Width
Case "TabControl.TabControl"
InitControls(i).Height = Control(Controls(i),TabControl).Height
InitControls(i).Top = Control(Controls(i),TabControl).Top
InitControls(i).Left = Control(Controls(i),TabControl).Left
InitControls(i).Width = Control(Controls(i),TabControl).Width
Case "ProgressBar.ProgressBar"
InitControls(i).Height = Control(Controls(i),ProgressBar).Height
InitControls(i).Top = Control(Controls(i),ProgressBar).Top
InitControls(i).Left = Control(Controls(i),ProgressBar).Left
InitControls(i).Width = Control(Controls(i),ProgressBar).Width
End Select
Next

frmLP_Resize

Form1.Show

End Sub

Sub frmLP_Resize
HeightRatio = form1.Height / (1.0 * InitHeight)
WidthRatio = form1.Width / (1.0 * Initwidth)


For i = 0 To ArrayLen(Controls())-1
Select ControlType(Controls(i))
Case "ListBox","NumUpDown","Button","TextBox","Label"," ComboBox","Panel","RadioBtn","Table","ImageButton" ,"CheckBox","Image"
Control(Controls(i)).Left = WidthRatio * InitControls(i).Left
Control(Controls(i)).Top = HeightRatio * InitControls(i).Top
Control(Controls(i)).Height = HeightRatio * InitControls(i).Height
Control(Controls(i)).Width = WidthRatio * InitControls(i).Width
Case "TabControl.TabControl"
Control(Controls(i),TabControl).Left = WidthRatio * InitControls(i).Left
Control(Controls(i),TabControl).Top = HeightRatio * InitControls(i).Top
Control(Controls(i),TabControl).Height = HeightRatio * InitControls(i).Height
Control(Controls(i),TabControl).Width = WidthRatio * InitControls(i).Width
Case "ProgressBar.ProgressBar"
Control(Controls(i),ProgressBar).Left = WidthRatio * InitControls(i).Left
Control(Controls(i),ProgressBar).Top = HeightRatio * InitControls(i).Top
Control(Controls(i),ProgressBar).Height = HeightRatio * InitControls(i).Height
Control(Controls(i),ProgressBar).Width = WidthRatio * InitControls(i).Width

'*** Uncomment these lines if your application includes Tables.
If ControlType(Controls(i)) = "Table" Then
tbl = Controls(i)
For i2 = 0 To Control(tbl,Table).ColCount-1
col = Control(tbl,Table).ColName(i2)
Control(tbl,Table).ColWidth(col) = Control(tbl,Table).ColWidth(col) * WidthRatio
Next
End If
End Select
Next

End Sub

' ChangeToVGA - from Erell's Tutorial
'
Sub ChangeToVGA
'Handles resolutions of 480 * 640
Controls() = GetControls("")
For i = 0 To ArrayLen(Controls())-1
Select ControlType(Controls(i))
Case "ListBox","NumUpDown","Button","TextBox","Label"," ComboBox","Panel","RadioBtn","Table","ImageButton" ,"CheckBox","Image"
Control(Controls(i)).Left = 2 * Control(Controls(i)).Left
Control(Controls(i)).Top = 2 * Control(Controls(i)).Top
Control(Controls(i)).Height = 2 * Control(Controls(i)).Height
Control(Controls(i)).Width = 2 * Control(Controls(i)).Width
Case "TabControl.TabControl"
Control(Controls(i),TabControl).Left = 2 * Control(Controls(i),TabControl).Left
Control(Controls(i),TabControl).Top = 2 * Control(Controls(i),TabControl).Top
Control(Controls(i),TabControl).Height = 2 * Control(Controls(i),TabControl).Height
Control(Controls(i),TabControl).Width = 2 * Control(Controls(i),TabControl).Width
'*** Uncomment these lines if your application includes Tables.
If ControlType(Controls(i)) = "Table" Then
tbl = Controls(i)
For i2 = 0 To Control(tbl,Table).ColCount-1
col = Control(tbl,Table).ColName(i2)
Control(tbl,Table).ColWidth(col) = Control(tbl,Table).ColWidth(col) * 2
Next
End If
End Select
Next

End Sub


' Hope this proves usefull does not include FONT rescaling...

Ian
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Resize textbox based on amount of text N1c0_ds Questions (Windows Mobile) 12 12-06-2008 05:58 PM
Beginner sample application gycs Questions (Windows Mobile) 1 09-11-2008 11:58 AM
D-Pad Navigation Sample (?) Dave Mitchell Questions (Windows Mobile) 1 05-14-2008 05:29 AM
Is it possible to open a JPEG and resize? tigme Questions (Windows Mobile) 5 02-19-2008 08:19 PM


All times are GMT. The time now is 10:25 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0