home *** CD-ROM | disk | FTP | other *** search
/ Inside Multimedia 1995 July / IMM0795.ISO / share / os2 / pmfract / src / init.c < prev    next >
C/C++ Source or Header  |  1994-01-24  |  2KB  |  51 lines

  1. /***************************************************************************\
  2. * INIT.C -- Library initialization funcitons
  3. * Created by Microsoft Corporation, 1989
  4. \***************************************************************************/
  5.  
  6. #include "tool.h"
  7. /****************************************************************************\
  8. * This function initializes the file dialog library (by loading strings).
  9. *
  10. * Note: Initialization will fail if CCHSTRINGSMAX is smaller than the
  11. *       space taken up by all strings in the .rc file.  Fix by increasing
  12. *       CCHSTRINGSMAX in wintool.h and maybe also the initial heap size
  13. *       in wintool.def.
  14. *
  15. * Returns:
  16. *   TRUE if initialization successful
  17. *   FALSE otherwise
  18. \***************************************************************************/
  19.  
  20. BOOL PASCAL InitLibrary()
  21. {
  22.     int i;
  23.     int cch;
  24.     PSTR pch;
  25.     PSTR pmem;
  26.     int cchRemaining;
  27.  
  28.     /* allocate memory for strings */
  29.     if (!(pch = (pmem = WinAllocMem(vhheap, cchRemaining = CCHSTRINGSMAX))))
  30.         return FALSE;
  31.  
  32.     /* load strings from resource file */
  33.     for (i = 0; i < CSTRINGS; i++) {
  34.         cch = 1 + WinLoadString(HABX, vhModule, i, cchRemaining, (PSZ)pch);
  35.         if (cch < 2)
  36.             /* loadstring failed */
  37.             return FALSE;
  38.         vrgsz[i] = pch;
  39.         pch += cch;
  40.  
  41.         if ((cchRemaining -= cch) <= 0)
  42.             /* ran out of space */
  43.             return FALSE;
  44.     }
  45.  
  46.     /* reallocate string space to size actually needed */
  47.     WinReallocMem(vhheap, pmem, CCHSTRINGSMAX, CCHSTRINGSMAX - cchRemaining);
  48.  
  49.     return TRUE;
  50. }
  51.