What is the TForm.TipMode property for?
Asked Answered
G

1

10

What is the TForm.TipMode property for ?

It's been added in Delphi XE3, but the documentation says nothing about this property.

Glottology answered 21/7, 2014 at 21:51 Comment(1)
I stopped being amazed about undocumented functions in Delphi's new help. Now I get amazed hen I find a function that IS documented.Orison
C
11

TTipMode is defined in Controls.pas, and is used to track the status (open or closed) of the text input panel available from TabTip.exe that is in the ITextInputPanel interface.

procedure TWinControl.UpdateTIPStatus;
begin
  if Assigned(FTIPIntf) then
  begin
    if TipMode = tipOpen then SetTextInputPanelStatus(Self, True)
    else if TipMode = tipClose then SetTextInputPanelStatus(Self, False);
  end;
end;

Here's the SetTextInputPanelStatus procedure that is called from this method:

procedure SetTextInputPanelStatus(Control: TWinControl; OpenTIP: Boolean);

  procedure InvokeTabTip;
  const
    DefaultTabTipPath = 'C:\Program Files\Common Files\microsoft shared\ink\TabTip.exe';
    DefaultOnScreenKeyboardPath = 'C:\Windows\System32\OSK.exe';
  var
    TabTipPath: string;
  begin
    TabTipPath := DefaultTabTipPath;
    ShellExecute(0, 'open', PChar(TabTipPath), nil, nil, SW_SHOWNOACTIVATE);
  end;

  procedure OPenTip2;
  begin
    (Control.FTIPIntf as ITextInputPanel).SetInPlaceVisibility(1); // True
  end;

  procedure CloseTip;
  begin
    (Control.FTIPIntf as ITextInputPanel).SetInPlaceVisibility(0); // False
  end;

begin
  if Assigned(Control.FTIPIntf) then
  begin
    if OpenTIP then OpenTip2 // InvokeTabTip
    else CloseTip;
  end;
end;

This shows that if the final parameter (OpenTip) is True, it opens the text input panel with the command line to the program (done in OpenTip). If the paramter is False it closes that window. You can see the text input window by executing the application in the location specified by DefaultTabTipPath.

(Note that the code for InvokeTabTip which includes that constant, included above, is never executed; the call to it is commented out. Thanks to @SertacAkyuz for pointing that out. I've edited to include that information.)

Charwoman answered 21/7, 2014 at 22:13 Comment(5)
Is this VCL code? Hard coded path? I'd expect at least code would look into HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\TabTip.exe. Even the key itself is not that hard coded: %CommonProgramFiles%\microsoft shared\ink\TabTip.exePeritonitis
@Sertac: Yes, I'm afraid it is, straight from VCL.Controls.Pas, around line 13360, in XE6.Charwoman
@Sertac: Agreed. It looks like at some point they replaced things with an interface, and just didn't remove that old code. (Or maybe it was never used in released code, but was just never cleaned up.)Charwoman
@Sertac: I've edited my answer to include the information about the ITextInputPanel interface that's used (as well as the information about the hard-coded paths being in dead code). Thanks for spotting that; I'd never noticed TTipMode until I saw this question and investigated to see what it was, and missed it.Charwoman
@SertacAkyuz The fact that that code can emerge from Embarcadero at all is simply appalling. It's as if they have no code review in place at all.Waylin

© 2022 - 2024 — McMap. All rights reserved.