home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / wp / ewdll.zip / MULHELP.C next >
C/C++ Source or Header  |  1993-07-09  |  4KB  |  113 lines

  1. /*------------------------------------------------
  2.    MULHELP.C -- Extension DLL for E! - version 1.0
  3.  
  4.    To compile: nmake /f mulhelp.mak
  5.  
  6.    Once compiled, copy MULHELP.EWD to your USER directory.
  7.  
  8.    MULHELP is a simple EWD allowing use of multiple help files from within
  9.    E!. There are many situations where you have to refer to multiple help
  10.    files. For example, when writing Visual C++ source code with E!, you may
  11.    want to refer to the Windows 3.1 SDK, the MFC 2.0 and the C/C++ language
  12.    help files. It would be nice to load one of this file at will when the
  13.    cursor is located on a keyword.
  14.  
  15.    With MULHELP you can.
  16.  
  17.    The first thing you have to do is to create a new section in EW.INI:
  18.    [extended help]. Then, list in that section the help files you want
  19.    to use, as follows:
  20.  
  21.    HelpName1=file1.hlp
  22.    HelpName2=file2.hlp
  23.    HelpName3=file3.hlp
  24.  
  25.    and so on...
  26.  
  27.    Second, you should load MULHELP from the User menu (you can also install
  28.    MULHELP as an autoloaded EWD). MULHELP.EWD must reside in your USER
  29.    diretectory. This step is not mandatory since EW always checks if an
  30.    Extension DLL is loaded when called from the User Menu or using a
  31.    keystroke assignment. If not, EW loads it beofre proceeding.
  32.  
  33.    Third, open the Keyboard Assignment dialog box, select "Assign DLL" and
  34.    MULHELP and assign MULHELP to, say, three different keystrokes, typing in
  35.    each time a different Routine Id in the RoutineId field (1 for HelpName1, 2
  36.    for HelpName2, ...).
  37.  
  38.    You may use any unsigned integer as a Routine Id as long as it reflects the
  39.    HelpName entry (e.g. HelpName20 will be used with Routine ID 20).
  40.  
  41.    For example, I have setup MULHELP for my personal needs as follows:
  42.  
  43.    [extended help]
  44.    HelpName1=win31wh.hlp
  45.    HelpName2=mfc.hlp
  46.    HelpName3=mscxx.hlp
  47.  
  48.    Key Assignments:
  49.  
  50.    MULHELP assigned to SHIFT+F1    with Routine Id 1
  51.    MULHELP assigned to ALT+F1      with Routine Id 2
  52.    MULHELP assigned to ALT+CTRL+F1 with Routine Id 3
  53.  
  54.    Now, when I hit SHIFT+F1 while the cursor is located on a keyword, EW opens
  55.    the Windows 3.1 SDK help file (this is the standard behavior of E!). When
  56.    I do the same with ALT+F1, EW opens the MFC help file with the same keyword.
  57.    Ditto for ALT+CTRL+F1 with the C/C++ language help file.
  58.  
  59.    It's important to make SHIFT+F1 participate in this process because it is
  60.    the default key for alternate help. Since MULHELP modifies the "alternatehelp"
  61.    entry in ew.ini, it is preferable to keep SHIFT+F1 tied to the default
  62.    alternate help file.
  63.  
  64.    Enjoy!
  65.  
  66.    Patrick Philippot
  67.    07/08/93
  68.   ------------------------------------------------*/
  69.  
  70. #include <windows.h>
  71. #include "ewapi.h"
  72. #include <stdlib.h>
  73. #include <string.h>
  74.  
  75. int FAR PASCAL LibMain (HANDLE hInstance, WORD wDataSeg, WORD wHeapSize,
  76.                         LPSTR lpszCmdLine)
  77. {
  78.   if (wHeapSize > 0)
  79.     UnlockData (0) ;
  80.   return 1 ;
  81. }
  82.  
  83.   char HelpEntry[] = "HelpName";
  84.   char HelpSection[] = "Extended Help";
  85.   char Profile[] = "ew.ini";
  86.  
  87. int FAR PASCAL EWExecute(unsigned int RoutineId)
  88. {
  89.   char EntryValue[80];
  90.   char IDStr[6];
  91.   char HelpCurEntry[15];
  92.   long CaretPos;
  93.  
  94.   _itoa(RoutineId, IDStr, 10);
  95.   _fstrcat(_fstrcpy(HelpCurEntry, HelpEntry), IDStr);
  96.   if (GetPrivateProfileString(HelpSection,
  97.                               HelpCurEntry,
  98.                               "",
  99.                               EntryValue,
  100.                               sizeof(EntryValue),
  101.                               Profile) != 0)
  102.   {
  103.     WritePrivateProfileString("system", "alternatehelp", EntryValue, Profile);
  104.     CaretPos = EWGetCaretPos();
  105.     return (EWAlternateHelp(LOWORD(CaretPos), HIWORD(CaretPos)));
  106.   }
  107.   else
  108.   {
  109.     MessageBox(GetFocus(), "No such Entry.", HelpSection, MB_ICONEXCLAMATION);
  110.     return(0);
  111.   }
  112. }
  113.