PDA

View Full Version : gui: xpbutton good for ("UIAdv")



Lionheart008
01-12-2009, 23:47
"UI", "UIAdv": what is xpbutton good for? I show a little example for grinning. that was made for fun. only click on pic buttons. bundle exe I add as attachment. that's all :)

nice evening, frank

TomLebowski
02-12-2009, 10:55
hi frank, very nice example! laughing seconds was on my side. this gui doesn't look like usual ms style, good! that's easy way for producing photo album fishing ;)
sorry, but where can I find this xp button ? second: what about menu or dialog modus to change color ? found nothing in help manual. bye, tom

Lionheart008
02-12-2009, 16:40
hello tom.

here a little example for you how to use xpbutton :)
you can find this kind of example here:
thinair / file / open / SampleScripts/ ui / xpbutton.


uses "UI"
uses "UIAdv"

%IDC_BUTTON1 = 101
%IDC_BUTTON2 = 102
%IDC_BUTTON3 = 103

' ========================================================================================
' Main
' ========================================================================================
FUNCTION TBMAIN() as long

LOCAL hDlg AS LONG

Dialog NEW 0, "for_Tom_XP Button Demo", -1, -1, 145, 235, %DS_CENTER Or %WS_OVERLAPPED Or %WS_THICKFRAME Or %WS_SYSMENU To hDlg
Dialog SET COLOR hDlg, RGB(180,180,180),RGB(10,10,140)
Control ADD XPBUTTON, hDlg, %IDC_BUTTON1, "", 10, 5, 105, 80, %WS_TABSTOP Or %WS_VISIBLE Or %WS_CHILD
Control ADD XPBUTTON, hDlg, %IDC_BUTTON2, "", 10, 95, 105, 80, %WS_TABSTOP Or %WS_VISIBLE Or %WS_CHILD
Control ADD BUTTON, hDlg, %IDC_BUTTON3, "hello", 72, 185, 50, 20, %WS_TABSTOP Or %WS_VISIBLE Or %WS_CHILD

XPButton_SetImagePos hDlg, %IDC_BUTTON1, %XPBUTTON_CENTERCENTER
XPButton_SetIcon hDlg, %IDC_BUTTON1, APP_SourcePath & "herr-der-ringe1.ico", %XPBUTTON_NORMAL
XPButton_SetImageSize hDlg, %IDC_BUTTON1, 152, 152, %TRUE

XPButton_SetImagePos hDlg, %IDC_BUTTON2, %XPBUTTON_CENTERCENTER
XPButton_SetIcon hDlg, %IDC_BUTTON2, APP_SourcePath & "torhüter.ico", %XPBUTTON_NORMAL
XPButton_SetImageSize hDlg, %IDC_BUTTON2, 152, 152, %TRUE

Dialog SHOW MODAL hDlg, Call DlgProc

END FUNCTION

' ========================================================================================
' Main Dialog procedure
' ========================================================================================
CALLBACK FUNCTION DlgProc() AS LONG

SELECT CASE CBMSG

CASE %WM_COMMAND
SELECT CASE CBCTL
CASE %IDCANCEL
IF CBCTLMSG = %BN_CLICKED THEN DIALOG END CBHNDL
CASE %IDC_BUTTON1
IF CBCTLMSG = %BN_CLICKED THEN
MsgBox 0, "Lord of the ring Button clicked"
End If
Case %IDC_BUTTON2
If CBCTLMSG = %BN_CLICKED Then
MsgBox 0, "Goalkeeper Button clicked"
End If
Case %IDC_BUTTON3
If CBCTLMSG = %BN_CLICKED Then
MsgBox 0, "Hello Tom Button clicked"
End If
END SELECT

END SELECT

END FUNCTION
' ========================================================================================


change color for dialog ("dialog set color"..) is possible, but not for menu. see my example. if you have any more question, don't hesitate to ask.

go with mouse over one of the word control add xpbutton or click into words and push "F1" for help file. new popup dialog opens. so you will get a special choice of commands they are available for current thinair issue. you will find also in help file "control set color" command.


CONTROL SET COLOR hWnd, CtrlID, Foreground, Background

have fun with thinair and your ui examples, hope to see one day one great opening ;)

nice day,best regards, frank lionheart

TomLebowski
03-12-2009, 13:57
hello frank. many, many thanks !
don't know why but I have taken primarly the help file and found control menus and buttons, but not for dialog set color or I was too tired to see right commmand. thanks. xpbutton example I have tested. do you know "cleanProg" application? nice little gui with easy to use buttons and icons. perhaps I will have more time to save this knowledge for bigger ui example I have in my mind. bye, go back to work now, tom

Lionheart008
07-12-2009, 17:53
tom, you are welcome :)

here I show little example how to get "gradient background" for gui and beautify your dialogs! take this one: "dialog set gradient"


' Empty GUI script created on 12-07-2009 12:04:25 by (ThinAIR)
Uses "ui"

%ButtonClose = 1001
%ButtonClone = 1002
%ButtonClone2 = 1003

Randomize Timer

Function TBMain()

'------------------------------------------------------------------------------
' Create dialog
'------------------------------------------------------------------------------

Dim hwnd As Long
Dim hDlg As Long

Dialog NEW hdlg, "myGradientWin1",-1,-1, 330, 203, _
%WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPCHILDREN Or _
%WS_CAPTION Or _
%WS_SYSMENU Or _
%WS_MINIMIZEBOX, _
0 To hDlg

Dialog SET GRADIENT hdlg, %GRADIENT_FILL_H, RGB(Rnd(10,255+Sin(GetTickCount*118)/500),100,10), RGB(0,Rnd(10,100),250+Sin(GetTickCount*118)/500)
Control ADD BUTTON, hDlg, %ButtonClose, "Click to kill", 90, 50, 60, 30
Control ADD BUTTON, hDlg, %ButtonClone, "clone me", 90, 120, 60, 30

Dialog SHOW MODAL hDlg Call cbDialog
End Function

'------------------------------------------------
' Callback function used to handle dialog events
'------------------------------------------------
CallBack Function cbDialog() As Long
Dim hdlg As Long

Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %ButtonClose Then Dialog End CBHNDL

If CBWPARAM = %ButtonClone Then
Dialog NEW hdlg, "myGradientWin2",-1,-1, 380, 260, _
%WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPCHILDREN Or _
%WS_CAPTION Or _
%WS_SYSMENU Or _
%WS_MINIMIZEBOX, _
0 To hDlg

Dialog SET GRADIENT hdlg, %GRADIENT_FILL_H, RGB(Rnd(10,255+Sin(GetTickCount*118)/500),Rnd(10,200),100), RGB(0,Rnd(10,100),250)
Control ADD BUTTON, hDlg, %ButtonClose, "Click to close", 20, 60, 60, 30
Control ADD BUTTON, hDlg, %ButtonClone2, "clone me", 280, 220, 60, 30
Dialog SHOW MODAL hDlg Call cbDialog2
End If

Case %WM_DESTROY
'MsgBox 0, "Window is to be destroyed."

End Select

End Function


CallBack Function cbDialog2() As Long
Dim hdlg As Long

Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %ButtonClose Then Dialog End CBHNDL

If CBWPARAM = %ButtonClone2 Then
Dialog NEW hdlg, "myGradientWin3",-1,-1, 280, 180, _
%WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPCHILDREN Or _
%WS_CAPTION Or _
%WS_SYSMENU Or _
%WS_MINIMIZEBOX, _
0 To hDlg

Dialog SET GRADIENT hdlg, %GRADIENT_FILL_V, RGB(Rnd(10,255+Sin(GetTickCount*118)/500),Rnd(10,200),100), RGB(0,Rnd(10,100),250)
Control ADD BUTTON, hDlg, %ButtonClose, "CloseMe", 30, 50, 50, 30
Control ADD BUTTON, hDlg, %ButtonClone2, "copy me", 120, 50, 60, 30
Dialog SHOW MODAL hDlg Call cbDialog2
End If

Case %WM_DESTROY
'MsgBox 0, "Window is to be destroyed."

End Select

End Function


I send this example because I found this line for the first time and sometimes tb manual holds some fine secrets ;)

"clear prog" application I know. "cleanprog" it's unknown for me.

best regards, frank

TomLebowski
08-12-2009, 15:19
hello frank. thank you again! gui and background with gradient look very nice. thanks for example. unusual to get very fast and detail infos from user's here ;) it's too much to study at the board and exploring sample scripts, I am impressed!

what about mixing tbgl / gui / canvas ? I notice there are several ways to create scenes and objects. for moving objects it's better to work with tbgl/ui example I suggest. I will find a good c++ example and translate for thinbasic. takes some days, but I am sure, I can do. bye, tom

marcuslee
08-12-2009, 18:35
here I show little example how to get "gradient background" for gui and beautify your dialogs! take this one: "dialog set gradient"



Dialog SET GRADIENT hdlg, %GRADIENT_FILL_H, RGB(Rnd(10,255+Sin(GetTickCount*118)/500),100,10), RGB(0,Rnd(10,100),250+Sin(GetTickCount*118)/500)



That is just pure awesomeness! Now, no more boring gray backgrounds. Isn't thinBasic really kewl? :occasion:


Mark