Page 1 of 1 1
Topic Options
#90445 - 2002-12-09 07:37 PM 'My' Color Common Dialog Chooser
Chris S. Offline
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
#90446 - 2002-12-09 09:18 PM Re: 'My' Color Common Dialog Chooser
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Chris,

Was this supposed to create another form and color it? I see the color numbers change in my DOS box when I click the colors, but nothing else happens.

KiXtart v4.12
KiXForms build 36

Top
#90447 - 2002-12-09 09:23 PM Re: 'My' Color Common Dialog Chooser
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
The numbers that are popping up in the console window is the decimal value of color you picked. You would then use that value to 'color' whatever you wanted, be it a font color, form color, etc.

No, the script doesn't do much. It is pretty much just a demo.

The reason I posted it was because of the unique way in which the picture boxes are created by the use of the Execute command.

Top
#90448 - 2002-12-09 09:25 PM Re: 'My' Color Common Dialog Chooser
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Oh, also, it should be changing the color of the label in the frame below the color pallete.
Top
#90449 - 2002-12-09 09:32 PM Re: 'My' Color Common Dialog Chooser
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Yes, color does change, but only once. Once you select a color it shows, but any other color selected after that does not show.

Extremely slow loading dialog box and color selection as well.

Top
#90450 - 2002-12-09 09:40 PM Re: 'My' Color Common Dialog Chooser
Chris S. Offline
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. Offline
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. [Big Grin]

Top
#90452 - 2002-12-09 09:45 PM Re: 'My' Color Common Dialog Chooser
Shawn Administrator Offline
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
#90453 - 2002-12-09 09:47 PM Re: 'My' Color Common Dialog Chooser
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Much better. Thanks, Shawn.
Top
#90454 - 2002-12-10 08:48 AM Re: 'My' Color Common Dialog Chooser
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
LABEL !

Excellent !!!

Will use these for mine too ...

By the way,sidenote for kixforms and RGB colors I heard from Shawn :

KiXforms reverses RGB colors to GGRRBB (just like VB, right ?) ... So if you want to take these color values outside kixforms (just as I do in PostPrep) you have to convert it first to HEX and then a bit string manipulation like

code:
$KColor = "FF0000" ;blue
$HTMLColor = right($KColor,2) + substr($KColor,3,2) + left($KColor,2)

results in '0000FF' (Blue)

[Big Grin]
_________________________



Top
#90455 - 2002-12-10 09:22 AM Re: 'My' Color Common Dialog Chooser
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh?
and I was wondering why my scripts didn't work as expected.

shawn, I give you [Razz] for not telling.
_________________________
!

download KiXnet

Top
#90456 - 2002-12-10 03:17 PM Re: 'My' Color Common Dialog Chooser
Shawn Administrator Offline
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

[Wink]

-Shawn

[ 10. December 2002, 15:18: Message edited by: Shawn ]

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 476 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

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

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