home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / NOTEPAD2.ZIP / MINIT.C < prev    next >
C/C++ Source or Header  |  1989-02-08  |  2KB  |  82 lines

  1. /*
  2.  * minit.c -- Essential MLE global initialization and instance initialization
  3.  *
  4.  * Created by Microsoft Corporation, 1989
  5.  */
  6.  
  7. #define INCL_WIN
  8. #include <os2.h>
  9. #include "mtypes.h"
  10. #include "mfuncs.h"
  11.  
  12. PSZ cdecl WC_MLE = "MLE Class";
  13.  
  14. /* exported function
  15.  *
  16.  * BOOL MleInit(HAB hab)
  17.  *
  18.  * Each process must call MleInit once before any MLE windows can be
  19.  * created.  This function registers the MLE class, WC_MLE, with the
  20.  * system.
  21.  */
  22. BOOL EXPENTRY MleInit(HAB hab)
  23. {
  24.         return(WinRegisterClass(hab,
  25.                         WC_MLE,
  26.                         MleWndProc,
  27.                         CS_SIZEREDRAW | CS_SYNCPAINT,
  28.                         sizeof(PED)));
  29. }
  30.  
  31. /* public function
  32.  *
  33.  * BOOL InitInstance(HWND hwnd)
  34.  *
  35.  * Initialises an MLE window.  Returns TRUE if the window could be initialized
  36.  * properly; FALSE otherwise.
  37.  */
  38.  
  39. public VOID InitInstance(HWND hwnd)
  40. {
  41.     ED NEAR *sped;
  42.     PED ped;            // pointer to edit record
  43.     HHEAP hh;           // heap for allocating edit structure
  44.     HWND hwndOwner;     // owner of MLE
  45.     PVOID pHH;
  46.  
  47.     // Send WM_CONTROLHEAP message to MLE's owner.  Return the
  48.     // heap handle.  Send the message to self if there is no owner (it
  49.     // will be handled by WinDefWindowProc).
  50.  
  51.     hwndOwner = WinQueryWindow(hwnd, QW_OWNER, FALSE);
  52.     hh = (HHEAP)WinSendMsg(((hwndOwner == NULL) ? hwnd : hwndOwner),
  53.             WM_CONTROLHEAP, 0L, 0L);
  54.  
  55.     // If we couldn't create the heap, bail out.
  56.  
  57.     if (hh == NULL)
  58.         return;
  59.  
  60.     // Create the edit record, initialize global parts of ped,
  61.     // and initialize other components.
  62.  
  63.     if ((sped = (ED NEAR *)WinAllocMem(hh, sizeof(ED))) == NULL) {
  64.         return;
  65.     }
  66.     pHH = WinLockHeap(hh);
  67.     ped = (PED)MAKEP(SELECTOROF(pHH),sped);
  68.  
  69.     WinSetWindowPtr(hwnd, QWP_PED, ped);
  70.  
  71.     ped->hwnd = hwnd;
  72.     ped->idChild = WinQueryWindowUShort (hwnd, QWS_ID);
  73.     ped->flStyle = WinQueryWindowULong (hwnd, QWL_STYLE);
  74.  
  75.     InitStore(ped);
  76.     TxtInit(ped);
  77.     KbdInit(ped);
  78.     MouseInit(ped);
  79.     DisplayInit(ped);
  80.     BufInit(ped);
  81. }
  82.