BlitzUI: InputBox$()

Community Forums/Showcase/BlitzUI: InputBox$()

superqix(Posted 2003) [#1]
With 200+ messages and counting, I thought BlitzUI could use a new thread... :)

Anyway, has anyone coded an InputBox$() like the MessageBox$() code in the BlitzUI "Extras" folder.

If so, give it up mate!


superqix(Posted 2003) [#2]
Alright, I'll make it myself :)

Function InputBox$(Message$, Title$="")

	W = 180
	H = 95
	for A = 0 to CountItems( Message$, chr(10) ) - 1
		if stringwidth( Parse( Message$, A, chr(10) ) ) + 50 > W
			W = stringwidth( Parse( Message$, A, chr(10) ) ) + 50
		endif
	next
	setfont app\fntLabel
	
	H = H + CountItems( Message$, Chr(10) ) * FontHeight()
	
	winMsgBox = Window( -1,-1, W, H, Title$, 0, True, False, False, True )
	SendMessage( winMsgBox, "WM_SETMODAL" )
	
	Label( -2, 8, Message$, "Center" )
	txtInput = TextBox(4,25,W-12,20,0,0,0,1)

	btnOk = Button( W / 2 - 75, H-50, 70, 20, "Ok" )
	btnCancel = Button( W / 2 + 5, H-50, 70, 20, "Cancel" )
	
	SetBuffer BackBuffer()
	
	Ret$ = ""
	Repeat
		UpdateGUI()
		
		Select app\Event
			case EVENT_WINDOW
				select app\WindowEvent
					case winMsgBox
						select app\WindowEventData
							case "Closed"
								Done = true
						end select
				end select
			Case EVENT_GADGET
				Select app\GadgetEvent
					case btnOk
						Done = true
						Ret$ = SendMessage( txtInput , "TM_GETTEXT" )
					Case btnCancel
						Done = True
				end select
		end select

		DrawMouse()
		ResetEvents()

		Flip
		Cls

	Until Done=True
	UpdateGUI()

	DeleteWindow( winMsgBox )
	winMsgBox = 0
	return Ret$

end function


Just call it like this...
MyInput$ = InputBox$("Enter your IP Address","IP Confirmation")



hub(Posted 2003) [#3]
Nice stuff and thanks to share this superqix.

Myself, i've planned to code a dialog box which return only a folder (not a filename as the OpenSaveDialog function).

BlitzUI is a great gui system, hope Fullernator will open a forum on his site !


hub(Posted 2003) [#4]
Hi !

Some newbie questions about listbox :

- How to get the selected item value ?

- Now, the contrary, how to select the item into the listbox if you only know its value (note : the value, not the index)

Thanks !


hub(Posted 2003) [#5]
Hi !
i think blitzui textbox height doesn't work properly,
try this :
win001 = Window( 283, 134, 458, 484, "Window", "0", 1, 0, 1, 1 )
cbo001 = ComboBox( 62, 109, 190, 10 )
AddComboBoxItem( cbo001, 0, "hfdhfhfgh", "" )

; (i want 12 px !)
txt001 = TextBox( 73, 80, 99, 12, 0, 0, 18, 10, 1 )
SendMessage( txt001, "TM_SETTEXT", 0, "Text Box" )


Thanks !


Odds On(Posted 2003) [#6]
hi hub, you have to set the last parameter to False, because when it's true it snaps to the nearest font height


hub(Posted 2003) [#7]
Many thanks for this Chris ! The blitzui editor sets automatically the parameter to true when it compile the bb code !


hub(Posted 2003) [#8]
Chris, How to get the listbox selected item value ? LM_GETITEMCAPTION ?

Another question. usually in other gui (for example b+) when you hide/disable a group box, its automatically hide/disable all the items into this group. Is it possible with blitzui ?

in fact, at the beginning of my program i wan't quicky disable all the items into a tab page.

This gui system is powerfull and easy to use !

Thanks for your answer !


Odds On(Posted 2003) [#9]
hub, LM_GETCAPTION will get the caption of the selected item. LM_GETITEMCAPTION returns the caption of the specified item (param1).

In BlitzUI groupbox's don't "own" any gadgets.. they are just like buttons etc. Hiding gadgets was a newly added feature and I'm not sure if hiding a tab page will hide all the items contained in it.


hub(Posted 2003) [#10]
Thanks !
the link to your site seems to be broken. i've just realized that i'm not use the lastest blitzui version !
You should also add the version number into the blitzui.bb file !


Odds On(Posted 2003) [#11]
The site is working ok here.. might have just been temporary since you posted an hour ago. I think I probably will include the version number in the source code from now on.