File:  [OS/2 SDKs] / pmsdk / samples / opendlg / init.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:28:16 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: pmsdk-1989, HEAD
Microsoft OS/2 SDK PM 02-24-1989

/***************************************************************************\
* INIT.C -- Library initialization funcitons
* Created by Microsoft Corporation, 1989
\***************************************************************************/

#include "tool.h"
/****************************************************************************\
* This function initializes the file dialog library (by loading strings).
*
* Note: Initialization will fail if CCHSTRINGSMAX is smaller than the
*       space taken up by all strings in the .rc file.  Fix by increasing
*       CCHSTRINGSMAX in wintool.h and maybe also the initial heap size
*       in wintool.def.
*
* Returns:
*   TRUE if initialization successful
*   FALSE otherwise
\***************************************************************************/

BOOL PASCAL InitLibrary()
{
    int i;
    int cch;
    PSTR pch;
    PSTR pmem;
    int cchRemaining;

    /* allocate memory for strings */
    if (!(pch = (pmem = WinAllocMem(vhheap, cchRemaining = CCHSTRINGSMAX))))
        return FALSE;

    /* load strings from resource file */
    for (i = 0; i < CSTRINGS; i++) {
        cch = 1 + WinLoadString(HABX, vhModule, i, cchRemaining, (PSZ)pch);
        if (cch < 2)
            /* loadstring failed */
            return FALSE;
        vrgsz[i] = pch;
        pch += cch;

        if ((cchRemaining -= cch) <= 0)
            /* ran out of space */
            return FALSE;
    }

    /* reallocate string space to size actually needed */
    WinReallocMem(vhheap, pmem, CCHSTRINGSMAX, CCHSTRINGSMAX - cchRemaining);

    return TRUE;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.