Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does Delphi have the equivalent of a VB inputbox? 2

Status
Not open for further replies.

Krel

Programmer
Feb 3, 2002
135
CA
If so, what is the name of the function? I couldn't find anything like it in the help files.
 
What do you call an inputbox ?
Delphi has on the standard tab the editbox, the listbox and the combobox. Depending on the version you are using there will be others.

A hint, type the name of the control you need help somewhere in your source, highlight it and press F1

The following is the result of highlighting Tedit






TEdit is a wrapper for a Windows single-line edit control.

Unit

StdCtrls

Description

Use a TEdit object to put a standard Windows edit control on a form. Edit controls are used to retrieve text that users type. Edit controls can also display text to the user.

When only displaying text to the user, choose an edit control to allow users to select text and copy it to the Clipboard. Choose a label object if the selection capabilities of an edit control are not needed.

TEdit implements the generic behavior introduced in TCustomEdit. TEdit publishes many of the properties inherited from TCustomEdit, but does not introduce any new behavior. For specialized edit controls, use other descendant classes of TCustomEdit or derive from it. S. van Els
SAvanEls@cq-link.sr
 
The Delphi unit Dialogs contains a number of routines for simple text output. I usually use ShowMessage, which just takes a string parameter; there is also MessageDlg, which has a few extra parameters for adding buttons and such. Both of these require the Dialogs unit to be in one of the 'uses' lists, either in the interface or implementation sections.

I hope this helps!

Patrick Manion
 
Sorry for the confusion. A VB inputbox is a function that pops up a text box for the user to type something in; it's not a control that you can put on the form. It looks like one of those Javascript user prompts that a few sites have to give input when a site is loaded.

What VB calls a msgbox I think Delphi calls "Showmessage", so I was wondering if Delphi has something equivalent to the inputbox.
 
Ok in Delphi all the visual stuff are related to forms, the pop-up type input is a modal type form. Once you have the form, you customize it with controls and buttons. Like Patrick stated, a lot of customized examples are in the dialogs unit. S. van Els
SAvanEls@cq-link.sr
 
hi,

The name of the function is Inputquery. Beaneath you find an example on how to use this function.

Steph [bigglasses]

example.
procedure TForm1.Button1Click(Sender: TObject);

var
NewString: string;
ClickedOK: Boolean;
begin
NewString := 'Default String';
Label1.Caption := NewString;
ClickedOK := InputQuery('Input Box', 'Prompt', NewString);
if ClickedOK then { NewString contains new input string }
Label1.Caption := 'The new string is ''' + NewString + '''';
end;
 
Awesome, Svanhooft, that's exactly what I wanted. Thanks a ton!
 
Or..

var
res : string;
begin
res := InputBox('caption','prompt','def');
if res = '' then
else

Label1.Caption := 'The new string is ''' + Res + '''';

Works also ;-).

Opp.
 
Lol... I should have thought that it could have the same name, but since all the other names are different from VB, it never occured to me. Thanks to you too, Oppenheimer!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top