procedure TForm1.Edit1Exit(Sender: TObject);
begin
OutputDebugString('Edit1Exit');
Application.MessageBox('MessageBox in OnExit', 'Test', MB_OK);
end;
procedure TForm1.Edit2Enter(Sender: TObject);
begin
OutputDebugString('Edit2Enter');
end;
After TAB key in Edit1 and OK in MessageBox is "focused" Edit2, but
without cursor and OnEnter is not performed also. It seems focus change
is not finished. How can I correct this error? I cannot use ShowMessage
or ShowModal, I need to correct focusing.
Thanks for help
rb
"Jaromir Zak" <jarom...@seznam.cz> wrote in message
news:39E9A8F1...@seznam.cz...
See following example:
http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=13359
BTW: There is also Czech Delphi mailing list: http://www.delphi.cz
--
Petr Vones (Team JEDI) - http://delphi-jedi.org
Windows doesn't like a focus change (showing the message window) while
processing a focus change event (OnExit). Use code similer to that
demonstrated in the example following my sig.
--
Regards
Ralph (TeamB)
===
unit EditExit;
interface
uses
SysUtils, WinTypes, WinProcs, Messages,
Classes, Controls, Forms, StdCtrls;
const
copyright = 'Copyright © 1998-1999 Garlin Software Development Corp., '
+ 'Middletown, NJ, USA. '
+ 'All Rights Reserved';
const
UM_EXITPROC = WM_USER + 42;
type
TFrmEditExit = class(TForm)
Button1: TButton;
ComboBox1: TComboBox;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
procedure Edit1Exit(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
FMouseDown: boolean;
procedure AppMessage(var TheMsg: TMsg; var Handled: Boolean);
procedure UMExitProc(var TheMsg: TMessage); message UM_EXITPROC;
public
end;
var
FrmEditExit: TFrmEditExit;
implementation
{$R *.DFM}
uses Unit2;
procedure TFrmEditExit.AppMessage(var TheMsg: TMsg; var Handled: Boolean);
begin
case TheMsg.Message of
WM_LBUTTONDOWN: begin
FMouseDown := true;
Label1.Caption := 'Mouse down'
end;
WM_LBUTTONUP: begin
FMouseDown := false;
Label1.Caption := 'Mouse up'
end;
end;
end;
procedure TFrmEditExit.UMExitProc(var TheMsg: TMessage);
begin
{ Here is where you would do the
actual exit processing, e.g.: }
{ You can also analyze TheMsg for
any additional info }
if FMouseDown then
PostMessage(ActiveControl.Handle, WM_LBUTTONUP, 0, 0);
{ The above takes care of any mouse processing that
was interrupted by the PostMessage. Be aware that
the WM_LBUTTONUP may cause an extraneous MouseUp
event when the exit processing was triggered by
keyboard operations }
with TForm2.Create(Application) do try
ShowModal;
finally
Release;
end;
(* Edit1.SetFocus; {if need be }*)
{ You don't _have_to_ do anything that
I've shown in this procedure. Basically this
procedure is where you decide what gets done
on the exit proc. }
end;
procedure TFrmEditExit.Edit1Exit(Sender: TObject);
begin
PostMessage(Handle, UM_EXITPROC, 0, 0);
{ The last 2 parameters (wParam and lParam)
don't have to be 0. They can be used to
pass additional info to UMExitProc }
end;
procedure TFrmEditExit.FormCreate(Sender: TObject);
begin
FMouseDown := false;
Application.OnMessage := AppMessage;
end;
end.
"Petr Vones (Team JEDI)" wrote:
>
> > After TAB key in Edit1 and OK in MessageBox is "focused" Edit2, but
> > without cursor and OnEnter is not performed also. It seems focus change
> > is not finished. How can I correct this error? I cannot use ShowMessage
>
"Ralph Friedman (TeamB)" wrote:
>
> In message <39E9A8F1...@seznam.cz>, Jaromir Zak stated:
> > After TAB key in Edit1 and OK in MessageBox is "focused" Edit2, but
> > without cursor and OnEnter is not performed also. It seems focus change
> > is not finished. How can I correct this error? I cannot use ShowMessage
> > or ShowModal, I need to correct focusing.
> >
>
> Windows doesn't like a focus change (showing the message window) while
> processing a focus change event (OnExit). Use code similer to that
> demonstrated in the example following my sig.
>
> --
> Regards
> Ralph (TeamB)
> ===
>
> unit EditExit;
>
> interface
>
> uses
> SysUtils, WinTypes, WinProcs, Messages,
> Classes, Controls, Forms, StdCtrls;
>
> const
> copyright = 'Copyright Š 1998-1999 Garlin Software Development Corp., '