Visit our Sponsor   Visit our Sponsor
delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
498 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi



Loremo - the 1.5 liter car coming in 2009




Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (0)


Simple context-sensitive helpFormat this article printer-friendly!Bookmark function is only available for registered users!
How to implement an easy context-sensitive help
Product:
Delphi all versions
Category:
GUI
Skill Level:
Scoring:
Last Update:
04/10/2002
Search Keys:
delphi delphi3000 article borland vcl code-snippet Help context-sensitive helpsystem
Times Scored:
2
Visits:
2633
Uploader: Herman van der Hoek
Company:
Reference: N/A
 
Question/Problem/Abstract:
I am creating a not so big application and I want to give the users a context-sensitive help without creating a big windows helpsystem or using all kind of tools
Answer:



Most of the times it’s overkill to use tools to create a real Windows-Helpsystem for smaller applications. However, often you’d like to give the user some help besides a printed manual.
Here is a small example of the way I do it:

Create a new application with 2 forms. The second form will be the Help-form in this example. On the second form is a RichEdit-control called “RedHelp” with the ReadOnly-property on True and the OnKeyUp-event of  RedHelp is implemented as follows:

procedure TForm2.redHelpKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  if key = VK_ESCAPE then close;
end;

For the first form I set the KeyPreview-property on True and I placed three components on the form as example.
Of course there are other ways and more sofisticated ways to do this, but I wanted to keep it simple.
The complete code of Unit1 is here below:

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Memo1: TMemo;
    RadioGroup1: TRadioGroup;
    procedure FormKeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.DFM}

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var dir, s, HelpFile : string;
begin
  if key = VK_F1 then                                       //if a F1 is pressed
  begin
    s := Form1.ActiveControl.Name;                //look which control is active
    if s = '' then                //when e.g. an item off a RadioGroup is active
      s := Form1.ActiveControl.Parent.Name;
    if s = '' then s := Application.ExeName;              //always get something

    dir := ExtractFilePath(Application.ExeName);//get the applications-directory
    HelpFile := format('%s%s.rtf',[dir, s]);        //make the complete filename
    if FileExists(HelpFile) then                       //if it's exists, load it
    begin
      Form2.redHelp.Lines.LoadFromFile(HelpFile);
      Form2.Show;
    end else                                      //if it's not there, create it
    begin
      Form2.redHelp.Lines.Clear;
      Form2.redHelp.Lines.Add(format('Help for %s-control', [s]));
      Form2.redHelp.Lines.Add('Add your helptext here');
      Form2.redHelp.Lines.SaveToFile(HelpFile);
    end;
  end;
end;

end.





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment













 
Sign up to consume product discounts for Bronze memberships !

read more


  Visit our Sponsor

 

  Community Ad of
Peganza
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)