Главная страница
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.03 c
15-1149483514
Ega23
2006-06-05 08:58
2006.07.02
С Днём рождения! 4 июня


15-1149644353
Никос
2006-06-07 05:39
2006.07.02
Общее


6-1140767270
integery
2006-02-24 10:47
2006.07.02
indy10 TIdAttachmentFile(Msg.MessageParts.Items[intIndex]).Filena


2-1150311706
STALKER2
2006-06-14 23:01
2006.07.02
TTreeView


15-1149340797
Новичоккк
2006-06-03 17:19
2006.07.02
Реализация BlowFish для Delphi