Solved

adding context help for labels ?

Posted on 2000-05-09
14
181 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now