Форум: "Прочее";
Текущий архив: 2006.07.02;
Скачать: [xml.tar.bz2];
ВнизПростой вопрос Найти похожие ветки
← →
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;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.01 c