Mega Code Archive

 
Categories / Delphi / Examples
 

Hinting

Subject: Rich Edit 'Label' Text Hi Weyert Wrote this B4 but I guess you didn't get it: I'm not aware of any component that's "like a label but which allows the use of RTF text" BUT if you size a RichEdit so that's it's about 100 by 20 pixels say, and set the BorderStyle property to bsNone (and ReadOnly to True) then it looks suspiciously like a label! You could then set the color to whatever you want, and format text as you liked. Would that do what you want it to? Below is a small complete program where there is an 'editor' RichEdit component on a form. Also on the form is a 'hint RichEdit' (as above) whose Visible property br default is False (ie it's usually hidden). A right-mouse click will show the 'hint RichEdit', while a left mouse click will hide it again. Hope this is useful... Richard unit TempUnit; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls; type TForm1 = class(TForm) ExitButton: TButton; RichEdit: TRichEdit; HintRichEdit: TRichEdit; procedure ExitButtonClick(Sender: TObject); procedure RichEditMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure ShowREHint(X, Y: Integer); private {private declarations} public {public declarations} end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.ExitButtonClick(Sender: TObject); begin Close; end; procedure TForm1.RichEditMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if (Button = mbRight) then ShowREHint(X, Y); if (Button = mbLeft) then HintRichEdit.Hide; end; procedure TForm1.ShowREHint(X, Y: Integer); begin HintRichEdit.Clear; HintRichEdit.Color := clAqua; HintRichEdit.Lines.Add('Trout'); HintRichEdit.Left := X; HintRichEdit.Top := Y; HintRichEdit.Show; end; end. Hope this is useful Richard