home *** CD-ROM | disk | FTP | other *** search
- {Activate the following define if you've created DEMOHELP.OBJ}
- { $DEFINE BoundInHelp}
-
- {$IFDEF BoundInHelp}
- {Context sensitive help available only if help is bound into application}
- {Activate the following define to try context-sensitive help}
- { $DEFINE ContextSensitive}
- {$ENDIF}
-
- {$R-,S-}
- program HelpDemo;
- uses
- Dos,
- TPDos,
- TPString,
- TPCrt,
- TPWindow,
- {$IFDEF UsingPickUnit}
- TPPick,
- {$ENDIF}
- TPHelp;
- var
- H : HelpPtr;
- Status : Word;
- I : Word;
- S : string;
- Ch : Char;
-
- {$IFDEF BoundInHelp}
- {$L demohelp.obj}
- procedure DemoHelp; external;
- {$ENDIF}
-
- procedure ActivateHelp;
- {-Cheap pick replacement}
- var
- Ch : Char;
- begin
- WriteLn('Choose help topic:');
- WriteLn(' 0. Quit, 1. Initializing, 2. Displaying, 3. Compiling, 4. Binding');
- repeat
- repeat
- Ch := readkey;
- until Ch in ['0'..'4'];
- if Ch <> '0' then
- if not ShowHelp(H, Ord(Ch)-Ord('0')) then
- Ch := '0';
- until Ch = '0';
- end;
-
- begin
- {$IFDEF BoundInHelp}
- Status := OpenHelpMem(@DemoHelp, 2, 2, 22, H);
- {$ELSE}
- Status := OpenHelpFile('DEMOHELP.HLP', 2, 2, 22, H);
- {$ENDIF}
- if Status <> 0 then begin
- case Status of
- 2 : WriteLn('Help file DEMOHELP.HLP not found');
- 100 : WriteLn('Unexpected end of file reading DEMOHELP.HLP');
- 106 : WriteLn('Help file has invalid format');
- 203 : WriteLn('Insufficient heap space available');
- else
- WriteLn('Help initialization error ', Status);
- end;
- Halt;
- end;
-
- {$IFDEF ContextSensitive}
-
- {Install context sensitive help - pop up with <F1>}
- SetContextHelp(H, $3B00);
-
- CurrentTopic := 1;
- WriteLn('Current topic "Initializing". Using CRT ReadLn, F1 for help');
- ReadLn(S);
-
- CurrentTopic := 2;
- WriteLn('Current topic "Displaying". Using ReadKey, F1 for help');
- Ch := readkey;
-
- CurrentTopic := 3;
- WriteLn('Current topic "Compiling". Using ReadKeyWord, F1 for help');
- I := readkeyword;
-
- CurrentTopic := 4;
- Assign(Output, '');
- Rewrite(Output);
- Assign(Input, '');
- Reset(Input);
- WriteLn('Current topic "Binding". Using DOS ReadLn, F1 for help');
- ReadLn(S);
-
- {$ELSE}
-
- {Not context-sensitive help}
- {$IFDEF UsingPickUnit}
- repeat
- I := PickHelp(H, 2, 2, 10, 1);
- if I <> 0 then
- if not ShowHelp(H, I) then
- WriteLn('error showing help ', status);
- until I = 0;
-
- {$ELSE}
- ActivateHelp;
- {$ENDIF}
- {$ENDIF}
-
- end.