UIStateForm.pas 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. unit UIStateForm;
  2. {
  3. Inno Setup
  4. Copyright (C) 1997-2004 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 on Windows 2000 and later
  9. when the "Hide keyboard navigation indicators" option is enabled.
  10. $jrsoftware: issrc/Projects/UIStateForm.pas,v 1.2 2004/06/26 04:36:08 jr Exp $
  11. }
  12. interface
  13. uses
  14. Windows, SysUtils, Messages, Classes, Graphics, Controls, Forms, Dialogs;
  15. type
  16. TUIStateForm = class(TForm)
  17. private
  18. procedure CMDialogKey(var Message: TCMDialogKey); message CM_DIALOGKEY;
  19. procedure CMShowingChanged(var Message: TMessage); message CM_SHOWINGCHANGED;
  20. end;
  21. implementation
  22. const
  23. WM_CHANGEUISTATE = $0127;
  24. UIS_SET = 1;
  25. UIS_CLEAR = 2;
  26. UIS_INITIALIZE = 3;
  27. UISF_HIDEFOCUS = $1;
  28. UISF_HIDEACCEL = $2;
  29. procedure TUIStateForm.CMShowingChanged(var Message: TMessage);
  30. begin
  31. if Showing then
  32. SendMessage(Handle, WM_CHANGEUISTATE, UIS_INITIALIZE, 0);
  33. inherited;
  34. end;
  35. procedure TUIStateForm.CMDialogKey(var Message: TCMDialogKey);
  36. begin
  37. case Message.CharCode of
  38. VK_LEFT..VK_DOWN, VK_TAB:
  39. SendMessage(Handle, WM_CHANGEUISTATE, UIS_CLEAR or (UISF_HIDEFOCUS shl 16), 0);
  40. VK_MENU:
  41. SendMessage(Handle, WM_CHANGEUISTATE, UIS_CLEAR or ((UISF_HIDEFOCUS or UISF_HIDEACCEL) shl 16), 0);
  42. end;
  43. inherited;
  44. end;
  45. end.