Je voudrais savoir s'il est possible d'afficher le HINT d'un edit meme si celui-ci a sa propriete enabled a FAUX.
Merci d'avance
Version imprimable
Je voudrais savoir s'il est possible d'afficher le HINT d'un edit meme si celui-ci a sa propriete enabled a FAUX.
Merci d'avance
Voici une solution à modifier selon tes besoins
1) Associer à l'événement OnShowHint une nouvelle procédure
2) Définir la procédure qui ajuste la valeur du HintCode:
1
2
3
4
5 procedure TForm1.FormCreate(Sender: TObject); begin Application.HintShortPause := 50; Application.OnShowHint := NewOnShowHint; end;
3) Utiliser une fonction déterminant le WinControl sous le curseur de la sourisCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 procedure TForm1.NewOnShowHint(var HintStr: string; var CanShow: Boolean; var HintInfo: THintInfo); var TheWinControl: TWinControl; begin HintInfo.ReshowTimeout := 1000; TheWinControl := GetWinControlAtPos(HintInfo.HintControl as TWinControl, HintInfo.CursorPos); if TheWinControl.Name = PreviousWinControlName then HintStr := '' else if (TheWinControl is TEdit) and (TheWinControl.Hint <> '') and (NOT TheWinControl.Enabled) and TheWinControl.ShowHint then HintStr := TheWinControl.Hint; PreviousWinControlName := TheWinControl.Name; end; // où PreviousWinControlName est une variable globale de type string
Bonne chance.Code:
1
2
3
4
5
6
7
8
9
10
11 function GetWinControlAtPos(TheParent: TWinControl; ThePos: TPoint): TWinControl; var ChildControl: TControl; begin ChildControl := TheParent.ControlAtPos(ThePos, True, True); if (ChildControl <> nil) and (ChildControl is TWinControl) then Result := GetWinControlAtPos(ChildControl as TWinControl, ThePos) else Result := TheParent; end;
Ok je vais essayé. Merci