Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.08.28;
Скачать: CL | DM;

Вниз

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 вся ветка

Текущий архив: 2005.08.28;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.036 c
6-1116268942
olevacho_
2005-05-16 22:42
2005.08.28
Статистика соединений


14-1122986763
oldman
2005-08-02 16:46
2005.08.28
Извините за оффтоп, но... ПОМОЖИТЕ УБОГОМУ...


3-1121345286
Greg123
2005-07-14 16:48
2005.08.28
Создание индексов в TDBF


1-1123429580
Андрей Молчанов
2005-08-07 19:46
2005.08.28
Как ловить сообщение, но не от формы, а от компонента


6-1116154204
Creo
2005-05-15 14:50
2005.08.28
Програмный выбор сетевого подключения.