Thema: Delphi Diverse Fokusprobleme

Einzelnen Beitrag anzeigen

Gerd01

Registriert seit: 18. Mär 2005
Ort: NRW
117 Beiträge
 
Delphi XE2 Professional
 
#8

AW: Diverse Fokusprobleme

  Alt 30. Apr 2014, 09:58
Ich kenne das Problem auch schon lange bei TFindDialog. Zum Beispiel in anderen Forms als in der Mainform. Ich habe dafür folgenden Workaround in Application on Message:

Code:
procedure TfmGeMail.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
var
  Shift: TShiftState;
  Key: Word;

  procedure GetShiftState(var Shift: TShiftState);
  var
    KeyboardState: TKeyboardState;
  begin
    Shift := [];
    GetKeyboardState(KeyboardState);
    if (KeyboardState[vk_Shift] and 128 = 128) then
      Shift := Shift + [ssShift];
    if (KeyboardState[VK_CONTROL] and 128 = 128) then
      Shift := Shift + [ssCtrl];
    if (KeyboardState[vk_Menu] and 128 = 128) then
      Shift := Shift + [ssAlt];
  end;


begin
  GetShiftState(Shift);
  Key := Msg.WParam;
  case Msg.Message of
    WM_KEYDOWN:
      case Key of
        Ord('F'): if (Shift=[ssCtrl]) then
                  begin
                    SetWindowPos (Application.handle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE+SWP_NOSIZE or SWP_NOREDRAW);
                    SetWindowPos(Application.Handle, HWND_NOTOPMOST, 0,0,0,0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOREDRAW );
                  end;


...
Dann werden die Fenster wieder in der richtigen Reihenfolge und der FindDialog verschwindet nicht und ist focussiert
  Mit Zitat antworten Zitat