Page 1 of 1 1
Topic Options
#172575 - 2007-01-09 03:16 PM KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 03
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
KiXforms.Net Learning Series - Windows Registry Run [Project 01 - Lesson 03]

Project 01 - Lesson 03 is a continuation of:
Project 01 - Lesson 01
Project 01 - Lesson 02
And is the last Lesson in the Project 01 Series.

Guidelines:
  • All scripters are welcome, Beginners to Masters.
  • KiXforms.Net version 3.1.45.0 or newer must be used. To verify your version of KiXforms.Net, use KiXforms.Net Version Checker (found below).
  • Please do not use this series just to bump your post count.
  • Do not post solutions until after solution post time is announced.
  • Collaboration is not allowed until after solution post time is announced.
  • I will post to indicate when solution post time starts.
  • Comments are a must, be descriptive but not excessive.
  • Use descriptive variable names to make it easier for yourself and others to follow what is happening.
  • The only help allowed is:
    • 'KiXforms.chm'
    • 'Kixforms.System.tlb'
    • 'Scripted Resource (Base64) Development Kit'
    • 'KiXforms Designer .NET 2.0 (Beta)'
    • 'The Script Center Script Repository'
    • 'KiXtart.org UDF library collection'
  • Note: 'KiXforms.chm' can be found in KiXforms.Zip (KF.NET Development Build)
    'Kixforms.System.tlb' can be found in your System32 directory after the installation of KiXforms.msi (found in 'KiXfomrs.zip').
    To view 'Kixforms.System.tlb' use iTripoli Type Library Viewer.
    If you choose, you can create a shortcut to the 'iTripoli Type Library Viewer' then, modify the shortcut target to:
    "C:\Program Files\iTripoli\Tools\TypeViewer.exe" Kixforms.System.tlb,
    then the shortcut will automatically open 'Kixforms.System.tlb'.
    Get Scripted Resource (Base64) Development Kit if you want or need it.
    Get KiXforms Designer .NET 2.0 (Beta) if you want or need it.
    Go to The Script Center Script Repository if you want or need to.
    Go to KiXtart.org UDF library collection if you want or need to.
    You can also modify UDFs found in 'KiXtart.org UDF library collection' if needed but make sure you comment on your changes.
  • All submitted code should be as though it were to be used in production.
    • Code should set options to On.
    • Error checking should be in place where needed.
    • All variables including form and controls should be Dimmed.
    • All UDFs should be self contained and all variables Dimmed.
  • All code should be in code tags.
  • When creating KiXforms the command console is not desired so use 'WKiX32.exe' not 'KiX32.exe'.

KiXforms.Net Version Checker:
Code:
;KiXforms.Net Version Checker

;Set Break to On if not in Logon Mode.
If Not @LogonMode
  Break On
EndIf

;Set Code Options to On
Dim $SO
$SO=SetOption("NoMacrosInStrings", "ON")
$SO=SetOption("NoVarsInStrings", "ON")
$SO=SetOption("Explicit", "ON")

;Setup Variables.
Dim $System,$nul,$MainForm,$ProductVersionLabel,$ProductNameLabel

;Create 'Kixforms.System' Object.
$System = CreateObject("Kixforms.System")

;Verify the 'Kixforms.System' Object was created if not, notify and exit.
If Not $System
  $nul= MessageBox("KiXforms.Net Not Initiated."+@CRLF+
  "Please verify KiXforms.Net is installed."+@CRLF+
  "This Script Will Now Close.","Error",16)
  Quit()
EndIf

;Create Form and Controls.
$MainForm = $System.Form()
$MainForm.StartPosition = $System.FormStartPosition_CenterScreen
$MainForm.Size = $System.Size(338,83)
$MainForm.Text = "KiXforms.Net Version Checker"

$ProductVersionLabel = $System.Label()
$ProductVersionLabel.Dock = $System.DockStyle_Top
$ProductVersionLabel.Text = "Ver. "+$System.ProductVersion
$ProductVersionLabel.TextAlign = $System.ContentAlignment_MiddleCenter
$nul = $MainForm.Controls.Add($ProductVersionLabel)

$ProductNameLabel = $System.Label()
$ProductNameLabel.Dock = $System.DockStyle_Top
$ProductNameLabel.Text = $System.ProductName
$ProductNameLabel.TextAlign = $System.ContentAlignment_MiddleCenter
$nul = $MainForm.Controls.Add($ProductNameLabel)

;Show the Form
$MainForm.Show

;Loop to catch form events.
While $MainForm.Visible
  $nul = Execute($MainForm.DoEvents())
Loop
Exit 0


Objectives for Lesson 03:
  • Allow the user to:
    • Delete - move the checked entries from the top 'ListView.Items' to the bottom 'ListView.Items'.
    • Save - delete all entries (Listed in the bottom 'ListView.Items') from the selected 'Run' key, clear both 'ListView.Items' and re-enumerate the entries of the selected 'Run' key.
  • The 'Save Button' should only be enabled when the user clicks the 'Delete Button' and should be disabled when the user clicks the 'Save Button', 'Backup Button', 'Restore Button', and the 'Refresh Button'.
  • The 'Backup Button' and 'Restore Button' should be disabled when the user clicks the 'Delete Button' and enabled when the user clicks the 'Save Button' or the 'Refresh Button'.
  • If no 'ListView.Items' are added to the bottom 'ListView' then the 'Save Button' should not be enabled and the 'Backup Button' and 'Restore Button' should not be disabled.
  • The sorting order for both 'ListViews' should be set to ascending.

Create:
  • A function for the 'Delete Button.Click' event.
  • A function for the 'Save Button.Click' event.

You may ask questions, but do not post code.
I will post when solutions may be posted.
You may begin..
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#172585 - 2007-01-09 06:01 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 03 [Re: Benny69]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
why restore is disabled with delete and enabled with refresh?
_________________________
!

download KiXnet

Top
#172594 - 2007-01-09 07:35 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 03 [Re: Lonkero]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Quote:
Delete - move the checked entries from the top 'ListView.Items' to the bottom 'ListView.Items'.


Do you want the entry actually removed from the top Listview, or just copied into the bottom Listview?
_________________________
Today is the tomorrow you worried about yesterday.

Top
#172603 - 2007-01-10 12:58 AM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 03 [Re: Gargoyle]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Gargoyle,
Move it (remove from the top and add to the bottom) because:
Quote:

Save - delete all entries (Listed in the bottom 'ListView.Items') from the selected 'Run' key, clear both 'ListView.Items' and re-enumerate the entries of the selected 'Run' key.
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#172879 - 2007-01-17 03:29 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 03 [Re: Benny69]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
You may begin posting your code at 06:00 am GMT Friday Morn.
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#174207 - 2007-02-23 09:15 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 03 [Re: Benny69]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
No it could not be as easy as I thought it might be... Oh well I am finally started on this project

[Edit]
And here is my attempt at the the solution....
[/Edit]


Edited by Gargoyle (2007-02-23 11:43 PM)
_________________________
Today is the tomorrow you worried about yesterday.

Top
#174209 - 2007-02-23 11:44 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 03 [Re: Gargoyle]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
If Not @LogonMode
    Break On
EndIf

;Declare Variables that will be used throughout
Global $SO, $Nul

;Set Code Options to On

$SO=SetOption("NoMacrosInStrings", "ON")
$SO=SetOption("NoVarsInStrings", "ON")
$SO=SetOption("Explicit", "ON")
$SO=SetOption("WrapAtEOL", "ON")

;Declare Variables for the form

DIM $MainMenu,$MenuItem1,$MenuItem2
DIM $Button_Text,$Button_Top[],$Lbl_Info
DIM $Splitter
DIM $Button_Click[],$ControlStackImageList


Global $System,$Form_Main,$ListView1,$ListView2,$Cmb_RegEntry,$Button[5],$Panel_ControlStack
Global $Panel_MainChild,$Panel_ChildInMainChild,$ListView2Column[1],$ListView1Column[1]
Global $ListView1Item[],$ListView2Item[]

;Array build information
$Button_Text = "Exit","Delete","Refresh","Restore","Backup","Save"
$Button_Top = 120,96,72,48,24,0
$Button_Click = "IWantOut()","Delete()","ListViewChange($CMB_RegEntry.SelectedIndex)",
   
"Restore($CMB_RegEntry.SelectedIndex)","Backup($CMB_RegEntry.SelectedIndex)","Save($CMB_RegEntry.SelectedIndex)"


;Check for existence of KiXForms
$System = CreateObject("Kixforms.System")
If Not $System
$nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
Quit()
EndIf
$nul = $System.Application.EnableVisualStyles

;Build the Form
$Form_Main = $System.Form()
$Form_Main.StartPosition = 1
$Form_Main.Size = $System.Size(600,400)
$Form_Main.Text = "Project1 - Lesson 1"
$Form_Main.SizeChanged = "Resize()"
$Form_Main.Icon = $System.Icon.FromBase64String(FormImage())

;Build the menu bar
$MainMenu = $System.MainMenu()

$MenuItem1 = $MainMenu.MenuItems.Add($System.MenuItem("File"))

$MenuItem2 = $MenuItem1.MenuItems.Add($System.MenuItem("Exit"))
$MenuItem2.Click = "IWantOut()"

$Form_Main.Menu = $MainMenu

;Add Two Panels that will allow for splitting
$Panel_MainChild = $System.Panel()
$Panel_MainChild.Borderstyle = 1
$Panel_MainChild.Dock = 5
$Nul = $Form_Main.Controls.Add($Panel_MainChild)

;Now we can add the top Listview
$ListView1 = $System.ListView()
$ListView1.Dock = 5
$ListView1.GridLines = -1 ;True
$ListView1.Checkboxes = -1 ;True
$ListView1.View = $System.View_Details
$nul = $Panel_MainChild.Controls.Add($ListView1)

;Add the ComboBox
$CMB_RegEntry = $System.ComboBox()
;$CMB_RegEntry.DropDownWidth = 512
$CMB_RegEntry.IntegralHeight = 0
$CMB_RegEntry.ItemHeight = 13
$CMB_RegEntry.Dock = 1
$CMB_RegEntry.SelectedIndexChanged = "ListViewChange($CMB_RegEntry.SelectedIndex)"
$nul = $Panel_MainChild.Controls.Add($CMB_RegEntry)

;Add in the Splitter
$Splitter = $System.Splitter()
$Splitter.Dock = 2
$Splitter.Height = 3
$nul = $Panel_MainChild.Controls.Add($Splitter)

;Add the secondary panel to the one just created
$Panel_ChildinMainChild = $System.Panel()
$Panel_ChildinMainChild.Borderstyle = 1
$Panel_ChildinMainChild.Dock = 2
$Nul = $Panel_MainChild.Controls.Add($Panel_ChildinMainChild)

;Insert the Bottom Listview
$ListView2 = $System.ListView()
$ListView2.GridLines = -1 ;True
$ListView2.View = $System.View_Details
$ListView2.Dock = 5
$nul = $Panel_ChildInMainChild.Controls.Add($ListView2)

;Add the Label
$Lbl_Info = $System.Label()
$Lbl_Info.BorderStyle = 1
$Lbl_Info.Dock = 1
$Lbl_Info.Text = "Entries to Delete"
$Lbl_Info.TextAlign = 32
$nul = $Panel_ChildInMainChild.Controls.Add($Lbl_Info)


;Set up Column headers for ListViews
$ListView2Column[0] = $ListView2.Columns.Add($System.ColumnHeader("Entry",100,$System.HorizontalAlignment_Left))
$ListView2Column[1] = $ListView2.Columns.Add($System.ColumnHeader("Value",100,$System.HorizontalAlignment_Center))
$ListView1Column[0] = $ListView1.Columns.Add($System.ColumnHeader("Entry",100,$System.HorizontalAlignment_Left))
$ListView1Column[1] = $ListView1.Columns.Add($System.ColumnHeader("Value",100,$System.HorizontalAlignment_Center))

;Add Control Stack containing panel
$Panel_ControlStack = $System.Panel()
$Panel_ControlStack.Borderstyle = 1
$Panel_ControlStack.Dock = 3
$Nul = $Panel_MainChild.Controls.Add($Panel_ControlStack)

;Build the ImageList for the ControlStack
$ControlStackImageList = $System.Imagelist()
$ControlStackImageList.ImageSize = $System.Size(16,16)
$Nul = $ControlStackImageList.Images.AddStrip($System.Bitmap.FromBase64String(ControlStackImageList()))

;Build the Buttons for the Control Stack
;Buttons are built from the bottom up
;See definition of Button_Text[] Array for clarification

For $SO = 0 to Ubound($Button)
$Button[$SO] = $System.Button()
$Button[$SO].Left = 0
$Button[$SO].TextAlign = 64
$Button[$SO].Top = $Button_Top[$SO]
$Button[$SO].Text = $Button_Text[$SO]
$Button[$SO].Click = $Button_Click[$SO]
$Button[$SO].ImageList = $ControlStackImageList
$Button[$SO].ImageAlign = 16
$Button[$SO].ImageIndex = $SO
$Nul = $Panel_ControlStack.Controls.Add($Button[$SO])
Next

;Set the widths of everything to match the form  
$Panel_ControlStack.Width = 79
Resize()
CMB_Fill()
; Unsure why we are using a function for this, but may assume it will              
; be because of future development  
$CMB_RegEntry.SelectedIndex = 0 ; So that the combobox does not appear to be empty upon launch


$Form_Main.Show ;Displays the Form

While $Form_Main.Visible
$Nul = Execute($Form_Main.DoEvents())
Loop
Exit 0

;================================================================================================
; Functions
;================================================================================================

Function Resize()
DIM $Width
If $Form_Main.Width => 600
   
$Width = $Form_Main.Width - 86
Else
    $Form_Main.Width = 600
   

EndIf
If $Form_Main.Height < 400
   
$Form_Main.Height = 400
EndIf

EndFunction

;=====================================

Function IWantOut()
Quit @ERROR
EndFunction

;=====================================

Function CMB_Fill()
Global $RegKey[1]
$RegKey[0] = $CMB_RegEntry.Items.Add("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\")
$RegKey[1] = $CMB_RegEntry.Items.Add("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\")
EndFunction

;=====================================

Function ListViewChange($Index)
DIM $Values,$Count,$Count2

;Clear out the listViews 
$ListView1.items.clear
$Listview2.items.clear
;Build and array with all of the Key Values under the selected RegKey
$Values = Arrayenumvalue($RegKey[$Index])

;Setup counters for the filling of items
$Count = 0 ; Item Counter to build the Array of items contained within the listview
$Count2 = 0 ; Row Counter so as to build the subitems in the listview

;Loop through the Key Values array and add to the ListView
For Each $SO In $Values
    ReDIM Preserve $ListView1Item[$Count+1]
   
;Add the Key to the first column in the Listview
    $ListView1Item[$count] = $ListView1.items.Add($system.listviewitem($SO))
   
;Add the Values of the specified key to the subitems list
    ;Increment the $Count by 1 so that it can be referenced as an individual item
    $ListView1Item[$count+1] = $Listview1.items.item($Count2).SubItems.Add($System.ListViewSubItem(ReadValue($RegKey[$Index],$SO)))
   
$Count = $Count+10
   
$Count2 = $Count2+1
Next
;Disable the Save Button
$Button[5].Enabled = 0
$Button[4].Enabled = -1
$Button[3].Enabled = -1
EndFunction

;=====================================

Function Delete()
DIM $Item,$count

$count = 0
;See what items are checked...

For $Item = 0 to Ubound($Listview1Item)
    If $Listview1Item[$Item].Checked = -1
       
Redim Preserve $Listview2Item[$item+1]
       
$ListView2Item[$Item] = $Listview2.items.add($system.listviewitem($listview1item[$Item].text))
       
$Listview2item[$item+1] = $listview2.items.item($count).Subitems.add($system.listviewsubitem($listview1item[$item+1].text))
       
$Listview1item[$item].remove
       
$count = $count+1    
   
Endif
    $Item = $Item + 9
Next
If
$ListView2.items.count > 0
   
$Button[3].Enabled = 0
   
$Button[4].Enabled = 0
   
$Button[5].Enabled = -1
EndIf

EndFunction
;=====================================

Function SAVE($Index)
Dim $Key

For $SO = 0 to $ListView2.Items.Count
    $Key = $Listview2.Items.Item($SO).Text
   
$Nul = DelValue($RegKey[$index],$Key)
Next

ListViewChange($Index)

EndFunction

;=====================================
;Courtesy Sealeopard UDF

Function arrayenumvalue($regsubkey)
DIM $retcode, $valuecounter, $currentvalue, $valuearray

If not KeyExist($regsubkey)
Exit 87
EndIf

$valuecounter=0
Do
$currentvalue=EnumValue($regsubkey,$valuecounter)
If not @ERROR
ReDIM preserve $valuearray[$valuecounter]
$valuearray[$valuecounter]=$currentvalue
$valuecounter=$valuecounter+1
EndIf
Until @ERROR

$arrayenumvalue=$valuearray
Exit 0
EndFunction

;=====================================
Function Backup($Index)
;Backup all entries in the top ListView to the repective "RunBackup" key
DIM $Key,$Value    
For $SO = 1 To $ListView1.Items.Count
    ;Retrieve the Key Value from the ListView
    $Key = $Listview1.Items.Item($SO).text
   
;Retrieve the value from the Subitems of the ListView
    $Value = $ListView1.Items.Item($SO).subItems.Item(1).text
   

;I tried putting the $Key and $Value directly in the WriteValue, but it
;continually gave me invaled method / function call


    $Nul = WriteValue($RegKey[$index]+"RunBackup",$Key,$Value,REG_SZ)
Next

ListViewChange($Index)

EndFunction

;=====================================
Function Restore($Index)
;Restore all entries from the "RunBackup" Key to the Selected Key
DIM $Key, $Value
For Each $Key In ArrayEnumvalue($RegKey[$Index]+"Runbackup")
   
$Value = ReadValue($RegKey[$Index]+"RunBackup",$Key)
   
$Nul = WriteValue($RegKey[$Index],$Key,$Value,REG_SZ)
Next
ListViewChange($Index)
EndFunction

;=====================================


;================================================================================================
; Image Strings
;================================================================================================

Function ControlStackImageList()
$ControlStackImageList = "
iVBORw0KGgoAAAANSUhEUgAAAGAAAAAQCAYAAADpunr5AAAACXBIWXMAAA7DAAAO
wwHHb6hkAAAGmElEQVR4nO2YW2wU5xmGv5vcRFGVq14lUitVucAkWTxSaKOgWKIH
kcgVAdGGQhungRVNIpTWmKQgYqMSWpI0NJUWexrAFBI7DjQGLT4sxudl7bWXGIxh
fWBNfdj1OevYpix22KcX49md3Z2xHUBqVfWTXmk08//fq/99//m+f0bk//HfEX+p
HOWPJdcXxf6iLv4X+f/j8YFzkGg0ilnc/hqmbmvI+8cgfyhsTxDhTroQVYQ76XLX
4twLf0IoKt/6UREPPHMMUVTzcYpq/cxqrBFJkbPfRUZGEdPT04vC5Wpn48ZaMjOT
8vz5dB9zc3Omi4/MQfiWhk2V8JsTfbyd3xJL8HW6YMSSFpYU98JvFOpXJ6f4eTk8
VgQPHhg3F23lEWR1Sfy+ovLtzFOp4xQVefYTZIsXyQsir7cjK4+kjPsmBpw7d8Xc
gHc/6yYSicQWHo1qi/8qoi18eFrD34pDfHg0SHbO8YQE/1ohGGEm8ly6cEfR3pbk
Z2b8XeEbrDqTwTNnMuicCCOqWPJ/b2st68rg0QMhHvyZC1nvQrZ3IO+MIrmDCWJL
phOx+xLurT4ND73gjOf84WfavNxBZGePlm9DlTbvFW+CCd/EgKqqq+YGHCj2c/Pm
zZgAkTm4NauJPzID/ZPQF4aaGigthd/u+HuKiDdXCDPzmLYlihxZIcymC3MWb0gy
/0f+QkSVGB75+DuIKub8isrTx6ZI+5TUcrGjC8npQV6oiN8zMeC7H8MDP3XGTcoL
athQhXz/aHzuK97EuUkGeL1e6urqqK+vp6GhAbfbjdvtxuPx0N7ezvnzFgbsP9bG
1NQU0agmPopwe0+WtvMvtjH1+yy6x6F9GHxB2P7GEVMhwzbBiCmbZsa0TZixWZen
ZH5RhZymPLxDN/jJ2bUxI0z5FRVRQQqiqfl14ey+uHAmBohjDnnuNLK2XBN+2xda
uUmOlUe0uYYSZjSgpaWF+vp6GhsbcbvdXLhwAY/HQ1NTEx0dHVRX+80NeOdwK+Fw
mMgcRPpvgCKgCMMX27jz7MOgCCH1IL4gtA7C69s/shTzS5swMY+wTZi0CV8tIH4y
v3e4jbpgGyMz0DEWZlmJLWaAKb8u4Acz1k13vU
_________________________
Today is the tomorrow you worried about yesterday.

Top
#174210 - 2007-02-24 12:03 AM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 03 [Re: Gargoyle]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Looks like the tail got cut off.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#174211 - 2007-02-24 12:06 AM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 03 [Re: Les]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
You are correct.. Wonder why it did that... Is there a length limit?


Here is the section labeled Image Strings again You will have to paste them together...

 Code:
;================================================================================================
;                                     Image Strings
;================================================================================================
Function ControlStackImageList()
$ControlStackImageList = "
iVBORw0KGgoAAAANSUhEUgAAAGAAAAAQCAYAAADpunr5AAAACXBIWXMAAA7DAAAO
wwHHb6hkAAAGmElEQVR4nO2YW2wU5xmGv5vcRFGVq14lUitVucAkWTxSaKOgWKIH
kcgVAdGGQhungRVNIpTWmKQgYqMSWpI0NJUWexrAFBI7DjQGLT4sxudl7bWXGIxh
fWBNfdj1OevYpix22KcX49md3Z2xHUBqVfWTXmk08//fq/99//m+f0bk//HfEX+p
HOWPJdcXxf6iLv4X+f/j8YFzkGg0ilnc/hq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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB
AQEBAQEBAQEGBgYBAQAAAQEBAQEBBgYAAAAGAQEAAAEBAQEBAAAAAAMABgEBAAAB
AQEBAQAGAQAAAAEBAQAAAQEBAQEABgEBBgYGAQEAAAEBAQEBAAYGAAAABgEBAAAB
AQEBAQAAAAACAAYBAQAAAQEBAQEABgYAAAABAQEAAQYGBgYAAAAGAQEBAQEBAAEA
AAAAAAUABgEBAQEBAQABAAYBAQAAAAEBAQEBAQEAAQAGAQEBAQEBAQEBAQEBAAAA
AAYDAwMDAwMDAwMDAwAABAAGAwMDAwMDAwMDAwMAAAAABgAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAA="

EndFunction
_________________________
Today is the tomorrow you worried about yesterday.

Top
#174222 - 2007-02-24 06:37 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 03 [Re: Gargoyle]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Here is my solution.
 Code:
;region Set Code Options
;Set Break to On if not in Logon Mode.
If Not @LogonMode
	Break On
EndIf

;Set Code Options to On
Dim $SO
$SO=SetOption("NoMacrosInStrings", "ON")
$SO=SetOption("NoVarsInStrings", "ON")
$SO=SetOption("Explicit", "ON")
;endregion Set Code Options

;region Setup Varibles
;Dim variables in order of creation.
Global $System,$MainForm
Dim $nul,$ImageList,$MainMenu,$FileMenuItem,$ExitMenuItem,$MainPanel
Dim $DeletePanel,$DeleteListView,$DeleteListViewColumn0,$DeleteListViewColumn1,$DeleteLabel
Dim $Splitter
Dim $ActivePanel,$ActiveListView,$ActiveListViewColumn0,$ActiveListViewColumn1,$ActiveComboBox
Dim $ControlPanel,$ControlButton,$Controls,$Control,$ImageIndex

;Create an array of names of the 'Control Stack'.
$Controls = "Exit","Delete","Refresh","Restore","Backup","Save"

;Create 'Kixforms.System' Object.
$System = CreateObject("Kixforms.System")

;Verify the 'Kixforms.System' Object was created if not, notify and exit.
If Not $System
	$nul= MessageBox("KiXforms.Net Not Initiated."+@CRLF+
	"Please verify KiXforms.Net is installed."+@CRLF+
	"This Script Will Now Close.","Error",16)
	Quit()
EndIf

;Create an 'ImageList' for the 'Control Stack'.
$ImageList = $System.ImageList()
$ImageList.ImageSize = $System.Size(16,16)
$nul = $ImageList.Images.AddStrip(ControlImages())
;endregion Setup Varibles

;region Main Form
;Create Form and Controls.
;Store the original 'MainForm.Size' in 'MainForm.Tag' for easy retrieval in the 'MainForm.SizeChanged' event function.
$MainForm = $System.Form()
$MainForm.Font = $System.Font("Verdana",8.25,0) ;Regular
$MainForm.Icon = $System.Icon.FromBitmap(FormIcon())
$MainForm.StartPosition = $System.FormStartPosition_CenterScreen
$MainForm.Size = $System.Size(600,400) ;(Width,Height)
$MainForm.SizeChanged = "OnFormSizeChange()"
$MainForm.Text = "Windows Registry Run [Project 01 - Lession 03]"
$MainForm.Tag = $System.Size(600,400) ;(Width,Height)

;Create the MainMenu.
$MainMenu = $System.MainMenu()
$FileMenuItem = $MainMenu.MenuItems.Add($System.MenuItem("File"))
$ExitMenuItem = $FileMenuItem.MenuItems.Add($System.MenuItem("Exit"))
$ExitMenuItem.Click = "ExitForm()"
$MainForm.Menu = $MainMenu

;region Form Controls
;Most controls are attached to the MainPanel.
$MainPanel = $System.Panel()
$MainPanel.Dock = $System.DockStyle_Fill
$nul = $MainForm.Controls.Add($MainPanel)

;region Active Panel
;Create the upper Panel, it contains the controls above the spliter.
$ActivePanel = $System.Panel()
$ActivePanel.BorderStyle = $System.BorderStyle_Fixed3D
$ActivePanel.Dock = $System.DockStyle_Fill
$ActivePanel.Height = 160
$nul = $MainPanel.Controls.Add($ActivePanel)

;Create the upper ListView, to display the current registry entries.
;Set the '.Name' property to a descriptive name to allow ease of location later.
$ActiveListView = $System.ListView()
$ActiveListView.CheckBoxes = "True"
$ActiveListView.Dock = $System.DockStyle_Fill
$ActiveListView.FullRowSelect = "True"
$ActiveListView.GridLines = "True"
$ActiveListView.Name = "ActiveListView"
$ActiveListView.Sorting = $System.SortOrder_Ascending
$ActiveListView.View = $System.View_Details
$nul = $ActivePanel.Controls.Add($ActiveListView)

;Create the Columns for the upper ListView.
$ActiveListViewColumn0 = $ActiveListView.Columns.Add($System.ColumnHeader("Entry",100,$System.HorizontalAlignment_Left))
$ActiveListViewColumn1 = $ActiveListView.Columns.Add($System.ColumnHeader("Value",100,$System.HorizontalAlignment_Left))

;Create a ComboBox for the upper ListView to tell the user what registry key the user is viewing.
;Set the '.Name' property to a descriptive name to allow ease of location later.
$ActiveComboBox = $System.ComboBox()
$ActiveComboBox.Dock = $System.DockStyle_Top
$ActiveComboBox.Name = "ActiveComboBox"
$ActiveComboBox.SelectedIndexChanged = "MainForm_Refresh()"
$nul = $ActivePanel.Controls.Add($ActiveComboBox)
;endregion Active Panel

;Create a horizontal Splitter so the user can adjust the vertical size of the ListViews.
$Splitter = $System.Splitter()
$Splitter.BackColor = $System.Color.FromName("ActiveCaption")
$Splitter.Dock = $System.DockStyle_Bottom
$Splitter.Height = 3
$nul = $MainPanel.Controls.Add($Splitter)

;region Delete Panel
;Create the lower Panel, it contains the controls below the spliter.
$DeletePanel = $System.Panel()
$DeletePanel.BorderStyle = $System.BorderStyle_Fixed3D
$DeletePanel.Dock = $System.DockStyle_Bottom
$DeletePanel.Height = 150
$nul = $MainPanel.Controls.Add($DeletePanel)

;Create the lower ListView, to display the registry entries to be deleted.
;Set the '.Name' property to a descriptive name to allow ease of location later.
$DeleteListView = $System.ListView()
$DeleteListView.Dock = $System.DockStyle_Fill
$DeleteListView.FullRowSelect = "True"
$DeleteListView.GridLines = "True"
$DeleteListView.Name = "DeleteListView"
$DeleteListView.Sorting = $System.SortOrder_Ascending
$DeleteListView.View = $System.View_Details
$nul = $DeletePanel.Controls.Add($DeleteListView)

;Create the Columns for the lower ListView.
$DeleteListViewColumn0 = $DeleteListView.Columns.Add($System.ColumnHeader("Entry",100,$System.HorizontalAlignment_Left))
$DeleteListViewColumn1 = $DeleteListView.Columns.Add($System.ColumnHeader("Value",100,$System.HorizontalAlignment_Left))

;Create a Lable for the lower ListView to tell the user what the lower ListView is for.
$DeleteLabel = $System.Label()
$DeleteLabel.Dock = $System.DockStyle_Top
$DeleteLabel.Height = 20
$DeleteLabel.Text = "Entries to Delete"
$DeleteLabel.TextAlign = $System.ContentAlignment_MiddleCenter
$nul = $DeletePanel.Controls.Add($DeleteLabel)
;endregion Delete Panel

;region User Controls
;Create a Panel for the form user controls.
$ControlPanel = $System.Panel()
$ControlPanel.BorderStyle = $System.BorderStyle_Fixed3D
$ControlPanel.Dock = $System.DockStyle_Left
$ControlPanel.Width = 90
$nul = $MainForm.Controls.Add($ControlPanel)

;Create the user controls: Exit, Delete, Refresh, Restore, Backup, Save.
;Set the '.Name' property to a descriptive name to allow ease of location later.
;Set the '.Click' event to trigger the 'ControlClick(Control.Name)' function.
$ImageIndex = 0
For Each $Control in $Controls
	$ControlButton = $System.Button()
	$ControlButton.Click = "ControlClick('"+$Control+"')"
	$ControlButton.Dock = $System.DockStyle_Top
	$ControlButton.Height = 26
	$ControlButton.ImageAlign = $System.ContentAlignment_TopLeft
	$ControlButton.ImageList = $ImageList
	$ControlButton.ImageIndex = $ImageIndex
	$ControlButton.Name = $Control
	$ControlButton.Text = $Control
	$ControlButton.TextAlign = $System.ContentAlignment_MiddleRight
	$nul = $ControlPanel.Controls.Add($ControlButton)
	$ImageIndex = $ImageIndex + 1
Next
$ControlButton.Enabled = "False"
;endregion User Controls

;endregion Form Controls

;region Startup
PopulateActiveComboBox()
;endregion Startup

;Show the Form
$MainForm.Show

;Loop to catch form events.
While $MainForm.Visible
   $nul = Execute($MainForm.DoEvents())
Loop
Exit 0
;endregion Main Form

;region Main Form Functions

;The 'OnFormSizeChange()' function adjusts the size of the form to the minimum size
;if the user tries to Set it too Small.
Function OnFormSizeChange()
	Dim $MainForm_Size
	;Retrieve the original 'MainForm.Size' from 'MainForm.Tag'
	$MainForm_Size = $MainForm.Tag
	If $MainForm.Width < $MainForm_Size.Width And Not($MainForm.WindowState = 1)
    $MainForm.Width = $MainForm_Size.Width
  EndIf
  If $MainForm.Height < $MainForm_Size.Height And Not($MainForm.WindowState = 1)
    $MainForm.Height = $MainForm_Size.Height
  EndIf
EndFunction

;The 'PopulateActiveComboBox()' function adds items to the 'ActiveComboBox'.
Function PopulateActiveComboBox()
	Dim $ActiveComboBox,$Item
	
	;Find the 'ActiveComboBox' control.
	$ActiveComboBox = $MainForm.FindControl("ActiveComboBox")
	;Add items to the 'ActiveComboBox' control.
	$Item = $ActiveComboBox.Items.Add("HKey_Local_Machine\Software\Microsoft\Windows\CurrentVersion\Run")
	$Item = $ActiveComboBox.Items.Add("HKey_Current_User\Software\Microsoft\Windows\CurrentVersion\Run")
	$ActiveComboBox.SelectedIndex = 0
EndFunction

;The 'MainForm_Refresh()' function is called when the
;'SelectedIndexChanged' event is triggered from the 'ActiveComboBox'.
;It clears the 'ActiveListView.Items', clears the 'DeleteListView.Items',
;populates the 'ActiveListView.Items' with the entries of the selected 'Run' key,
;disables the 'Save Button' and enables the 'Backup Button' and 'Restore Button'.
Function MainForm_Refresh()
	Dim $ActiveComboBox,$ActiveListView,$DeleteListView,$SaveButton,$BackupButton,$RestoreButton,
	$Entries,$Array,$Entry,$Value,$Item0,$Item1
	
	;Find the 'ActiveComboBox' control.
	$ActiveComboBox = $MainForm.FindControl("ActiveComboBox")
	;Find the 'ActiveListView' control.
	$ActiveListView = $MainForm.FindControl("ActiveListView")
	;Find the 'DeleteListView' control.
	$DeleteListView = $MainForm.FindControl("DeleteListView")
	;Find the 'Save Button' user control.
	$SaveButton = $MainForm.FindControl("Save")
	;Find the 'Backup Button' user control.
	$BackupButton = $MainForm.FindControl("Backup")
	;Find the 'Restore Button' user control.
	$RestoreButton = $MainForm.FindControl("Restore")
	;Clear the 'ActiveListView.Items' collection.
	$ActiveListView.Items.Clear
	;Clear the 'DeleteListView.Items' collection.
	$DeleteListView.Items.Clear
	;Enumerate the registry entries selected in the 'ActiveComboBox.Text' property.
	$Entries = GetKeyEntries($ActiveComboBox.Text)
	
	;Loop thru each entry in the 'Entries' array and add them to the 'ListView'.
	For Each $Array in $Entries
		$Entry = Split($Array,"|")[0]
		$Value = Split($Array,"|")[1]
		$Item0 = $ActiveListView.Items.Add($System.ListViewItem($Entry))
		$Item1 = $Item0.SubItems.Add($System.ListViewSubItem($Value))
	Next
	
	;Resize the 'ActiveListView' columns to the width of the largest 'ActiveListView.Items'
	$ActiveListView.Columns.Item(0).Width = -1
	If $ActiveListView.Columns.Item(0).Width < 100
		$ActiveListView.Columns.Item(0).Width = 100
	EndIf
	$ActiveListView.Columns.Item(1).Width = -1
	If $ActiveListView.Columns.Item(1).Width < 100
		$ActiveListView.Columns.Item(1).Width = 100
	EndIf
	;Disable the 'Save Button' so the user can not save the selected changes.
	$SaveButton.Enabled = "False"
	;Enable the 'Backup Button' so the user can backup the selected 'Run' key.
	$BackupButton.Enabled = "True"
	;Enable the 'Restore Button' so the user can restore the selected 'Run' key.
	$RestoreButton.Enabled = "True"
EndFunction

;The 'GetKeyEntries()' function enumerates the entries of a key passed to it,
;and passes those entries and their values back in an array.
Function GetKeyEntries($SubKey)
	Dim $Index,$Array[0],$Entry,$Value,$Error
	
	$Index = 0
	$Entry = EnumValue($Subkey,$Index)
	If @ERROR = 0
		$Value = ReadValue($Subkey,$Entry)
		$Array[$Index] = $Entry+"|"+$Value
		While @ERROR = 0
			$Index = $Index + 1
			$Entry = EnumValue($Subkey,$Index)
			$Value = ReadValue($Subkey,$Entry)
			ReDim Preserve $Array[$Index]
			$Array[$Index] = $Entry+"|"+$Value
		Loop
		ReDim Preserve $Array[$Index-1]
		$GetKeyEntries = $Array
	Else
		$GetKeyEntries = ''
	EndIf
EndFunction

;The 'ControlClick(Control.Name)' function defines the '.Click' event for each button in the 'Control Stack'.
Function ControlClick($ControlName)
	Select
		Case $ControlName = "Save"
			SaveReg()
		Case $ControlName = "Backup"
			BackupReg()
		Case $ControlName = "Restore"
			RestoreReg()
		Case $ControlName = "Refresh"
			MainForm_Refresh()
		Case $ControlName = "Delete"
			DeleteReg()
		Case $ControlName = "Exit"
			ExitForm()
	EndSelect
EndFunction

;The 'SaveReg()' function removes the entries (listed in the 'DeleteListView.Items') from the selected 'Run' key,
;then clears the 'ActiveListView.Items', clears the 'DeleteListView.Items' and refreshes the
;'ActiveListView.Items' in the selected 'Run' key.
Function SaveReg()
	Dim $ActiveComboBox,$ActiveListView,$DeleteListView,$Item,$nul
	
	;Find the 'ActiveComboBox' control.
	$ActiveComboBox = $MainForm.FindControl("ActiveComboBox")
	;Find the 'ActiveListView' control.
	$ActiveListView = $MainForm.FindControl("ActiveListView")
	;Find the 'DeleteListView' control.
	$DeleteListView = $MainForm.FindControl("DeleteListView")
	;Loop thru each item in 'DeleteListView.Items'
	For Each $Item in $DeleteListView.Items
		;Delete the selected 'Run' key entry (listed in the 'DeleteListView.Items').
		$nul = DelValue($ActiveComboBox.Text,$Item.Text)
	Next
	;Clear the 'ActiveListView.Items', clear the 'DeleteListView.Items'
	;and populate the 'ActiveListView.Items' with the entries of the selected 'Run' key.
	MainForm_Refresh()
EndFunction

;The 'BackupReg()' function copies the registry entries form the selected 'Run' key to 'RunBackup' key.
Function BackupReg()
	Dim $ActiveComboBox,$SelectedReg,$Entries,$Array,$Entry,$Value,$nul
	
	;Find the 'ActiveComboBox' control.
	$ActiveComboBox = $MainForm.FindControl("ActiveComboBox")
	;Pull the 'Run' key off of the 'ActiveComboBox.Text' property value.
	;HKey_Local_Machine\Software\Microsoft\Windows\CurrentVersion\Run
	;becomes:
	;HKey_Local_Machine\Software\Microsoft\Windows\CurrentVersion
	$SelectedReg = SubStr($ActiveComboBox.Text,1,Len($ActiveComboBox.Text)-4)
	;Enumerate the registry entries selected in the 'ActiveComboBox.Text' property.
	$Entries = GetKeyEntries($ActiveComboBox.Text)
	;Loop thru each entry in the 'Entries' array and add them to the 'RunBackup' registry key.
	For Each $Array in $Entries
		$Entry = Split($Array,"|")[0]
		$Value = Split($Array,"|")[1]
		$nul = WriteValue($SelectedReg+"\RunBackup",$Entry,$Value,"REG_SZ")
	Next
	;Clear the 'ActiveListView.Items', clear the 'DeleteListView.Items'
	;and populate the 'ActiveListView.Items' with the entries of the selected 'Run' key.
	MainForm_Refresh()
	;Set index 0 to '(value not set)'
	$nul = DelValue($SelectedReg+"\RunBackup","")
EndFunction

;The 'RestoreReg()' function copies the registry entries form the selected 'RunBackup' key to 'Run' key.
Function RestoreReg()
	Dim $ActiveComboBox,$SelectedReg,$Entries,$Array,$Entry,$Value,$nul
	
	;Find the 'ActiveComboBox' control.
	$ActiveComboBox = $MainForm.FindControl("ActiveComboBox")
	;Pull the 'Run' key off of the 'ActiveComboBox.Text' property value.
	;HKey_Local_Machine\Software\Microsoft\Windows\CurrentVersion\Run
	;becomes:
	;HKey_Local_Machine\Software\Microsoft\Windows\CurrentVersion
	$SelectedReg = SubStr($ActiveComboBox.Text,1,Len($ActiveComboBox.Text)-4)
	;Enumerate the registry entries selected in the 'SelectedReg\RunBackup' varible.
	$Entries = GetKeyEntries($SelectedReg+"\RunBackup")
	;Loop thru each entry in the 'Entries' array and add them to the 'Run' registry key.
	For Each $Array in $Entries
		$Entry = Split($Array,"|")[0]
		$Value = Split($Array,"|")[1]
		$nul = WriteValue($SelectedReg+"\Run",$Entry,$Value,"REG_SZ")
	Next
	;Clear the 'ActiveListView.Items', clear the 'DeleteListView.Items'
	;and populate the 'ActiveListView.Items' with the entries of the selected 'Run' key.
	MainForm_Refresh()
	;Set index 0 to '(value not set)'
	$nul = DelValue($SelectedReg+"\Run","")
EndFunction

;The 'DeleteReg()' function moves the checked entries from the 'ActiveListView' to the 'DeleteListView'.
Function DeleteReg()
	Dim $ActiveListView,$DeleteListView,$SaveButton,$BackupButton,$RestoreButton,$Item,$Item0,$Item1
	
	;Find the 'ActiveListView' control.
	$ActiveListView = $MainForm.FindControl("ActiveListView")
	;Find the 'DeleteListView' control.
	$DeleteListView = $MainForm.FindControl("DeleteListView")
	;Find the 'Save Button' user control.
	$SaveButton = $MainForm.FindControl("Save")
	;Find the 'Backup Button' user control.
	$BackupButton = $MainForm.FindControl("Backup")
	;Find the 'Restore Button' user control.
	$RestoreButton = $MainForm.FindControl("Restore")
	;Find all 'ActiveListView.Items' that are checked, add them to the 'DeleteListView.Items',
	;then remove the checked 'ActiveListView.Items'
	For Each $Item in $ActiveListView.Items
		If $Item.Checked = -1
			$Item0 = $DeleteListView.Items.Add($System.ListViewItem($Item.Text))
			$Item1 = $Item0.SubItems.Add($System.ListViewSubItem($Item.SubItems.Item(1).Text))
			$Item.Remove
		EndIf
	Next
	;Resize both 'ListView.Columns' and enable or disable user controls if 'Items' have been
	;added to 'DeleteListView.Items'.
	If $DeleteListView.Items.Count > 0
		;Resize the 'ActiveListView' columns to the width of the largest 'ActiveListView.Items'
		$ActiveListView.Columns.Item(0).Width = -1
		If $ActiveListView.Columns.Item(0).Width < 100
			$ActiveListView.Columns.Item(0).Width = 100
		EndIf
		$ActiveListView.Columns.Item(1).Width = -1
		If $ActiveListView.Columns.Item(1).Width < 100
			$ActiveListView.Columns.Item(1).Width = 100
		EndIf
		;Resize the 'DeleteListView' columns to the width of the largest 'DeleteListView.Items'
		$DeleteListView.Columns.Item(0).Width = -1
		If $DeleteListView.Columns.Item(0).Width < 100
			$DeleteListView.Columns.Item(0).Width = 100
		EndIf
		$DeleteListView.Columns.Item(1).Width = -1
		If $DeleteListView.Columns.Item(1).Width < 100
			$DeleteListView.Columns.Item(1).Width = 100
		EndIf
		;Enable the 'Save Button' so the user can save the selected changes.
		$SaveButton.Enabled = "True"
		;Enable the 'Backup Button' so the user can not backup the selected 'Run' key.
		$BackupButton.Enabled = "False"
		;Enable the 'Restore Button' so the user can not restore the selected 'Run' key.
		$RestoreButton.Enabled = "False"
	EndIf
EndFunction

;The 'ExitForm()' function exits the form.
Function ExitForm()
	Quit 0
EndFunction

;endregion Main Form Functions

;region Images
;The 'FormIcon()' function creates the icon for 'MainForm.Icon'.
Function FormIcon()
$FormIcon = "
Qk02BAAAAAAAADYAAAAoAAAAEAAAABAAAAABACAAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAA
AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAA
AP8AAAD/AAAA/wAAAP/////////////////////////////////////////////////AwMD/
wMDA/8DAwP///////////wAAAP8AAAD/////////////////////////////////wMDA/8DA
wP8AAAD/AAAA/wAAAP/AwMD///////////8AAAD/AAAA////////////////////////////
AAAA/wAAAP8AAAD/AAAA/wAA//8AAAD/wMDA////////////AAAA/wAAAP//////////////
/////////////wAAAP/AwMD//////wAAAP8AAAD/AAAA/////////////////wAAAP8AAAD/
//////////////////////////8AAAD/wMDA////////////wMDA/8DAwP/AwMD/////////
//8AAAD/AAAA////////////////////////////AAAA/8DAwP/AwMD/AAAA/wAAAP8AAAD/
wMDA////////////AAAA/wAAAP///////////////////////////wAAAP8AAAD/AAAA/wAA
AP8A/wD/AAAA/8DAwP///////////wAAAP8AAAD///////////////////////////8AAAD/
wMDA/8DAwP8AAAD/AAAA/wAAAP////////////////8AAAD//////8DAwP/AwMD/wMDA/8DA
wP8AAAD/AAAA/wAAAP/AwMD/////////////////////////////////AAAA//////8AAAD/
AAAA/wAAAP8AAAD/AAAA/wD///8AAAD/wMDA/////////////////////////////////wAA
AP//////AAAA/8DAwP///////////wAAAP8AAAD/AAAA////////////////////////////
//////////8AAAD//////wAAAP/AwMD/////////////////////////////////////////
////////////////////////AAAA/wAAAP8AAAD/AAAA/8DAwP8AAP//AAD//wAA//8AAP//
AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAAAP8AAAD///8A/wAAAP/AwMD/AAD//wAA
//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAAD/AAAA/wAAAP8AAAD/
wMDA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/w==
"
$FormIcon = $System.Bitmap.FromBase64String($FormIcon)
EndFunction

;The 'ControlImages()' function creates the images for the 'ImageList'.
Function ControlImages()
$ControlImages = "
iVBORw0KGgoAAAANSUhEUgAAAGAAAAAQCAYAAADpunr5AAAAAXNSR0IArs4c6QAAAARnQU1B
AACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAA
AAlwSFlzAAAOwgAADsIBFShKgAAABrxJREFUWEftWFlMFVcYnhdfjGl86lObtEnjg3bBmnQx
GknsEmto1MZWa1uxVWPVGFvAWo2Cqdq6VGsTFKoV6gKiVjCX7bIvF/CCisLVy+KFsl028SJL
RVC+/v/MPcPcYYbFJe1DJ/lyhzPnnG/O9/3n/88gSf9f/w0Ffkltw49xt0bF7phKPI03/rf5
n8aaxjXnAUsjBgcHYXTdfwB03VcQ9mcjfogq8zHh4esSBmdI4N9xkWo6Pw6/D+eMSDzzbgwm
zIqGRPeG78PtZs/0A0Rf7a+uT8huK/z9Y9Dd3T0qr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xd8z2gijGSC4O/w1hwzA6wUCMP4WeC11yB9W+FrALfTkc8H
ZgYEUa3gov1ZnhLdAjN1x1mxk3RFeN68eOzcmYnw8Es4fNgu4widFBkRESUyIiMvIyjIisDA
wuHH0G37rKhraJJzvrtyKAU1RRxUd0JFVBTSXEByNbDiy18NBa17RYJAveb+L7pnmJkg+IXw
ovgG2ZS0x8JPP+cP6y0TfhaExWMIcfhXK6b+XttPb5T4m873PvOxgSSg/hS0mtoZK1fasGVL
IUJDS7B1axHWrUuhdgsJn40lS1JIeIuxAVt/SkJNXYO87WvptMNRf2+xn7x414kouIMC5chj
8S1VwPLAg8PErHlZghZasc3aRR89vzBgSqwfVmWFYdLxyXIdMOVnMVkskefH+qE1Wm4Uz3k+
inK1AGvGcQoSBvAHlt3uUpGaaoPVmg+n04UZNAfD8ENs844LcFbVoLoDqKDTzjXvaUfkfBH5
8U7g/E36IPt8v2rAjWkSnBpU0r3RuqrJoCqC0XMtv7Md4MjXnn4WJG+UxTfiV7nELmAT3jP4
sBqr2Pp+PK84for6MKIBDZg//yKCg2Pl05DL5UJ/f/8oBoSeh6PSJYtf3qoUPW3OF5HH4p8p
JwOW7VNFdpDgAmzGSOusoOcC2n6bvfw3SXzm54LLWJ4Rhk22KFn8hArFfD2/Dx8LxGlImPCo
omsjf/ZJww8wbRHW7gCL5QoWLUqlmpCiit/Z2TmyASFbYnHVUTli5J+7AZy8DkRfA5Z+utdH
6OtTJTDGst5y6lfmhbqIx+T34eWI1f6rYSwvZdZHnKDYBJO0pk9B4eEn5GJssymRz+LX1NSM
YsDm00jNakZKhkdB+h0kp3Ug2XobSantSEppQ2JyKxKTWmBJbB5mwHjXqDcs5EnzP8kaIEww
WaTegLi4OJ/Id7vdVAOchgb8AzONw4G+paf3AAAAAElFTkSuQmCC"
$ControlImages = $System.Bitmap.FromBase64String($ControlImages)
EndFunction
;endregion Images
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
Page 1 of 1 1


Moderator:  NTDOC, ShaneEP, Mart, Radimus, Glenn Barnas, Jochen, Allen 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 210 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.062 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org