home *** CD-ROM | disk | FTP | other *** search
/ Windoware / WINDOWARE_1_6.iso / source / wzun11sr / winit.c < prev    next >
C/C++ Source or Header  |  1991-11-24  |  3KB  |  77 lines

  1. #include <windows.h>    /* required for all Windows applications */
  2. #include <assert.h>    /* required for all Windows applications */
  3. #include "wizunzip.h"                /* specific to this program              */
  4.  
  5. long FAR PASCAL WizUnzipWndProc(HWND, unsigned, WORD, LONG);
  6.  
  7. /****************************************************************************
  8.  
  9.     FUNCTION: WizUnzipInit(HANDLE)
  10.  
  11.     PURPOSE: Initializes window data and registers window class
  12.  
  13.     COMMENTS:
  14.  
  15.         Sets up a structure to register the window class.  Structure includes
  16.         such information as what function will process messages, what cursor
  17.         and icon to use, etc.
  18.  
  19.         This provides an example of how to allocate local memory using the
  20.         LocalAlloc() call instead of malloc().  This provides a handle to
  21.         memory.  When you actually need the memory, LocalLock() is called
  22.         which returns a pointer.  As soon as you are done processing the
  23.         memory, call LocalUnlock so that Windows can move the memory as
  24.         needed.  Call LocalLock() to get a pointer again, or LocalFree() if
  25.         you don't need the memory again.
  26.  
  27.  
  28. ****************************************************************************/
  29. BOOL WizUnzipInit(HANDLE hInstance)
  30. {
  31.     HANDLE hMemory;                            /* handle to allocated memory */
  32.     PWNDCLASS pWndClass;                       /* structure pointer          */
  33.  
  34.     hMemory = LocalAlloc(LMEM_MOVEABLE, sizeof(WNDCLASS));
  35.     assert(hMemory);    /* DEBUG */
  36.     pWndClass = (PWNDCLASS) LocalLock(hMemory);
  37.  
  38.     pWndClass->style = CS_HREDRAW | CS_VREDRAW;
  39.     pWndClass->lpfnWndProc = WizUnzipWndProc;
  40.     pWndClass->hInstance = hInstance;
  41.     pWndClass->hIcon = LoadIcon(hInstance, "WizUnzip");
  42.     pWndClass->hCursor = LoadCursor(NULL, IDC_ARROW);
  43.     pWndClass->hbrBackground = BG_SYS_COLOR+1; /* set background color */
  44.     pWndClass->lpszMenuName = (LPSTR) "WizUnzip";
  45.     pWndClass->lpszClassName = (LPSTR) szAppName;
  46.     pWndClass->cbClsExtra     = 0;
  47.     pWndClass->cbWndExtra     = 0;
  48.  
  49.  
  50.     if (!RegisterClass(pWndClass))
  51.     {
  52.         LocalUnlock(hMemory);                           /* Unlocks the memory    */
  53.         LocalFree(hMemory);                             /* Returns it to Windows */
  54.     return(FALSE);
  55.     }
  56.     /* define status class
  57.       */
  58.     pWndClass->lpszClassName = (LPSTR) szStatusClass;
  59.    pWndClass->style = CS_HREDRAW | CS_VREDRAW;
  60.     pWndClass->lpfnWndProc = StatusProc;
  61.     pWndClass->hInstance = hInstance;
  62.     pWndClass->hIcon = NULL;
  63.     pWndClass->hCursor = LoadCursor(NULL, IDC_ARROW);
  64.     pWndClass->hbrBackground = GetStockObject(WHITE_BRUSH);
  65.     pWndClass->lpszMenuName = NULL;
  66.     if (!RegisterClass(pWndClass))
  67.     {
  68.         LocalUnlock(hMemory);                           /* Unlocks the memory    */
  69.         LocalFree(hMemory);                             /* Returns it to Windows */
  70.     return(FALSE);
  71.     }
  72.     LocalUnlock(hMemory);                           /* Unlocks the memory    */
  73.     LocalFree(hMemory);                             /* Returns it to Windows */
  74.    return (TRUE);           /* Returns result of registering the window */
  75. }
  76.  
  77.