#90445 - 2002-12-09 07:37 PM
'My' Color Common Dialog Chooser
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
I was working on this when jpols was playing around with a color chooser. Probably not very useful, but it does demonstrate the ability to 'dynamically' create KiXform objects using the Execute command...
code:
Break On Cls
Dim $Color[48]
$frmColor = CreateObject("KiXtart.Form") $frmColor.Size = 220,270 $frmColor.Caption = "Color"
$fraColor = $frmColor.Frame("Color Selected",10,160,195,40) $lblColor = $fraColor.Label("",10,15,175,15) $btnColorOK = $frmColor.Button("OK",10,$fraColor.Bottom+10,50,20) $btnColorCncl = $frmColor.Button("Cancel",$btnColorOK.Right+10,$fraColor.Bottom+10,50,20)
For $x = 16777215 to 0 step -356962.02127659574468085106382979 $l = $l + 1 $Color[$l]=$x Next
For $lTop = 10 to 145 Step 25 For $lLeft = 10 to 185 Step 25 $lGrid = $lGrid + 1 $nul=Execute("$$picGrid"+$lGrid+" = $$frmColor.PictureBox('',$lLeft,$lTop,20,20)") $nul=Execute("$$picGrid"+$lGrid+".BackColor = $Color[$lGrid]") $nul=Execute("$$picGrid"+$lGrid+".OnClick = 'ColorChooser($lGrid)'") Next Next
$frmColor.Center $frmColor.Show
While $frmColor.Visible $NUL = Execute($frmColor.DoEvents) $Chooser ? Loop
Function ColorChooser($lGridN) $nul = Execute("$$Chooser = $$picGrid"+$lGridN+".BackColor") $nul = Execute("$$lblColor.BackColor = $$picGrid"+$lGridN+".BackColor") EndFunction
|
|
Top
|
|
|
|
#90450 - 2002-12-09 09:40 PM
Re: 'My' Color Common Dialog Chooser
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Hmm. The label on mine changes everytime I click on a new color.
As far as the slowness of the form, I assume that is because of the 'Execute' method. I is slow on my PC as well. For fun, you can try this...
code:
Break On Cls
Dim $Color[48]
$frmColor = CreateObject("KiXtart.Form") $frmColor.Size = 220,270 $frmColor.Caption = "Color"
$fraColor = $frmColor.Frame("Color Selected",10,160,195,40) $lblColor = $fraColor.Label("",10,15,175,15) $btnColorOK = $frmColor.Button("OK",10,$fraColor.Bottom+10,50,20) $btnColorCncl = $frmColor.Button("Cancel",$btnColorOK.Right+10,$fraColor.Bottom+10,50,20)
$frmColor.Center $frmColor.Show
For $x = 16777215 to 0 step -356962.02127659574468085106382979 $l = $l + 1 $Color[$l]=$x Next
For $lTop = 10 to 145 Step 25 For $lLeft = 10 to 185 Step 25 $lGrid = $lGrid + 1 $nul=Execute("$$picGrid"+$lGrid+" = $$frmColor.PictureBox('',$lLeft,$lTop,20,20)") $nul=Execute("$$picGrid"+$lGrid+".BackColor = $Color[$lGrid]") $nul=Execute("$$picGrid"+$lGrid+".OnClick = 'ColorChooser($lGrid)'") Next Next
;$frmColor.Center ;$frmColor.Show
While $frmColor.Visible $NUL = Execute($frmColor.DoEvents) $Chooser ? Loop
Function ColorChooser($lGridN) $nul = Execute("$$Chooser = $$picGrid"+$lGridN+".BackColor") $nul = Execute("$$lblColor.BackColor = $$picGrid"+$lGridN+".BackColor") EndFunction
|
|
Top
|
|
|
|
#90451 - 2002-12-09 09:44 PM
Re: 'My' Color Common Dialog Chooser
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
BTW, one application I can see with this Execute method is a way to 'dynamically' create forms and objects. It would then be used to create a 'Visual KiXforms Editor.'
Just an idea.
|
|
Top
|
|
|
|
#90452 - 2002-12-09 09:45 PM
Re: 'My' Color Common Dialog Chooser
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
One of the causes of the slowness maybe because the PictureBox is a resource hog (relatively speaking) ... with so many pic's - memory gets chewed-up pretty quick. Just as a test - might comment out the first line and add two more (use labels instead):
code:
$lGrid = $lGrid + 1 ;$nul=Execute("$$picGrid"+$lGrid+" = $$frmColor.PictureBox('',$lLeft,$lTop,20,20)") $nul=Execute("$$picGrid"+$lGrid+" = $$frmColor.Label('',$lLeft,$lTop,20,20)") $nul=Execute("$$picGrid"+$lGrid+".BorderStyle=2")
|
|
Top
|
|
|
|
#90456 - 2002-12-10 03:17 PM
Re: 'My' Color Common Dialog Chooser
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Can't totally blame me on this one - this was documented in the first version of the manual, and on the kixforms web page ... not too sure about the object reference though ... anyways, heres the link:
RGB Method
-Shawn [ 10. December 2002, 15:18: Message edited by: Shawn ]
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 476 anonymous users online.
|
|
|