Solved

adding context help for labels ?

Posted on 2000-05-09
14
184 Views
Last Modified: 2010-04-04
Is there a way to add a contextID to a label and have it react to context help request (help by pressing the ? button in form title) ?

of course without rewriting tcustomLabel as a subclass of tWinControl
0
Comment
Question by:fadyg
  • 6
  • 4
  • 4
14 Comments
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2794149
It would seem not. It looks like the Windoze help system uses:
"The GetWindowContextHelpId function retrieves the help context identifier, if any, associated with the specified window." Seeing as only descendants of TWincontrol are windows, that explains why only they have HelpContextIDs. Bummer.

You could use a Tedit with BorderStyle = none, readonly = true, and colour = background to look like a label. Be OK I think if you only had a couple...
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 100 total points
ID: 2794365
You can use a TStaticText (in the additional tab) - it is basically a TLabel but with a window!

Cheers,

Raymond.
0
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2795032
I love those simple answers !

cheers to _you_, Raymond :-)
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 12

Expert Comment

by:rwilson032697
ID: 2795056
I do what I can :o)
0
 

Author Comment

by:fadyg
ID: 2796178
yes but then I will lose two features that I use in my Tlabel subclass: WordWrap and multiline.

This implies that I will have to rewrite the paint of staticlabel to regain those features.

Any simpler solution ?
0
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2796586
Yep !

Since Raymond pointed me at the TStaticText control, and it's a window control, all you need to do is add ES_MULTILINE and remove ES_AUTOHSCROLL from the windows style and recreate the handle. Code below...

I changed the TEXT property to be CAPTION to look more like a label, but unfortunately the text in the control doesn't change when you edit the CAPTION property in the property editor. If you don't like that, just remove the caption property, and publish the text property.

That's all there is to it.

-----------------------------------
unit MyLabel;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TMyLabel = class(TCustomEdit)
  private
    FWordWrap: boolean;
    procedure SetWordWrap(const Value: boolean);
    procedure SetCaption(const Value: string);
    function GetCaption : string;
    { Private declarations }
  protected
    procedure CreateParams(var Params: TCreateParams); override;
  public
    Constructor Create(AOwner : TComponent);override;
    { Public declarations }
  published
    property WordWrap : boolean read FWordWrap write SetWordWrap;
    property Caption : string read GetCaption write SetCaption;
    property Anchors;
    property AutoSelect;
    property AutoSize;
    property BiDiMode;
    property CharCase;
    property Color;
    property Constraints;
    property Ctl3D;
    property DragCursor;
    property DragKind;
    property DragMode;
    property Enabled;
    property Font;
    property HideSelection;
    property ImeMode;
    property ImeName;
    property MaxLength;
    property OEMConvert;
    property ParentBiDiMode;
    property ParentColor;
    property ParentCtl3D;
    property ParentFont;
    property ParentShowHint;
    property PasswordChar;
    property PopupMenu;
    property ShowHint;
    property TabOrder;
    property TabStop;
    property Visible;
    property OnChange;
    property OnClick;
    property OnContextPopup;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDock;
    property OnEndDrag;
    property OnEnter;
    property OnExit;
    property OnKeyDown;
    property OnKeyPress;
    property OnKeyUp;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
    property OnStartDock;
    property OnStartDrag;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Planetech', [TMyLabel]);
end;

{ TMyLabel }

constructor TMyLabel.Create(AOwner: TComponent);
begin
  inherited;
  BorderStyle := bsNone;
  Readonly := true;
  ParentColor := True;
end;

procedure TMyLabel.CreateParams(var Params: TCreateParams);
const
  WordWraps: array[Boolean] of DWORD = (0, ES_AUTOHSCROLL);
begin
  inherited CreateParams(Params);
  with Params do
    Style := Style and not WordWraps[FWordWrap] or ES_MULTILINE;
end;

function TMyLabel.GetCaption: string;
begin
  result := inherited Text;
end;

procedure TMyLabel.SetCaption(const Value: string);
begin
  inherited Text := Value;
end;

procedure TMyLabel.SetWordWrap(const Value: boolean);
begin
  FWordWrap := Value;
  ReCreateWnd;
end;

end.
0
 

Author Comment

by:fadyg
ID: 2799379
Ok, great! now where do we stand with the points ? You both deserve them..

I've never dealt with 2 experts solving one problem. How is it usually solved guys?

anyway thanks to both of you.

Fady
0
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2799525
Raymond, you're the 'senior expert' !
What's the answer? :-)
0
 

Author Comment

by:fadyg
ID: 2810098
Hey guys, still alive ?
0
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2810431
I'm alive ! (well mostly :-))

Raymond?
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2815225
Fady: Well, its usually up to you! If you feel one expert solved the problem in the best way for you then you can reward that expert (regardless of whether another expert has posted an answer).

Alternatively, if you want to share points you need to create 'dummy' Q's with the appropriate point sharing for the experts you want to reward. You can then delete this Q to reclaim the points.

Cheers,

Raymond.
0
 

Author Comment

by:fadyg
ID: 2816236
I will Actually accept this one (after all it solved my problem) and ask another dummy question (50 pts) to Mullet Attack who helped me in a different way (I used his advice for another component)

thanks to both again
0
 
LVL 2

Expert Comment

by:mullet_attack
ID: 2817744
thanks!
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 2819050
Your welcome!

Raymond.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert Jpg /PNG To GIF 5 150
Unique identifier on a terminal server (rdp) 4 67
Dev express lookupcombo 3 34
firemonkey keyboard covers the controls 1 37
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question