Главная страница
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.051 c
2-1150432976
Kristina_spb
2006-06-16 08:42
2006.07.02
на сколько нужно делить Кб чтоб получить Гб?


3-1146904453
Olleg_ator
2006-05-06 12:34
2006.07.02
Подскажите


2-1150204269
RomanH
2006-06-13 17:11
2006.07.02
ACDSee в OLE-контейнере


2-1150265940
XTD
2006-06-14 10:19
2006.07.02
Есть DisAssembler. А DisDelphi есть ?


1-1148452967
.ruslan
2006-05-24 10:42
2006.07.02
Сохранение содержимого TListView