문제

I have a TEdit with PasswordChar set to * and I want the standard "Caps Lock is On" balloon to appear if the Caps Lock mode is on. That standard balloon appearing only when the editor is getting focus or when Caps Lock mode has been turned on, while the focus was in that editor.

My password editor is the first focused control of the application. So, when the application starts with Caps Lock mode previously on, I cannot see any balloons until my password editor will lose focus and then will be focused again. The user has a chance to not see that balloon in half of the use cases!

Can I force this "Caps Lock is On" balloon at application startup without switching focus?

도움이 되었습니까?

해결책

The solution is to call WM_KILLFOCUS and WM_SETFOCUS, this will force the editor to show "Caps Lock is On" balloon:

  if GetKeyState(VK_CAPITAL) and 1 <> 0 then
  begin
    if edtPassword.Focused then
    begin
      PostMessage(edtPassword.Handle, WM_KILLFOCUS, 0, 0);
      PostMessage(edtPassword.Handle, WM_SETFOCUS, 0, 0);
    end;
  end;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top