home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
NOTEPAD2.ZIP
/
MINIT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-02-08
|
2KB
|
82 lines
/*
* minit.c -- Essential MLE global initialization and instance initialization
*
* Created by Microsoft Corporation, 1989
*/
#define INCL_WIN
#include <os2.h>
#include "mtypes.h"
#include "mfuncs.h"
PSZ cdecl WC_MLE = "MLE Class";
/* exported function
*
* BOOL MleInit(HAB hab)
*
* Each process must call MleInit once before any MLE windows can be
* created. This function registers the MLE class, WC_MLE, with the
* system.
*/
BOOL EXPENTRY MleInit(HAB hab)
{
return(WinRegisterClass(hab,
WC_MLE,
MleWndProc,
CS_SIZEREDRAW | CS_SYNCPAINT,
sizeof(PED)));
}
/* public function
*
* BOOL InitInstance(HWND hwnd)
*
* Initialises an MLE window. Returns TRUE if the window could be initialized
* properly; FALSE otherwise.
*/
public VOID InitInstance(HWND hwnd)
{
ED NEAR *sped;
PED ped; // pointer to edit record
HHEAP hh; // heap for allocating edit structure
HWND hwndOwner; // owner of MLE
PVOID pHH;
// Send WM_CONTROLHEAP message to MLE's owner. Return the
// heap handle. Send the message to self if there is no owner (it
// will be handled by WinDefWindowProc).
hwndOwner = WinQueryWindow(hwnd, QW_OWNER, FALSE);
hh = (HHEAP)WinSendMsg(((hwndOwner == NULL) ? hwnd : hwndOwner),
WM_CONTROLHEAP, 0L, 0L);
// If we couldn't create the heap, bail out.
if (hh == NULL)
return;
// Create the edit record, initialize global parts of ped,
// and initialize other components.
if ((sped = (ED NEAR *)WinAllocMem(hh, sizeof(ED))) == NULL) {
return;
}
pHH = WinLockHeap(hh);
ped = (PED)MAKEP(SELECTOROF(pHH),sped);
WinSetWindowPtr(hwnd, QWP_PED, ped);
ped->hwnd = hwnd;
ped->idChild = WinQueryWindowUShort (hwnd, QWS_ID);
ped->flStyle = WinQueryWindowULong (hwnd, QWL_STYLE);
InitStore(ped);
TxtInit(ped);
KbdInit(ped);
MouseInit(ped);
DisplayInit(ped);
BufInit(ped);
}