@rvk:
Well, if I've correctly understood it, the standard is not to hide the focus rectangle (and the underlined letters too) by default, when starting.
In fact, it's : "when starting, do as it is configured for the current user". And by default, Windows configurations do include these 2 hidings.
This behavior can be change directly by the user in: Control Panel, under Appearance, Effects, option "Hide underlined letters for keyboard navigation until I press the Alt key".
Please note that this option is in fact common to the 2 sorts of hiding, though it's mentioning only one of them.
You can make a few tests by yourself by modifying this option. The LCL is quite respecting the user option (well, at least for me): hidden when starting if this option is checked, not hidden (both for underlined letters and focus rectangle) in the other case.
And this is quite conform to any Windows program behavior. Attached, one of my small sample programs I've quickly modified to see the effect of this option on a "standard" Windows program when it starts.
As this program is not using the LCL at all (it's using directly the Windows DialogBox API) and as it doesn't modify any UI state by itself, I consider it could be a sort of "reference" of what is expected for a "standard" Windows program concerning these 2 points (underlined letters + focus rectangle when starting).
The results are identical as those for the LCL.
However, I've noticed one difference between the LCL and the "direct" Windows DialogBox. When the option is checked (i.e. both hidden when starting), if you press the ALT key:
-for the LCL, only the underlined letters become visible; focus rectangle are not affected,
-for the Windows DialogBox, both of them become visible.
The second version is more logical, as you stated. But on the opposite, the first one is compatible with Delphi (at least with my own old version of Delphi). So, which one is better ? I guess the answer won't be the same one for everybody.
A few links concerning your question about the focus rectangle visibility (the second one is the more interesting one; I've already included it in one of my former posts):
http://msdn.microsoft.com/en-us/library/ms646335%28VS.85%29.aspx#_win32_UI_Statehttp://blogs.msdn.com/b/oldnewthing/archive/2005/05/03/414317.aspx@BrunoK:
I couldn't remember the exact order of the different Windows events (and consecutive LCL processes) when a key is pressed; that's why I've not included any more precisions about them in my comment.
And you are quite right: if the focused control/form processes this keyboard event first, effectively it's quite possible in the message result (i.e. WM_SYSCHAR->LM_SYSCHAR) to tell Windows that the message has already been processed.
I'm just a bit surprised it's not already the case in the LCL: when a corresponding mnemonic (Alt+Char) has been found and is valid, I mean.
I've discovered lastly your own bug report; though I've not looked deeply into your code.
Briefly, what his the main idea ? LZDialogChar replaces the current DialogChar method: with a specific method (i.e. overidden) for each kind of control ?
Concerning your own NoHideFocus test (just another test result difference; great), which result do you get: no focus visible at all ? Never ?
**Edit1**
After having looked at the LCL source code again, it seems that the control mnemonics are processed in the DialogChar(var Message: TLMKey) method indeed. I guess this one is called after the menu handler, and that's why it's too late for the beep. Or ...
**Edit2**
@rvk:
So, apparently there is definitely something different between Windows XP and Windows 7 (and probably all 8.x) concerning this issue.