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

Вниз

Как узнать с какого контрола перешел фокус на текущий?   Найти похожие ветки 

 
BillyJeans ©   (2003-08-13 12:50) [0]

Как узнать с какого контрола перешел фокус на текущий?


 
Семен Сорокин ©   (2003-08-13 12:51) [1]

никак, тока если на onExit контрола сохранять его ссылку


 
BillyJeans ©   (2003-08-13 12:52) [2]

а если много контролов?


 
Семен Сорокин ©   (2003-08-13 12:55) [3]

общий обработчик на OnCreate
for _i := 0 to ControlCount - 1 do
if Controls[_i] is TWinControl then
TWinControl(Controls[_i]).OnExit := MyExit;


 
Толик ©   (2003-08-13 12:59) [4]

F1 + TWinControl.FindNextControl
The GoForward parameter controls the direction of the search. If GoForward is True, FindNextControl searches forward through the child controls in tab order. If Go Forward is False, FindNextControl searches backward through the controls.


 
BillyJeans ©   (2003-08-13 13:00) [5]

The WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard focus.
может тут копнуть?


 
NAlexey ©   (2003-08-13 13:01) [6]

Кажется я отвечал. повторюсь:
Насколько я помню в WM_SETFOCUS в WParam хранится Handle того кто потерял.


 
BOA_KAA ©   (2003-08-13 13:04) [7]

Почему никак?
WM_SETFOCUS: в WParam передается окно(контрол) которое утратило фокус
WM_KILLFOCUS: в WParam - окно(контрол) которое получает фокус
Ловим на контрол и вот


 
BillyJeans ©   (2003-08-13 14:29) [8]


> NAlexey © (13.08.03 13:01) [6]

Выходит WM_SETFOCUS ловить нужно глобально для всех контролов?


 
NAlexey ©   (2003-08-13 14:57) [9]

Не берусь советовать, все зависит от задачи. Главное что цель ясна. Не важно где ты его выловил:

var
Ctl: TWinControl;
begin
WM_SETFOCUS:
begin
Ctl := FindControl(WParam);
if Assigned(Ctl) then
{ ... }
end;
end;


 
BillyJeans ©   (2003-08-13 15:02) [10]


> NAlexey © (13.08.03 14:57) [9]

хм... это будет работать?


 
NAlexey ©   (2003-08-13 15:06) [11]

Что это?


 
Семен Сорокин ©   (2003-08-13 15:06) [12]

BillyJeans © (13.08.03 15:02)
Application.OnMessage


 
NAlexey ©   (2003-08-13 15:09) [13]

>Семен Сорокин
Не факт что он сможет так отловить WM_SETFOCUS...


 
BillyJeans ©   (2003-08-13 15:11) [14]

как я в событии OnEnter могу узнать с кого пришел фокус???


 
HSolo ©   (2003-08-13 15:14) [15]

А так:
procedure CatchWMSETFOCUS(Var Msg: TMessage); message WM_SETFOCUS;
begin
//...
inherited;
//...
end;


 
NAlexey ©   (2003-08-13 15:18) [16]

>BillyJeans
Никак.
>HSolo
Это справедливо для ОДНОГО конкретного конторола.


 
BillyJeans ©   (2003-08-13 15:22) [17]


> HSolo © (13.08.03 15:14) [15]

это и будет глобально...


 
BillyJeans ©   (2003-08-13 15:25) [18]

может так запомнить для начала...

procedure TForm1.CatchWMSETFOCUS(Var Msg: TMessage);
var BackControl: THandle;
begin
inherited;
BackControl := msg.wParam;
end;


 
NAlexey ©   (2003-08-13 15:32) [19]

>может так запомнить для начала...
Да чё запомнитьто?
procedure TYourControl.WMSETFOCUS(var Msg: TMessage);
var
Ctl: TWinControl;
begin
inherited;
Ctl := FindControl(Msg.WParam);
if Assigned(Ctl) then Windows.SetFocus(Ctl.Handle);
end;


 
BillyJeans ©   (2003-08-13 15:38) [20]

procedure TYourControl.WMSETFOCUS(var Msg: TMessage); что это?


 
NAlexey ©   (2003-08-13 15:43) [21]


TYourControl = class(TSomeClass)
protected
procedure WmSetFocus(var Msg: TMessage); message WM_SETFOCUS;
end;

procedure TYourContro.WmSetFocus(var Msg: TMessage);
begin

end;


 
Семен Сорокин ©   (2003-08-13 15:48) [22]

2BillyJeans ©

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
Memo1: TMemo;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Memo2: TMemo;
ComboBox1: TComboBox;
ListBox1: TListBox;
procedure FormCreate(Sender: TObject);
private
FLastControl: TWinControl;
public
procedure MyExit(Sender: TObject);
end;

type
T_WinControl = class(TWinControl)
public
property OnExit;
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
_i: integer;
begin
for _i := 0 to ControlCount - 1 do
if Controls[_i] is TWinControl then
T_WinControl(Controls[_i]).OnExit := MyExit;
end;

procedure TForm1.MyExit(Sender: TObject);
begin
//ShowMessage(TWinControl(Sender).Name)
FLastControl := Sender
end;

end.



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

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

Наверх




Память: 0.51 MB
Время: 0.032 c
1-81629
Spawn
2003-08-14 09:38
2003.08.25
Word


14-81949
VEG
2003-08-05 19:05
2003.08.25
Нужен ли человечеству ИИ???


1-81686
ilka
2003-08-11 14:16
2003.08.25
проблема с TStrings


14-81935
mfender
2003-08-08 19:02
2003.08.25
Существует ли компонент наподобие графика мероприятий в Outlook e


1-81732
Mishenka
2003-08-07 15:53
2003.08.25
Запись информации.