Page 1 of 1 1
Topic Options
#171609 - 2006-12-16 08:41 PM KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 02
Benny69 Offline
Moderator
*****

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

Project 01 - Lesson 02 is a continuation of:
Project 01 - Lesson 01

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 02:
  • Populate the 'ComboBox' with these two values.
    • "HKey_Local_Machine\Software\Microsoft\Windows\CurrentVersion\Run"
    • "HKey_Current_User\Software\Microsoft\Windows\CurrentVersion\Run"
  • Populate the top 'ListView' with the entries and values of the selected 'ComboBox.Text' registry key.
  • When the user selects a different registry key in the 'ComboBox' the top and bottom 'ListView.Items' should be cleared.
  • The top 'ListView' should have checkboxes enabled.
  • Allow the user to:
    • Backup - copy the entries and values of the selected 'ComboBox.Text' registry key to these keys respectively:
      • "HKey_Local_Machine\Software\Microsoft\Windows\CurrentVersion\RunBackup"
      • "HKey_Current_User\Software\Microsoft\Windows\CurrentVersion\RunBackup"
    • Restore - copy the entries and values of the selected 'ComboBox.Text' backup registry key to these keys respectively:
      • "HKey_Local_Machine\Software\Microsoft\Windows\CurrentVersion\Run"
      • "HKey_Current_User\Software\Microsoft\Windows\CurrentVersion\Run"
    • Restore - clear the bottom 'ListView.Items' and re-enumerate the entries and values of the selected 'ComboBox.Text' registry key.
    • Refresh - clear the top 'ListView.Items', clear the bottom 'ListView.Items' and re-enumerate the entries and values of the selected 'ComboBox.Text' registry key.
    • Exit - exit the form.

Create:
  • A function to populate the 'ComboBox'.
  • A function to populate the top 'ListView' with the entries and values of the selected 'ComboBox.Text' registry key.
  • A function for the 'Backup Button.Click' event.
  • A function for the 'Restore Button.Click' event.
  • A function for the 'Refresh Button.Click' event.
  • A function for the 'Exit 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
#171647 - 2006-12-17 10:31 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 02 [Re: Benny69]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Help...

Can I get a basic primer on ListView and the addition of items.. I was able to get data into the first column with no problem, but have not had any luck understanding samples that I have seen on how to add data to the second column.

[edit]

Okay so I have figured out that
ListViewItemXX = ListView.Items.Add($System.Listviewitem("data to add")
is the equivilant (in my way of thinking) to the Key for all items that appear in that row.
EX: to add a subitem you have to do this..
ListViewItemXY = ListView.Items.Item(XX).Subitems.Add($System.ListViewSubItem("Data to add"))

But in my typical way of working I was assigning each ListViewItem in an array

ListViewItem[$Counter] = ....

Why you may ask.. Well if you have an unknown # of Key's it has be done dynamically, and I automatically go for array's to store that type of data.

Issue that I have now though is I have to add a subitem. But how to reference the Item {key} in the string to add a subitem

Cant do a
ListViewItemXY = ListView.Items.Item[$Counter].Subitems.Add($System.ListViewSubItem("Data to add"))
As the expected format is .Item(XX), Cant Reference it via .Item($Count)

So my real question becomes - How can I convert the ListItem[XX] to Item(XX)

[/edit]

[Edit 2]
Nevermind I see what I did wrong and it now works for me... that is what I get for having stayed up all night and having to work on a Sunday....
[/Edit 2]


Edited by Gargoyle (2006-12-17 11:31 PM)
_________________________
Today is the tomorrow you worried about yesterday.

Top
#171649 - 2006-12-17 11:44 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 02 [Re: Gargoyle]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Maybe this will help others out:
'ListView.Items' is a collection of all the Items in the ' ListView',
Each ' ListView.Item' contains a collection of SubItems.

To add an ' Item' in column 0 you would do this:
  • ' $Item0 = $ListView.Items.Add($System.ListViewItem("Item 1A"))'

To add a SubItem to $Item0 you could use one of these two methods:
  • ' $Item1 = $ListView.Items.Item(0).SubItems.Add($System.ListViewSubItem("Item 1B"))'
  • ' $Item1 = $Item0.SubItems.Add($System.ListViewSubItem("Item 1B"))'


The (first column) Item Text is referenced like this:
'$Item0Text = $ListView1.Items.Item(Row).Text'
'Item(Row)' Row is the row index of the Item you are trying access, this is a zero based index like an array. So if you have 3 rows the index values will be 0,1,2. Zero being the top most Item in the column.

Any column after the first (Second Column, Third Column, Fourth Column,...), is in the SubItems collection of the Item in the first column.
The second column Item Text is referenced like this:
'$Item1Text = $ListView1.Items.Item(Row).SubItems.Item(Column).Text'
'Item(Column)' Column is the column index of the Item you are trying access, this is also a zero based index like an array. So if you have 3 columns the index values will be 0,1,2. Zero being the left most Item (or column 0).

If you wanted to access each 'Item.Text' in a 'ListView', this would be one way to do it:
Code:
For $Row = 0 to $ListView.Items.Count
	For $Column = 0 to $ListView.Items.Item($Row).SubItems.Count-1
		$ItemText = $ListView.Items.Item($Row).SubItems.Item($Column).Text
		? $ItemText
	Next
Next

_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#171678 - 2006-12-18 06:14 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 02 [Re: Benny69]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
In the objectives you have us filling in the Top Listview, but do not mention what you want created for the bottom Listview. My assumption is that you want any Item that is "checked" to be placed in the bottom listview. Is this correct?
_________________________
Today is the tomorrow you worried about yesterday.

Top
#171679 - 2006-12-18 06:16 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 02 [Re: Gargoyle]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
The bottom ListView will be covered in Lesson 03
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#171680 - 2006-12-18 06:18 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 02 [Re: Benny69]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
This Project will have Lessons 01 - 03
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#171762 - 2006-12-20 12:23 AM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 02 [Re: Benny69]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
How is everyone progressing?
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#171763 - 2006-12-20 12:27 AM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 02 [Re: Benny69]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Final testing going on now.

[edit]
Ok now it is ready for comment
[/edit]


Edited by Gargoyle (2006-12-20 12:51 AM)
_________________________
Today is the tomorrow you worried about yesterday.

Top
#171970 - 2006-12-23 09:11 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 02 [Re: Gargoyle]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
No one else doing this challenge... I sure hope it is not only me, and it is the excuse of the holiday's
_________________________
Today is the tomorrow you worried about yesterday.

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

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Ok now that the holidays are over with, shall we continue?

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
#172434 - 2007-01-05 03:19 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson 02 [Re: Benny69]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Well here is my code. Please be gentle
===============================================

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")

;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[]

;Array build information
$Button_Text = "Exit","Delete","Refresh","Restore","Backup","Save"
$Button_Top = 120,96,72,48,24,0
$Button_Click = "IWantOut()","","ListViewChange($CMB_RegEntry.SelectedIndex)","Restore($CMB_RegEntry.SelectedIndex)","Backup($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
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
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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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB
AQEBAQEBAQEGBgYBAQAAAQEBAQEBBgYAAAAGAQEAAAEBAQEBAAAAAAMABgEBAAAB
AQEBAQAGAQAAAAEBAQAAAQEBAQEABgEBBgYGAQEAAAEBAQEBAAYGAAAABgEBAAAB
AQEBAQAAAAACAAYBAQAAAQEBAQEABgYAAAABAQEAAQYGBgYAAAAGAQEBAQEBAAEA
AAAAAAUABgEBAQEBAQABAAYBAQAAAAEBAQEBAQEAAQAGAQEBAQEBAQEBAQEBAAAA
AAYDAwMDAwMDAwMDAwAABAAGAwMDAwMDAwMDAwMAAAAABgAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAA=
"

EndFunction


Edited by Gargoyle (2007-01-05 08:47 PM)
_________________________
Today is the tomorrow you worried about yesterday.

Top
#172443 - 2007-01-05 07:11 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson [Re: Gargoyle]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Garg

Not sure what method you're using to post but can you please post so that it maintains formatting.

If using one of the many PostPrep versions then only post HTML and don't use the CODE TAGS. If using the UBB of PostPrep depending on your version it does not seem to work well for me.

Thanks.

Top
#172448 - 2007-01-05 08:46 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson [Re: NTDOC]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
I am using the HTML from KiXtarter. Let me try it without the code tags and see if that helps you
_________________________
Today is the tomorrow you worried about yesterday.

Top
#172518 - 2007-01-08 03:16 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson [Re: Gargoyle]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Gargoyle,
Well done, just a couple small oops, the registry backup is being placed in:
"HKey_Local_Machine\Software\Microsoft\Windows\CurrentVersion\Run\RunBackup"
Rather than in:
"HKey_Local_Machine\Software\Microsoft\Windows\CurrentVersion\RunBackup"
And the other is the same, in addition nether one is backing up all the entries, each is missing one.
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

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

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Okay, I know what I did with the backup location, and will fix it next week when I am no longer on vacation.

I think I know why it is missing one on each of the backups, but will have to debug the code to be sure.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#172574 - 2007-01-09 03:13 PM Re: KiXforms.Net Learning Series - Windows Registry Run Project 01 - Lesson [Re: Gargoyle]
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
Here is my solution.

Code:
;Things to note:
;Most variables are declared with 'Dim' and not 'Global'. Control.Name property is given a unique value
;in order to find the control inside UDFs with the $Form.FindControl('Control.Name') function.
;The 'Button.Click' event is directed thru the 'ControlClick('Control.Name')' UDF, then it points each
;button to the appropriate 'Button.Click' event.

;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,
$DeletePanel,$DeleteListView,$DeleteListViewColumn0,$DeleteListViewColumn1,$DeleteLabel,
$Splitter,
$ActivePanel,$ActiveListView,$ActiveListViewColumn0,$ActiveListViewColumn1,$ActiveComboBox,
$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 02]"
$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.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.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
;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'
;and populates the 'ActiveListView.Items' with the entries of the selected 'Run' key.
Function MainForm_Refresh()
	Dim $ActiveComboBox,$ActiveListView,$DeleteListView,$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")
	;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
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
	
	$Index = 0
	$Entry = EnumValue($Subkey,$Index)
	$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
EndFunction

;The 'ControlClick(Control.Name)' function defines the '.Click' event for each button in the 'Control Stack'.
Function ControlClick($ControlName)
	Select
		Case $ControlName = "Save"
			
		Case $ControlName = "Backup"
			BackupReg()
		Case $ControlName = "Restore"
			RestoreReg()
		Case $ControlName = "Refresh"
			MainForm_Refresh()
		Case $ControlName = "Delete"
			
		Case $ControlName = "Exit"
			ExitForm()
	EndSelect
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 '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
n8aaxjXnAUsjBgc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ControlImages = $System.Bitmap.FromBase64String($ControlImages)
EndFunction
;endregion Images


I will now post Lesson 03.
Next Lesson:
Project 01 - Lesson 03

You may use my solution, someone else's or modify your own to include bits and pieces of different ones.

_________________________
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
0 registered and 346 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.063 seconds in which 0.021 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