Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

adding context help for labels ?

Posted on 2000-05-09
14
Medium Priority
?
188 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 400 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

916 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