Delphes :Empêcher l'indice TPageControl de s'afficher sur les éléments contenus

StackOverflow https://stackoverflow.com/questions/3214359

  •  13-09-2020
  •  | 
  •  

Question

J'ai un formulaire avec les composants suivants :UN TPageControl contenant un seul TTabSheet, contenant un TEdit.

Je veux qu'un indice "Bonjour" s'affiche lorsque je passe la souris sur l'onglet de contrôle de page, et Non indice affiché lorsque je passe la souris sur TEdit.

Le PageControl a un hint= "Hello", et showhint = true.Cela fonctionne comme prévu.

Le TEdit a showhint = false, parentshowhint = false, et hint est vide.

Mais je reçois toujours un indice "Bonjour" lorsque je passe la souris sur TEdit.Comment puis-je arrêter cela ?

Voici le .dfm, si vous êtes intéressé.

object Form65: TForm65
  Left = 0
  Top = 0
  Caption = 'Form65'
  ClientHeight = 258
  ClientWidth = 290
  OldCreateOrder = False
  ShowHint = True
  TextHeight = 13
  object PageControl1: TPageControl
    Left = 0
    Top = 0
    Width = 290
    Height = 258
    Hint = 'Bar'
    ActivePage = TabSheet1
    Align = alClient
    TabOrder = 0
    object TabSheet1: TTabSheet
      Caption = 'TabSheet1'
      object Edit3: TEdit
        Left = 72
        Top = 67
        Width = 121
        Height = 21
        ParentShowHint = False
        ShowHint = False
        TabOrder = 0
        Text = 'tab1'
      end
    end
  end
end
Était-ce utile?

La solution

Ajoutez un contrôle TApplicationEvents à votre formulaire et utilisez l'événement OnShowHint :

procedure TForm1.ApplicationEvents1ShowHint(var HintStr: string;
  var CanShow: Boolean; var HintInfo: THintInfo);
begin
  CanShow := HintInfo.HintControl <> Edit1;
end;

Si vous n'avez pas l'objet TApplicationEvents (par ex.si vous utilisez une très ancienne version de Delphi), alors vous pouvez utiliser (dans FormCreate, par exemple)

Application.OnShowHint := ApplicationEvents1ShowHint

pour définir le gestionnaire d'événements manuellement.

Mise à jour

Si vous avez plusieurs contrôles dans TTabSheet, vous pourriez rencontrer le même problème avec tous.Alors cela pourrait vous intéresser

procedure TForm1.ApplicationEvents1ShowHint(var HintStr: string;
  var CanShow: Boolean; var HintInfo: THintInfo);
begin
  CanShow := not SameStr(HintStr, PageControl1.Hint) or (HintInfo.HintControl = TabSheet1);
end;

Mise à jour 2

Si vous avez plusieurs TTabSheets dans le TPageControl et que vous souhaitez que toutes les feuilles affichent l'indice, mais aucun des contrôles enfants, vous pouvez le faire

  CanShow := not SameStr(HintStr, PageControl1.Hint) or
    ((HintInfo.HintControl is TTabSheet) and
      (TTabSheet(HintInfo.HintControl).PageControl = PageControl1));

plutôt.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top