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

Вниз

Простой вопрос   Найти похожие ветки 

 
Nic ©   (2006-06-04 21:00) [0]

Есть код обработки введа текста в поле:

procedure TForm1.MemoKeyPress(Sender: TObject; var Key: Char);
begin
 if not (key in["0".."9",#8,#13,"-"]) then key:=#0;
end;


В данном случае #0 - что это такое? Нулевой символ, что-то вроде nothing?


 
Колдун   (2006-06-04 21:04) [1]

просто ничего не будет


 
Marser ©   (2006-06-04 21:30) [2]

> что-то вроде nothing?

Угу.


 
Zeqfreed ©   (2006-06-04 21:53) [3]

Controls.pas:
procedure TWinControl.KeyPress(var Key: Char);
begin
 if Assigned(FOnKeyPress) then FOnKeyPress(Self, Key);
end;

function TWinControl.DoKeyPress(var Message: TWMKey): Boolean;
var
 Form: TCustomForm;
 Ch: Char;
begin
 Result := True;
 Form := GetParentForm(Self);
 if (Form <> nil) and (Form <> Self) and Form.KeyPreview and
   TWinControl(Form).DoKeyPress(Message) then Exit;
 if not (csNoStdEvents in ControlStyle) then
   with Message do
   begin
     Ch := Char(CharCode);
     KeyPress(Ch);
     CharCode := Word(Ch);
     if Char(CharCode) = #0 then Exit;
   end;
 Result := False;
end;

procedure TWinControl.WMChar(var Message: TWMChar);
begin
 if not DoKeyPress(Message) then inherited;
end;


Таким образом, если вернуть #0, то обработка сообщения прерывается и, соответственно, ничего не вводится в контрол.


 
Nic ©   (2006-06-04 23:03) [4]

О, спасибо большое. Я так и думал, но терзали смутные сомнения.

> if Char(CharCode) = #0 then Exit;

Иеперь всё ясно.



Страницы: 1 вся ветка

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

Наверх




Память: 0.47 MB
Время: 0.037 c
15-1147688699
Евгений Р.
2006-05-15 14:24
2006.07.02
OnDblClick в DrawGrid


2-1148848191
Олег_
2006-05-29 00:29
2006.07.02
Общие


2-1150369163
Pe+erBuild
2006-06-15 14:59
2006.07.02
Scrool в грид


2-1150216966
Userr
2006-06-13 20:42
2006.07.02
mdb


1-1148387421
novill
2006-05-23 16:30
2006.07.02
Как описание класса разбить на несколько модулей?