PDA

View Full Version : color output as "rgb" value?



Lionheart008
10-09-2008, 12:25
hello dear thinbasic friends, theme: "UI", callback examples...

I have just a simple question how can I output the color as "rgb" (0,255,128) value? I like to get a message with the translated "rgb" value I have choosed from the color box ;-)

bye, lionheart, would like to build a new little color callback script :-)

PS: Respect for building the new issue of thinBasic !!! :-))) I am curious to check the new examples... - the help manual I can download where? Do somebody has a link for me?

ErosOlmi
10-09-2008, 12:44
You need thinBasic preview version you can find here: http://community.thinbasic.com/index.php?topic=2027.msg14971#msg14971
_________________________________________________
Here it is a callback example.
I will not anymore use UI scripts using WHILE/WEND message pump loop.
It is quite automatically for me working with callbacks now.

Below the code and attached the file.

Ciao
Eros



USES "UI"

DIM hDlg AS DWORD

' -- ID numbers of controls
Begin Const
%btnColor = 1000
%btnClose
%lbl_r
%lbl_b
%lbl_g
End Const

DIALOG New 0, "Test colors",-1,-1, 160, 120, _
%WS_POPUP Or %WS_VISIBLE Or _
%WS_CLIPCHILDREN Or %WS_CAPTION OR _
%WS_SYSMENU Or %WS_MINIMIZEBOX, 0 To hDlg

DIALOG SHOW modal hDlg call cbMain

'-------------------------------------
callback function cbMain() as long
'-------------------------------------
dim lColor as long

Select Case cbMsg

Case %WM_INITDIALOG
' -- Place controls here
CONTROL ADD BUTTON, cbhndl, %btnColor, "open color box" , 35, 100, 60, 14
CONTROL ADD BUTTON, cbhndl, %btnClose, "Close" , 95, 100, 60, 14

CONTROL ADD textbox, cbhndl, %lbl_r , "" , 50, 10, 60, 14
CONTROL ADD textbox, cbhndl, %lbl_g , "" , 50, 30, 60, 14
CONTROL ADD textbox, cbhndl, %lbl_b , "" , 50, 50, 60, 14

Case %WM_Command

select case cbCtl

case %btnColor
lColor = Dialog_ChooseColor(cbhndl, rgb(255, 0, 0), %CC_RGBINIT OR %CC_FULLOPEN )

if lColor = -1 then
'msgbox 0, "Color Dialog cancel by user"
control set text cbhndl, %lbl_r, ""
control set text cbhndl, %lbl_g, ""
control set text cbhndl, %lbl_b, ""
else
dialog set color cbhndl, 0, lColor
dialog redraw cbhndl
'---lColor is a 32 bit LONG variable. How to get the 4 bytes lColor is composed?
'---Just over impose an array of 4 bytes at the same memory location of lColor
'---using DIM ... AT thinBasic power. DIM ... AT create a logical variable
'---that will use the same memory location of another variable
dim RGB_Bytes(4) as byte at varptr(lColor)
control set text cbhndl, %lbl_r, RGB_Bytes(1)
control set text cbhndl, %lbl_g, RGB_Bytes(2)
control set text cbhndl, %lbl_b, RGB_Bytes(3)
end if

case %btnClose
dialog end cbhndl

end select

End Select

end function

Lionheart008
10-09-2008, 13:10
hi dear eros:-)

very good idea to make the background of the callback script gui in the way of picking a color from the box! I like it and must laugh... it seems easy, but I haven't manage it, if I have a look at the script... thank you:-)))

thank you for the link, I wanted to download the "help online" file but I cannot do that... don't ask me, my pc strikes again...

see you, little question beside my input questions...

qt: "thinbasic is well known (?)" worldwide and dedicated for a special group of "basic" users I can imagine... I have found the last days a lot of links belongs to the "basic" themes... - there are so much "basic" languages in the programming world, it's not so easy to get new users? I visited your website at the first time by chance (a link from a link from a link...), but I like this forum and the prompted replies from the user here.. :-)

why are so many "basic" languages ( nearly all are relatives to qbasic) on the programming market?

have a nice day and good ideas for the next thinBasic versions :-D

ErosOlmi
10-09-2008, 13:16
Yes, there are many Basic around and coming out from the very low level of this big list is not easy.
We are trying to get our position in the programming language but it is not easy too.

Anyhow we are doing our best in this direction considering we didn't do any advertise.
We prefer a different road: little steps day by day. We do not want to say thinBasic is good. We want our hard work and people using thinBasic say this for us. So it will be a long road but I think it will create concrete basis on which to build our product credibility.

Ciao
Eros

Lionheart008
17-09-2008, 21:49
Hi all, dear eros, all others... :)

... I try to bring two dialogs together, colorbox dialog and a callback dialog... I need it for my menu project...

a) How can I include the 'new window' button (should open two new popup windows) in the main part of the color dialog?

b) "open colorbox" does run, the "close?" button open the colorbox again, not my aim... and the button "new window" should open two new dialog callback windows... Michael has made this try some days before... You only can leave the script by pushing the "X" Icon ;) it's new stuff, therefore I need a good advice...

c) perhaps somebody can have a certain look at this script...

best wishes for good ideas, good evening, Lionheart

Petr Schreiber
18-09-2008, 14:10
Hi LionHeart,

as Yoda says - use the callbacks, Luke :)
I attach new code for you.


Petr

Lionheart008
18-09-2008, 17:56
Hi petr, one of Yodas best friends ;)

thank you for the script modifications... I saw my mistake, but didn't know how to open the new windows... I am learning day by day... I collect several scripts for my menu-project (inka 3d) to make it more professional... - the power is with you!

have a nice evening, yedi ritter ;D

! salve, Lionheart, the unknown brother of Luke!


ps: I will improve the script, then mail it as attachment...
pps: the central heating is "out", but I am ill, I am feeling it... ice, cold, everywhere!!!

Lionheart008
19-09-2008, 00:09
hi all, dear petr... :)

last input for this day (night)...

I have include new popup windows, one artbox window (this point I will improve with more functions...), I am not quite satisfied, but more will come...

A good example for learning thinbasics callback scripts ! ;)
good night, my headache became better, central heating was on!

ciao, Lionheart

ps: qt: "it's possible to change the windows gui "color" in skyblue or dark grey???" :)

Lionheart008
03-01-2009, 16:31
dear thinbasic users:) hello guys...

Theme Callback dialogs: I have played around a little bit with thinform 1.8 for the first time, have found a Calendar and Time function and include a new dialog with it by one code line, so it does run with thinbasic 1.7.5.0 ;) thinform is a damned great tool, isn't it??? ;)


CONTROL ADD "sysdatetimepick32" , cbhndl, %dat3, "30.12.2008", 4, 70, 80, 24, %ws_child or %ws_visible

- So I can see that's very simple and does a great job, perhaps this handling is also possible with other date/time and alternative callback dialog constructions??? It's quite new for me:)

bye, have a nice day, Lionheart