Actually Kent, the question you pose (re: laying out forms) is good one. There are actually a couple of ways to do this. But the success of each one depends alot on the personal preferences and "mind set" of the individual:
1) TRIAL AND ERROR
The "trial and error" approach is the most common - even with the more advanced methods that I will outline below, trial and error is still the key strategy. Simply code the form and guess-timate the location and size of all the controls, then run the script and check it out, then adjust your code then run again. When designing a form, one might have to run the script dozens upon dozens of times to get the right look-and-feel. The only other thing I can say about this strategy is that one should never try to code the entire form all at once. Start with one element of the form, get it to look right, then move on to the next.
2) VB FORM DESIGNER
In terms of the way controls are constructed and configured, I tried to design Kixforms to be very similiar to VB and VB.NET. Having said that, one can even go so far as to design a form using Visual Studio, then take the generated .FRM file and copy it directly into ones script. Then manually "convert" all the statements over to Kixtart syntax. I've done this quite a bit in the past, when converting public domain VB source into Kixtart/Kixforms (ie, the MUD Manage User Details script). Here's some example VB6 .FRM statements:
code:
Begin VB.TextBox txtFullName
Height = 285
Left = 3600
TabIndex = 15
Top = 1245
Width = 3450
End
Begin VB.ListBox lstGroupPath
Height = 255
Left = 6105
TabIndex = 24
Top = 4380
Visible = 0 'False
Width = 855
End
Then just convert it to Kixforms:
code:
$txtFullName = $Form.TextBox
$txtFullName.Height = 285/15
$txtFullName.Left = 3600/15
$txtFullName.TabIndex = 15
$txtFullName.Top = 1245/15
$txtFullName.Width = 3450/15
$lstGroupPath = $Form.ListBox
$lstGroupPath.Height = 255/15
$lstGroupPath.Left = 6105/15
$lstGroupPath.TabIndex = 24
$lstGroupPath.Top = 4380/15
$lstGroupPath.Visible = 0 ; False
$lstGroupPath.Width = 855/15
Why divide by 15 ? This converts VB twips into pixel units of measure. This excersize can be done using visual studio and DOTNET as well:
code:
this.listView1 = new System.WinForms.ListView ();
listView1.Location = new System.Drawing.Point (40, 24);
listView1.Size = new System.Drawing.Size (480, 168);
listView1.FullRowSelect = true;
listView1.View = System.WinForms.View.Report;
listView1.ForeColor = System.Drawing.SystemColors.WindowText;
listView1.GridLines = true;
listView1.TabIndex = 0;
this.addbutton = new System.WinForms.Button ();
addbutton.Location = new System.Drawing.Point (320, 232);
addbutton.Size = new System.Drawing.Size (56, 48);
addbutton.TabIndex = 7;
addbutton.Text = "Add";
addbutton.Click += new System.EventHandler (this.addbutton_Click);
and the Kixforms version:
code:
$listView1 = $Form.ListView()
$listView1.Location = 40, 24
$listView1.Size = 480, 168
$listView1.FullRowSelect = true
$listView1.View = 3
$listView1.ForeColor = Blue
$listView1.GridLines = true
$listView1.TabIndex = 1
$addbutton = $Form.Button()
$addbutton.Location = 320, 232
$addbutton.Size = 56, 48
$addbutton.TabIndex = 7
$addbutton.Text = "Add"
$addbutton.OnClick = "addbutton_Click"
3) And lastly, the style that I prefer, is to leverage the size and location of existing objects to build the form on the fly. The way this works to to use all the builtin Kixforms positioning and sizing properties to quickly acheive a form effect (ever wonder why there were SO MANY position and sizing methods in Kixforms - this is why)
So for example, what I do is picture how the form will look in my mind, then describe it using words (again, in my mind), example:
code:
The form will 600 pixels wide by 400 pixels
in height. A listview will be positioned in the upper
left corner of the form and extend halfway
across the width and fully down to the bottom
(less about 10 pixels for a border). Just to the
right of the listview, will be a 100x30 button
containing the word "Exit"
Then I code it as follows:
code:
Break On
$Form = CreateObject("Kixtart.Form")
$Form.Size = 600,400
$ListView = $Form.Listview
$ListView.Location = 10,10 ; Upper left
$ListView.Right = 0.5 * $Form.ClientWidth ; Half the width of the form
$ListView.Bottom = $Form.ClientHeight - 10 ; All the way to the bottom
$Button = $Form.Button
$Button.Left = $ListView.Right + 10 ; Just to the right
$Button.Top = $ListView.Top ; same as listview
$Button.Size = 100,30 ; 100x30
$Button.Text = "Exit" ; The caption
$Form.Center
$Form.Show
While $Form.Visible
$=Execute($Form.DoEvents)
Loop
Hope this give you the flavours of the mind processes that go on when designing forms. Look forward to your comments and thoughts.
-Shawn
[ 02. November 2002, 21:23: Message edited by: Shawn ]