' Rapid-Q by William Yu (c)1999-2000 . ' ================================================================================ ' Upload_il_tuo_script_su_Rapidq.it ' QInputBox QInputBox J, 01 aprilie 2004, 14:23 (RO) THU, 01 April 2004, 14:23 (EN) © Stănescu Åžerban, 2004. 1.Custom_Control: 2.Purpose: The purpose of this custom control is to offer to the programmer a possibility to querry the user of a program for a data input. The control lets the programmer choose the message he needs to display on the dialog, according to the needs. We often encounter that need during programming. There are a wide range of situations when we ned to ask user to input some data, according to program flow. In order to accomplish some special program requirements, we need to get some runtime data from the user, or avoid some data input leaks comming from users. It's much easier to bring up such a dialog, than using some weird hidden code, to avoid an error, for instance when the user has to fill a field with a value for a runtime computing. If user simply forgot to fill the required data, we bring such a dialog, and ask him explicitly to input the data. It's nicer and obvious to the user that there must be some mistake. 3._Syntax: MyString=QInputBox.Input(QuerryString) QInputBox - Should be replaced with the control's name in control's declaration: Let's say, DIM InputBox As QInputBox MyString = A String variable to get the user input; QuerryString =A String variable which holds the message the control will show for the user. Let's say, "You forgot to input the value for your age! Please input the value now!" If you need to show a long message, use or to make a multiline message. The size of the dialog should allow at least three lines, as shown in the demo program. 4._QInputBox_Methods: FUNCTION Input(Querry As String) As String The function receives the message string as a parameter from the programmer. This message has to be displayed on the QInputBox dialog. After user's input, the function will return the user input so the programmer will be able to pass it where needed in program flow. In the sample code, you can see it running. Just create an empty file with your code editor, and paste the code from the "Sample code" section, and then run it. A typical_call for the Dialog is: MyString=InputBox.Input("Please input a value for current year!") Or, if we need to pass the value to a control, named : Edit1.Text=InputBox.Input("Please input a value for current year!") All_other_methods_are_inherited from the , but we don't really need them. 5._Properties All_properties_are_inherited from the , so if you want to set the caption, do it as with any other form. The current sample, shows the name of the .exe file of the demo. 6._Screen_capture 7._The_Sample_Code '============ ' QInputBox.inc '============ '--- QInputBox.bas: <<-- This is the testing module for '=========================================== '--- Purpose: ' This Control gives a useful method to querry user for an input ' while running the application. We often encounter that need. ' (C) Stanescu Serban, 2004, GNU-GPL (See http://www.gnu.org) '========================== Type QInputBox Extends QForm Message As QEdit '--- Add the edit field lblQuerry As QLabel '--- Add a label for our message OKBtn As QCoolBtn '--- The button we need to ' close the window and pass the input value '--- Redefine the OKBtn.OnClick Event to according to our purpose EVENT OKBtn.OnClick If QInputBox.Message.Text<>"" Then QInputBox.Close Else '--- Change the message according to the locales... '---(EN) 'ShowMessage "No input?!? Please type in something!" '---(RO) ShowMessage "Nimic introdus?!? Va rog introduceti ceva!" End If END EVENT FUNCTION Input(Querry As String) As String '--- Why doesn't this work?!! 'QInputBox.lblQuerry.Alignment=2 'taCenter '2 QInputBox.lblQuerry.Caption=" "+Querry QInputBox.Message.Font.Bold=1 QInputBox.ShowModal Result=QInputBox.Message.Text QInputBox.Message.Text="" END FUNCTION CONSTRUCTOR DelBorderIcons 1,2 '--- Minimize and Restore buttons Height=150 Center lblQuerry.Parent=QInputBox lblQuerry.Autosize=1 lblQuerry.Alignment=2 'taCenter lblQuerry.Top=8 lblQuerry.Font.Bold=1 lblQuerry.LabelStyle=1 Message.Parent=QInputBox Message.Left=1 OKBtn.Parent=QInputBox OKBtn.Top=QInputBox.ClientHeight-27 Message.Top=QInputBox.OKBtn.Top-27 OKBtn.Left=QInputBox.ClientWidth/2-OKBtn.Width/2 OKBtn.Font.Bold=1 lblQuerry.Width=QInputBox.ClientWidth-5 Message.Width=QInputBox.ClientWidth-5 OKBtn.Caption="O&K" END CONSTRUCTOR End Type '=========================================== '========================================== = '========================== '--- QInputBox.bas: This is the testing module for ' QInputBox.inc '========================== $Include "QInputBox.inc" $Include "rapidq.inc" DECLARE SUB BInput_OnClick(Sender As QCoolBtn) DIM TestInput As QForm With TestInput .Caption="Test QInputBox Control Form" .Height=120 .Center End With DIM BInput As QCoolBtn With BInput .Parent=TestInput .Top=20 .Width=95 .Font.Bold=1 .Left=TestInput.Width/2- .Width/2 .Caption="Show InputBox" .OnClick=BInput_OnClick End With DIM EditResult As QEdit With EditResult .Parent=TestInput .Top=BInput.Top+BInput.Height+15 .Width=280 .Left=TestInput.Width/2- .Width/2 .Color=RGB(255,255,221) .Font.Color=RGB(0,0,221) .Font.Bold=1 End With DIM InputBox As QInputBox '========================== TestInput.ShowModal '========================== SUB BInput_OnClick EditResult.Text="" InputBox.Caption=Application.ExeName 'InputBox.Width=400 EditResult.Text=InputBox.Input("Introduceti o valoare corespunzatoare "+CRLF+"necesitatilor programului, " +CRLF+"altfel nu se vor putea efectua calculele fara erori!") END SUB ' =============================================================================== ' 2003 Holyguard.net - 2007_Abruzzoweb