Форум: "KOL";
Текущий архив: 2005.08.28;
Скачать: [xml.tar.bz2];
ВнизInputBox или InoutQuery в KOL Найти похожие ветки
← →
Bil Bal Dur (2005-01-20 16:34) [0]Есть ли они? Как мне ввести строку?
← →
thaddy (2005-01-20 17:04) [1]Here"s code for it, but you can easily use a KOL form. These are the API versions for KOL:
--------------------
program kolinputquery;
uses
Windows,
Messages,
Kol;
{$R *.res}
Function ApiInputBox( Const Caption, Prompt, Default: String ): String;forward;
Function ApiInputQuery( Const Caption, Prompt: String; Var value: String ):Boolean;forward;
const
INPUT_DIALOG = 1;
IDC_EDIT = 102;
IDC_LABEL = 101;
resourcestring
DefaultAPIQueryCaption = "Enter data";
DefaultAPIQueryPrompt = "Value:";
Type
TInputBoxData = Record
aCaption, aPrompt, aValue: String;
End;
PInputBoxData = ^TInputBoxData;
Function ApiInputBox( Const Caption, Prompt, Default: String ): String;
Var
value: String;
Begin
value:= Default;
If APIInputQuery( Caption,Prompt, Value ) Then
Result := value
Else
Result := Default;
End; { ApiInputBox }
Function DlgProc( hwndDlg: HWND; Msg: UINT; wparam: WPARAM; lparam: LPARAM ):
BOOL; stdcall;
Procedure InitDialog;
Var
pdata: PInputBoxData;
Begin
Assert( lparam <> 0 );
pdata := Pointer( lparam );
SetWindowLong( hwndDlg, GWL_USERDATA, lparam );
SetWindowText( hwndDlg, PChar( pdata^.aCaption ));
SetDlgItemText( hwndDlg, IDC_LABEL, Pchar( pdata^.aPrompt ));
If Length( pdata^.aValue ) > 0 Then
SetDlgItemText( hwndDlg, IDC_EDIT, Pchar( pdata^.aValue ));
SetFocus( GetDlgItem( hwndDlg, IDC_EDIT ));
End; { InitDialog }
Function HandleCommand: Boolean;
Var
pdata: PInputBoxData;
Begin
Result := False;
If HiWord( wparam ) = BN_CLICKED Then Begin
Result := true;
If LoWord( wparam ) = IDOK Then Begin
pData := Pointer( GetWindowLong( hwndDlg, GWL_USERDATA ));
SetLength( pData.aValue,
SendDlgItemMessage(
hwndDlg, IDC_EDIT,
WM_GETTEXTLENGTH, 0, 0 ));
GetDlgItemText( hwndDlg, IDC_EDIT, Pchar(pData.aValue),
Length( pData.aValue )+1 );
End;
EndDialog( hwndDlg, LoWord( wparam ));
End;
End; { HandleCommand }
Begin
Result := False;
Case Msg Of
WM_INITDIALOG: InitDialog;
WM_COMMAND : Result := HandleCommand;
End; { Case }
End; { DlgProc }
Function ApiInputQuery( Const Caption, Prompt: String; Var value: String ):Boolean;
Var
data: TInputBoxData;
res: Integer;
Begin
If Length( Caption ) > 0 Then
data.aCaption:= Caption
Else
data.aCaption := DefaultAPIQueryCaption;
If Length( Prompt ) > 0 Then
data.aPrompt := Prompt
Else
data.aPrompt := DefaultAPIQueryPrompt;
data.aValue := value;
res := DialogBoxParam( hInstance, MakeIntResource( INPUT_DIALOG ),
GetActiveWindow, @DlgProc, LPARAM(@data ));
Result := res = IDOK;
Assert( res <> -1, "ApiInputQuery: DialogBoxParam failed" );
End; { ApiInputQuery }
var a:string;
begin
a:="Thaddy";
Applet:=NewForm(nil,"");
Applet.Caption:= ApiInputBox("","",A);//then Applet.Caption:=A;
Run(Applet)
end.
Copy the following to a file apidlg.rc and compile it with brcc32:
/****************************************************************************
apidlg.rc
produced by Borland Resource Workshop
*****************************************************************************/
#define INPUT_DIALOG 1
#define IDC_EDIT 102
#define IDC_LABEL 101
INPUT_DIALOG DIALOG 6, 15, 207, 45
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "INPUTDIALOG"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "OK", IDOK, 148, 6, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 148, 24, 50, 14
LTEXT "Label 1", IDC_LABEL, 4, 12, 138, 8
EDITTEXT IDC_EDIT, 4, 25, 138, 12, ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP
}
Страницы: 1 вся ветка
Форум: "KOL";
Текущий архив: 2005.08.28;
Скачать: [xml.tar.bz2];
Память: 0.46 MB
Время: 0.037 c