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

Вниз

KOLEditBox : действия при потере фокуса.   Найти похожие ветки 

 
серый мЫш ©   (2005-04-09 04:12) [0]

Как можно Edit заставить что-то выполнить перед тем, как передать фокус другому элементу приложения?
  Я считал, что для этого нужно событие OnLeave, но, похоже, ошибся.


 
thaddy   (2005-04-09 08:52) [1]

You can trap WM_KILLFOCUS in an onmessage handler:

procedure NewForm1( var Result: PForm1; AParent: PControl );
begin
 New(Result,Create);
 with Result^ do
 begin
   Form:= NewForm(AParent,'KOLForm').SetSize(600,400).centeronparent.Tabulate;
   Applet:=Form;
   Edit:=Neweditbox(form,[]);
   Edit1:=Neweditbox(form,[]).placedown;
   Edit.OnMessage:=DoMessage;
   Form.Add2AutoFree(Result);
 end;
end;

function TForm1.DoMessage(var Msg:TMsg;var Rslt:integer):Boolean;
begin
 Result:=false;
 if msg.message = WM_KILLFOCUS then
  Edit.Caption := 'LostFocus' else
 if msg.message = WM_SETFOCUS then
  Edit.Caption:='HasFocus';
end;


 
thaddy   (2005-04-09 08:53) [2]

You can trap WM_KILLFOCUS in an onmessage handler:

procedure NewForm1( var Result: PForm1; AParent: PControl );
begin
 New(Result,Create);
 with Result^ do
 begin
   Form:= NewForm(AParent,'KOLForm').SetSize(600,400).centeronparent.Tabulate;
   Applet:=Form;
   Edit:=Neweditbox(form,[]);
   Edit1:=Neweditbox(form,[]).placedown;
   Edit.OnMessage:=DoMessage;
   Form.Add2AutoFree(Result);
 end;
end;

function TForm1.DoMessage(var Msg:TMsg;var Rslt:integer):Boolean;
begin
 Result:=false;
 if msg.message = WM_KILLFOCUS then
  Edit.Caption := 'LostFocus' else
 if msg.message = WM_SETFOCUS then
  Edit.Caption:='HasFocus';
end;


 
Владимир Кладов   (2005-04-09 13:19) [3]

вообще то OnLeave есть и он работает в KOL.


 
thaddy   (2005-04-09 17:59) [4]

Oversight... Sorry Vladimir! Your new MM improved already?


 
thaddy   (2005-04-09 17:59) [5]

Oversight... Sorry Vladimir! Your new MM improved already?


 
Владимир Кладов   (2005-04-09 22:15) [6]

I improved it and on first 3 tests it is faster then FastMM from the pack about 30% even without translating code to asm. But on 4th I get Out of memory, and on some other it loose sometimes 7 times (700%). So I decided stop this work for some time and return to collapse project. At least, FastMM3 seems working not bad. Thanks for a link.


 
серый мЫш ©   (2005-04-16 22:05) [7]

М-да... Я и забыл, что OnLeave уже в других случаях использовал и он работает :). Но проблема все равно есть, так как он работает не везде (как в моем случае). А может, это особенности операционной системы, с которыми я еще не ознакомился... В общем, проблема вот какая: есть Grid и есть control, с помощю которого осуществляется ввод данных в Grid. Так вот, этот контрол не имеет OnLeave, по крайней мере, если его пытаться создать стандартно (двойное нажатие на поле OnLeave на вкладке Events в Inspector Object).
    P.S.
    Я, конечно, нашел выход, но хотелось бы знать правильное решение. Так как control в моем случае невидимый, то я дожидался, пока он исчезнет и проводил нужные операции. Такой способ может не всегда пригодится, поэтому я и спросил здесь: как правильно?


 
thaddy   (2005-04-16 22:24) [8]

See my example above: use the focus messages



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

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

Наверх




Память: 0.48 MB
Время: 0.039 c
2-1132873596
Alex17
2005-11-25 02:06
2005.12.11
Exel


3-1130316165
alexliv
2005-10-26 12:42
2005.12.11
создание пользователя


1-1131936511
Razor
2005-11-14 05:48
2005.12.11
Как правильнее передавать строки в DLL?


14-1132011027
ronyn
2005-11-15 02:30
2005.12.11
Как установить драйвер?...


2-1132787260
Дева
2005-11-24 02:07
2005.12.11
работа со строковой переменной