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.