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
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