Search code examples
delphidelphi-xe6

What is the TForm.TipMode property for?


What is the TForm.TipMode property for ?

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


Solution

  • 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.)