KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Script Archive
Tracking Systems

KiXforms 2.3.0 R.C. 1 Tips and Tricks

Post new topic   Reply to topic    KiXforms Forum Index -> Discussion
View previous topic :: View next topic  
Author Message
KiXforms Developer
KiXforms Developer

Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon Apr 19, 2004 12:16 pm    Post subject: KiXforms 2.3.0 R.C. 1 Tips and Tricks Reply with quote

Going to use this space to discuss some of the new features in the Build 43 ... would appreciate that any comments be directed to the DISCUSSION thread instead of this one, just to keep things clean ...

How to use the new Office Style menus

Firstly, the "old" menu system is still there. By default, if you dont do anything, the old menu system is used. To purposely "use" the new menus, you have to make only two modifications to your code.

Lets say you have these lines of code today:

$FileMenu = $Form.Menu.MenuItems.Add("File")
$OpenMenu = $FileMenu.MenuItems.Add("Open")

this basically creates a main "File" menu item, and an "Open" submenu item. To start using the new menus, just add this before it:

$Form.Menu = $System.MainMenu()
$Form.Menu.Style = 1

This does two things ... it "plugs" a new MainMenu object into the form, and activates it. Then it sets the "style" of the menu to 1 (office2k). If you didn't set the style, it would default to the old look and feel, but you would still be running on the new menus (its like a compatibility mode). One difference in this mode is that Icons are now supported. So its like the old menus, with icons.

If you want to use Icons in the menu, need to add one more line:

$Form.Menu.ImageList = ImageList

where ImageList could be $System.BuiltinImageList or an ImageList your created yourself, from a bitmap called a "strip".

So your modified code would look like:

$Form.Menu = $System.MainMenu()
$Form.Menu.Style = 1
$Form.Menu.ImageList = $System.BuiltinImageList()

$FileMenu = $Form.Menu.MenuItems.Add("File")
$OpenMenu = $FileMenu.MenuItems.Add("Open")

to set the Icon for a menuitem, just set the item's ImageIndex property like this:

$OpenMenu = $FileMenu.MenuItems.Add("Open")
$OpenMenu.ImageIndex = 0

0 (zero) points to the index in the ImageList to use as the icon. To setup Shortcuts (hotkeys) in menuitems, just set the Shortcut property like this:

$OpenMenu.Shortcut = "Ctrl+O"

Just as it would appear in the menu. Refer to the Shortcut property in the CHM file for a list of all the allowed shortcuts. If for some reason you dont like the text "Ctrl+O" that is displayed (lang. reasons) you can "override" this default text by using the ShortcutText property, like this:

$OpenMenu.Shortcut = "Ctrl+O"
$OpenMenu.ShortcutText = "Control+O"

and the ShortcutText string will be displayed in the menu instead.

Think thats all I have to say about menus for now. Down the road, I will be provide properties that will allow you to tailor the look and feel of the menu, things like BackColor and ForeColor and SelectedColor and even customizing the Font in menus (which you dont see too often).

Back to top
View user's profile Send private message
KiXforms Developer
KiXforms Developer

Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Mon Apr 19, 2004 2:47 pm    Post subject: Reply with quote

Ok RichTextBox ... it basically behaves (in the current release) somewhat like a regular old TextBox, supports (or will support) most of the same properties and methods, but the really feature is the HTML support.

Now don't be mislead ... RichTextBox doesn't render HTML like a real browser can. It has a very tiny builtin HTML parser and it supports only a small subset of HTML - I am kinda working toward the HTML 2.0 and maybe even 3.2 standard. Lots of tags still are not supported, even important ones like <A> anchors and <TABLE> tables and <UL> lists and <PRE> etc. But I meant this as an experimental thing, in its early stages ... the CHM file only hints at some of the supported tags, there were alot of additions added late in the game.

I really encourage you to give it a try and if you have any issues or more importantly, suggestions as to where we can go with this, would love to hear.

Even though hyper-link <A> anchor tags "show-up" properly in the control, there is no actual event triggered yet. That is because I am still working-out the "mechanics" of how these events should be presented. Whether the control should try to resolve the link itself, or whether a DoEvents even will fire and the script should resolve the link. I am kinda leaning toward the latter because that would provide the most flexibilty ... but really, let me share my vision of where this stuff could take us one day ...

Lets say you wanted to write an application that showed all the running services on a remote machine, and when the user clicked on a service, the service "details" would show up. Heres how I see this shaping up:


break on

$System = CreateObject("Kixtart.System")

$Browser = Browser()

While $Browser.Visible

Exit 1

Function Browser()
 dim $this

 If Not $System
  $System = CreateObject("Kixtart.System")

 $this = $System.Form()

 $this.Size = 640, 480
 $this.Font = $System.Font("Verdana",10)
 $this.Text = "Service Browser"

 $this.RichTextBox1 = $this.RichTextBox()
 $this.RichTextBox1.Location = 0,0
 $this.RichTextBox1.Size = $this.ClientSize
 $this.RichTextBox1.Anchor = 15
 $this.RichTextBox1.ReadOnly = 1
 $this.RichTextBox1.HTML = BrowserEnumServices($this)


 $Browser = $this


Function BrowserEnumServices($this)

 dim $str, $root, $service

 $root = GetObject("WinNT://@WKSTA")

 if $root

  $root.Filter = "Service",""
  $str = ""
  $str = $str + '<DIV STYLE=MARGIN-LEFT:30;MARGIN-RIGHT:30><BR>'
  $str = $str + '[ <A HREF="REFRESH">Refresh</A> ] '
  $str = $str + '[ <A HREF="EXIT">Exit</A> ]'
  $str = $str + '<BR>'
  $str = $str + '<FONT FACE="COURIER NEW" SIZE=3><BR><B>Running Services:</B></FONT><BR><BR>'
  $str = $str + '<FONT FACE="COURIER NEW" SIZE=2>'

  For Each $service In $root
   $name = $service.Name
   $str = $str + '<A HREF="$name">$name</A><BR>'


 $str = $str + '</FONT></DIV>'

 $BrowserEnumServices = $str


If that doesn't stir the imagine, not sure what will. One could decorate the form with all manner of "real" menus and buttons. And the RichTextBox would act as a sort of main window area, where information was presented ... with fancy fonts and links in full technicolor Wink

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group