Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Cursor verschwindet in TEdit nach Form.Show (https://www.delphipraxis.net/58584-cursor-verschwindet-tedit-nach-form-show.html)

vt670 9. Dez 2005 10:05


Cursor verschwindet in TEdit nach Form.Show
 
Hallo,

in einem "onEnter" eines TEdit möchte ich Fenster anzeigenn und anschliessend wieder zurück zum Edit.
Dummerweise wird in dem Edit anschliessend kein Cursor angezeigt.


Delphi-Quellcode:
procedure TForm1.EditEnter(Sender: TObject);
VAR
P : TPoint;

begin
IF NOT ShortCutForm.Visible
   THEN
   ShortCutForm.Show;
Application.ProcessMessages;


IF Edit.CanFocus
   THEN
   Edit.SetFocus;

Application.ProcessMessages;
// vergebliche versuche grrrrrr
Edit.Text := '123456';
Edit.SelStart := 1;
Edit.SelLength := 3;
Edit.Refresh;
Edit.Cursor := crDefault;
GetCaretPos( P );
ShowCaret(Edit.Handle);
Form1.Refresh;
end;

Wenn ich das Form jedoch anklicke und anschliessend das Edit im Hauptform anklicke wird der Cursor angezeigt.

dataspider 9. Dez 2005 10:12

Re: Cursor verschwindet in TEdit nach Form.Show
 
Kann es sein, dass das Form den Focus nicht wieder bekommt?
Cu, Frank

vt670 9. Dez 2005 10:21

Re: Cursor verschwindet in TEdit nach Form.Show
 
Zitat:

Zitat von dataspider
Kann es sein, dass das Form den Focus nicht wieder bekommt?
Cu, Frank

Hallo Frank,

hatte ich auch schon gedacht ist aber leider nicht der fall. ActiveControl und ActiveForm habe ich mit dem Debugger gepüft. Ein Tastendruck geht auch an das Edit nur halt ohne Cursor :(

danke für deine Antwort

vt670 9. Dez 2005 15:01

Re: Cursor verschwindet in TEdit nach Form.Show
 
für alle die jemals vor dem gleichen Problem stehen sollten, hier die Lösung der Workaround:
Delphi-Quellcode:
procedure TKBForm.myShowForm ( Work : TForm );
BEGIN
WITH Work DO
     BEGIN
     SetWindowPos( Handle,
                   HWND_TOPMOST,
                   Left,Top, Width,Height,
                   SWP_NOACTIVATE or
                   SWP_NOMOVE or
                   SWP_NOSIZE or
                   SWP_SHOWWINDOW );
     END;
END;


procedure TKBForm.myHideForm ( Work : TForm );
BEGIN
WITH Work DO
     BEGIN
     SetWindowPos( Handle,
                   HWND_TOPMOST,
                   Left,Top, Width,Height,
                   SWP_NOACTIVATE or
                   SWP_NOMOVE or
                   SWP_NOSIZE or
                   SWP_HIDEWINDOW );
     END;
END;


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:57 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz