UIStateForm.pas 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. unit UIStateForm;
  2. {
  3. Inno Setup
  4. Copyright (C) 1997-2024 Jordan Russell
  5. Portions by Martijn Laan
  6. For conditions of distribution and use, see LICENSE.TXT.
  7. TUIStateForm, a TForm descendant which correctly handles the hiding of
  8. accelerator key characters and focus rectangles when the
  9. "Hide keyboard navigation indicators" option is enabled.
  10. }
  11. interface
  12. uses
  13. Windows, SysUtils, Messages, Classes, Graphics, Controls, Forms, Dialogs;
  14. type
  15. TUIStateForm = class(TForm)
  16. private
  17. procedure CMDialogKey(var Message: TCMDialogKey); message CM_DIALOGKEY;
  18. procedure CMShowingChanged(var Message: TMessage); message CM_SHOWINGCHANGED;
  19. end;
  20. implementation
  21. const
  22. WM_CHANGEUISTATE = $0127;
  23. UIS_SET = 1;
  24. UIS_CLEAR = 2;
  25. UIS_INITIALIZE = 3;
  26. UISF_HIDEFOCUS = $1;
  27. UISF_HIDEACCEL = $2;
  28. procedure TUIStateForm.CMShowingChanged(var Message: TMessage);
  29. begin
  30. if Showing then
  31. SendMessage(Handle, WM_CHANGEUISTATE, UIS_INITIALIZE, 0);
  32. inherited;
  33. end;
  34. procedure TUIStateForm.CMDialogKey(var Message: TCMDialogKey);
  35. begin
  36. case Message.CharCode of
  37. VK_LEFT..VK_DOWN, VK_TAB:
  38. SendMessage(Handle, WM_CHANGEUISTATE, UIS_CLEAR or (UISF_HIDEFOCUS shl 16), 0);
  39. VK_MENU:
  40. SendMessage(Handle, WM_CHANGEUISTATE, UIS_CLEAR or ((UISF_HIDEFOCUS or UISF_HIDEACCEL) shl 16), 0);
  41. end;
  42. inherited;
  43. end;
  44. end.