Solved

adding context help for labels ?

Posted on 2000-05-09
14
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month11 days, 4 hours left to enroll

628 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