PDA

View Full Version : need third button for my test gui:-)



Lionheart008
04-09-2008, 13:28
dear thinBasic friends:-)

I have built my first gui after an example... - How can I build a third button with ("ignore")? - I add my code here... - I am impressed how easy it is to work with thinBasic and the thinAir editor...

but! - the producing *.exe files are always so big... it's necessary? ;-) I know this "boxed files" are include more, but what things does it include? I am curious...

ok, here is my code and the little problem: I need the "third button" with function...


uses "UI"

%ID_OPEN = 401
%ID_EXIT = 402
%ID_OPTION1 = 403
%ID_OPTION2 = 404
%ID_HELP = 405
%ID_ABOUT = 406

%ID_OK = 1
%ID_NOTOK = 2
%ID_CANCEL = 3
%ID_TEXT = 100


Main

FUNCTION Main() AS LONG
LOCAL hDlg AS long
LOCAL lResult AS LONG
LOCAL hMenu AS dword
LOCAL hPopup1 AS dword
LOCAL hPopup2 AS dword

local Msg AS LONG
local wParam AS LONG
local lParam AS LONG

local UserName as string
local CountEvents AS LONG

' ** First create a top-level menu:
MENU NEW BAR TO hMenu

' ** Add a top-level menu item with a popup menu:
MENU NEW POPUP TO hPopup1
MENU ADD POPUP, hMenu, "&File new", hPopup1, %MF_ENABLED
MENU ADD STRING, hPopup1, "&Open me", %ID_OPEN, %MF_CHECKED or %MF_GRAYED
MENU ADD STRING, hPopup1, "-", 0, 0
MENU ADD STRING, hPopup1, "&Exit program", %ID_EXIT, %MF_ENABLED

MENU NEW POPUP TO hPopup1
MENU ADD POPUP, hMenu, "&Render quad view", hPopup1, %MF_ENABLED
MENU ADD STRING, hPopup1, "&Open GL view", %ID_OPEN, %MF_CHECKED or %MF_GRAYED
MENU ADD STRING, hPopup1, "move me!", 0, 0

' ** Now we can add another item to the menu that will bring up a sub-menu. First we obtain a new popup menu handle to distinuish it from the first popup menu:
MENU NEW POPUP TO hPopup2

' ** Now add a new menu item to the first menu. This item will bring up the sub-menu when selected:
MENU ADD POPUP, hPopup1, "&More Options for 3d objects", hPopup2, %MF_ENABLED

' ** Now we will define the sub menu:

MENU ADD STRING, hPopup2, "Create Primitives &1", %ID_OPTION1, %MF_ENABLED
MENU ADD STRING, hPopup2, "Create Nurbs &2", %ID_OPTION2, %MF_ENABLED

' ** Finally, we'll add a second top-level menu and popup. For this popup, we can reuse the first popup variable:
MENU NEW POPUP TO hPopup2
MENU ADD POPUP, hMenu, "&Help", hPopup2, %MF_ENABLED
MENU ADD STRING, hPopup2, "&Help and Manual", %ID_HELP, %MF_ENABLED
MENU ADD STRING, hPopup2, "Forum and faq", 0, 0
MENU ADD STRING, hPopup2, "&About this little demo gui", %ID_ABOUT, %MF_ENABLED


' ** Create a new dialog template
DIALOG NEW 0, "What is your real name?", -1, -1, 260, 80, _
%WS_DLGFRAME OR %DS_CENTER OR %WS_CAPTION OR %WS_SYSMENU OR %WS_OVERLAPPEDWINDOW, _
0 TO hDlg

' ** Display the dialog
DIALOG SHOW modeless hDlg


WHILE IsWindow(hDlg)

'---Get the message and fill wParam and lParam
Msg = GetMessage(hDlg, wParam, lParam)

INCR CountEvents

'---Now test the message
SELECT CASE Msg


case %WM_INITDIALOG '---Message fired at the very beginning when dialog is initialized
'---Attach menu to dialog
MENU ATTACH hMenu, hDlg

'---Add relevant controls
CONTROL ADD TEXTBOX , hDlg, %ID_TEXT, "", 14, 12, 134, 12, 0
CONTROL ADD BUTTON , hDlg, %ID_OK, "it's all OK", 34, 32, 40, 14, %BS_DEFAULT
CONTROL ADD BUTTON , hDlg, %ID_CANCEL, "Cancel me", 84, 32, 40, 14, 0
CONTROL ADD BUTTON , hDlg, %ID_NOTOK, "it's not OK", 34, 32, 40, 14, %BS_DEFAULT
CONTROL ADD BUTTON , hDlg, %ID_CANCEL, "Cancel me too", 84, 32, 40, 14, 0

case %WM_Command

select case wParam
case %ID_EXIT, %ID_CANCEL
exit while

case %ID_OK
CONTROL GET TEXT hDlg, %ID_TEXT TO UserName
if UserName = "" then
msgbox 0, "Please, specify a name", %MB_ICONEXCLAMATION
else
msgbox 0, "Hello my dear " & UserName
exit while
end if

end select

CASE %WM_SYSCOMMAND

SELECT CASE wParam
CASE %SC_CLOSE
EXIT WHILE
END SELECT

case else

end select

wend

DIALOG END hDlg

END FUNCTION



Have all a nice day:-)

PS: I am looking for an "quad view render gui"... Does anybody can help me with an example for thinBasic?

Ciao and Servus, Lionheart :-D

Michael Hartlef
04-09-2008, 13:46
The exe contains the thinbasic engine, the modules you use and the scripts you use. And all the over files that you added to the bundle.

Petr Schreiber
04-09-2008, 14:35
Hi Lionheart008,

now I see what you mean by quad GUI, you are creating some kind of 3D editor, right?
To build OpenGL into dialog, future ThinBasic 1.7.0.0 brings some help on this.

To make quad GUI, you would split your TBGL control using viewports.
I will be happy to help you with it, but you will need to sign in for beta ( by sending private message to Eros Olmi ) or wait for ThinBasic 1.7.0.0 release.

One thing - you put %ID_NOTOK and second %ID_CANCEL over existing buttons, is that what you wanted?
Also make sure to have only one button with %BS_DEFAULT and it is better to not use multiple controls with same id ( like those 2 cancel buttons ).

It could look somehow like this in the end ( you need to add equate for %ID_CANCEL2 ):


CONTROL ADD BUTTON , hDlg, %ID_OK, "it's all OK", 34, 32, 40, 14, %BS_DEFAULT
CONTROL ADD BUTTON , hDlg, %ID_CANCEL, "Cancel me", 84, 32, 40, 14
CONTROL ADD BUTTON , hDlg, %ID_NOTOK, "it's not OK", 34, 52, 40, 14
CONTROL ADD BUTTON , hDlg, %ID_CANCEL2, "Cancel me too", 84, 52, 40, 14


Bye,
Petr

Lionheart008
04-09-2008, 15:49
dear michael, dear petr :-)

yes, I saw my problem... I have included the id_cancel2 and a new ID_IGNORE line...


%ID_OK = 1
%ID_CANCEL = 2
%ID_NOTOK = 3
%ID_CANCEL2 = 4
%ID_IGNORE = 5
%ID_TEXT = 100

and the little fake I will change too, if I have got the right answer... I think I must apply two new function with the below two button lines...


case %WM_Command

select case wParam
case %ID_EXIT, %ID_CANCEL, %ID_IGNORE
exit while

I have included simply ID_IGNORE and the button runs... but not with the case if you don't input your right name (so if you input "Andreas") you must got a "not ok"... :-)))

I will build it the next time... my dog is "wuffing", want to go outside for walking (haha, does not know the right word!)..

thank you all:-)

more will come later... :-D

have a nice day, ciao und servus, Lionheart

Petr Schreiber
04-09-2008, 15:58
Hi,

little motivation picture, code will be released once ThinBasic 1.7.0.0 will be out.
It is just skeleton for editor.


Petr

Lionheart008
04-09-2008, 16:11
dear petr:-)

good to see that, your welcome! :->>

My next aim in a few days is to build a little quad view with a render view (open right), a basic floor (grid) and you should can move it... I have found yesterday some examples, but no time to check it... I have found the open gl demo 12 example from the script examples of thinAir, great!

thank you for the preview! I like such things:-)))

servus, Lionheart

ps: thinbasic 1.7.0.0 will be out this month? ;-)

ErosOlmi
04-09-2008, 16:40
ps: thinbasic 1.7.0.0 will be out this month? ;-)

Yes, definitely.

Lionheart008
04-09-2008, 22:45
hi all:-)

question for the open gl window you have attached in the last post...

1) how can I rotate an open gl polygon? after that I will rotate it by mouse or move it with the arrow tabs of the keyboard (open, left, right, down) :-)

"TBGL_TranslatePoly" doesn't exist or shows errors, the same to
"TBGL_RotatePoly"




TBGL_Translate Poly %GL_LINES(-0.0, 0.0, -4.0) '' Move Left 1.5 Units And Into The Screen 4.0
TBGL_Rotate Poly %GL_LINES(1.0, 2.0, 0.0) '' Rotate The Triangle On The X axis ( NEW )

TBGL_BeginPoly %GL_LINES
' -- Horizontal, from left to right, in half of screen
TBGL_COLOR 255, 0, 0
TBGL_Vertex 0, 0.55
TBGL_COLOR 255, 0, 0
TBGL_Vertex 1, 0.55

' -- Vertical, from top to down, in half of screen
TBGL_COLOR 255, 0, 0
TBGL_Vertex 0.55, 0
TBGL_COLOR 255, 0, 0
TBGL_Vertex 0.55, 1

TBGL_ENDPOLY

TBGL_Rotate Poly %GL_LINES = + 0.8 '' Increase The Rotation Variable For The Triangle ( NEW )


TBGL_RotatePoly = + 0.8 doesn't function too;-)




Perhaps somebody can help...

good evening, good ideas and until the next time, best regards, lionheart

ps: good to hear the next new issue of thinbasic will come this month! :->

ErosOlmi
04-09-2008, 23:01
Lionheart008,

please possibly avoid double posting very similar requests (http://community.thinbasic.com/index.php?topic=2006.msg14811#msg14811).
As you have seen, here people are very helpful but posting almost similar requests in two different threads can get users confused.

Ciao
Eros

Lionheart008
04-09-2008, 23:35
dear eros, yes, that was my mistake... have copied the message again, but would like to ask another thing and in this column... sorry, I can understand double postings are confuse the users here... beginner mistake;-)

ciao, lionheart