Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: -0.967 c
6-1140371174
newprogrammer
2006-02-19 20:46
2006.07.02
winsock назначение порта серверу


3-1146906931
Alfred
2006-05-06 13:15
2006.07.02
Похоже ошибка в ADOTable


15-1149648990
pargo
2006-06-07 06:56
2006.07.02
Доигрался с AppInit_DLLs :((


2-1149778397
Vasiliy
2006-06-08 18:53
2006.07.02
Как установит Increment для TrackBar ?


1-1148027278
Dr.TurboBoa
2006-05-19 12:27
2006.07.02
Как работать с property типа TStrings




   Наверх