Bug - resolvendo o bug do cursor desaparecido |
Top Previous Next |
|
{ You may have come across the disappearing caret trick! Often when you have a series of Edit Boxes you want to use the OnExit event to do some validation. Sometimes, though, your OnExit routine may need to display a messagebox. When you do this you'll find that after closing the message box, the caret (or cursor) has disappeared!
To see this bug/feature of Delphi, just create 3 or 4 edit boxes, and then in one of them put the code: }
procedure TForm1.Edit1Exit(Sender: TObject); begin showmessage('The caret will now disappear'); end;
//Run it and see what happens. The cure is to get Windows to move the focus to the next control and then straight back again. //Here is a piece of code which illustrates how to do it.
procedure TForm1.Edit1Exit(Sender: TObject); begin showmessage('Your caret will not disappear this time'); postmessage(handle,WM_NEXTDLGCTL,0,0); postmessage(handle,WM_NEXTDLGCTL,1,0); end; |