home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / os2sdk / os2sdk12 / mdi / appinit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-06  |  3.2 KB  |  129 lines

  1. /*
  2.     mdiinit.c - MDI initialization funtions.
  3.     Created by Microsoft Corporation, 1989
  4. */
  5. #define INCL_WINSYS
  6. #define INCL_WINCOMMON
  7. #define INCL_WINMESSAGEMGR
  8. #define INCL_WINPOINTERS
  9. #define INCL_WININPUT
  10. #define INCL_WINMENUS
  11. #define INCL_WINFRAMEMGR
  12. #define INCL_WINWINDOWMGR
  13. #define INCL_WINRECTANGLES
  14. #define INCL_WINHEAP
  15. #define INCL_GPIBITMAPS
  16. #define INCL_GPILCIDS
  17. #define INCL_DEV
  18.  
  19. #include <os2.h>
  20. #include "app.h"
  21. #include "appdata.h"
  22. #include "mdi.h"
  23. #include "mdidata.h"
  24.  
  25.  
  26. /* Function prototypes */
  27. BOOL RegisterWindowClasses(VOID);
  28. VOID InitSysValues(VOID);
  29.  
  30.  
  31. BOOL AppInit(VOID)
  32. {
  33.     ULONG ctlData;
  34.     HPS hps;
  35.     HDC hdc;
  36.  
  37.     hab = WinInitialize(0);
  38.  
  39.     hmqMDI = WinCreateMsgQueue(hab, 0);
  40.  
  41.     if (!RegisterWindowClasses())
  42.         return(FALSE);
  43.  
  44.     ctlData = FCF_TITLEBAR | FCF_MINMAX | FCF_SIZEBORDER | FCF_SYSMENU |
  45.               FCF_MENU | FCF_TASKLIST | FCF_SHELLPOSITION | FCF_ICON;
  46.  
  47.     hwndMDIFrame = WinCreateStdWindow(HWND_DESKTOP, WS_VISIBLE,
  48.             (VOID FAR *)&ctlData, szMDIClass, (PSZ)NULL,
  49.             WS_VISIBLE | WS_CLIPCHILDREN, NULL, IDR_MDI,
  50.             (HWND FAR *)&hwndMDI);
  51.  
  52.  
  53.     if (hwndMDIFrame == NULL)
  54.         return(FALSE);
  55.  
  56. /* MULTIPLEMENU */
  57.  
  58.     /* Remember the first menu so we can put it back when all the documents are
  59.        closed */
  60.     hwndFirstMenu=WinWindowFromID(hwndMDIFrame, FID_MENU);
  61.  
  62.     hHeap = WinCreateHeap(0, 0, 0, 0, 0, 0);
  63.  
  64.     if (hHeap == NULL)
  65.         return(FALSE);
  66.  
  67.     hps = WinGetPS(hwndMDI);
  68.  
  69.     hdc = GpiQueryDevice(hps);
  70.     DevQueryCaps(hdc, CAPS_FAMILY, CAPS_VERTICAL_FONT_RES, (PLONG)rglDevCaps);
  71.  
  72.     WinReleasePS(hps);
  73.  
  74.     InitSysValues();
  75.  
  76.     return(TRUE);
  77. }
  78.  
  79.  
  80. VOID InitSysValues(VOID)
  81. {
  82.     cyTitlebar = (SHORT)WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR);
  83.     cyIcon = (USHORT)WinQuerySysValue(HWND_DESKTOP, SV_CYICON);
  84.  
  85.     cxBorder = (USHORT)WinQuerySysValue(HWND_DESKTOP, SV_CXBORDER);
  86.     cyBorder = (USHORT)WinQuerySysValue(HWND_DESKTOP, SV_CYBORDER);
  87.  
  88.     cxSizeBorder = (USHORT)WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER);
  89.     cySizeBorder = (USHORT)WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);
  90.  
  91.     cxByteAlign = (USHORT)WinQuerySysValue(HWND_DESKTOP, SV_CXBYTEALIGN);
  92.     cyByteAlign = (USHORT)WinQuerySysValue(HWND_DESKTOP, SV_CYBYTEALIGN);
  93.  
  94.     cxVScroll = (USHORT)WinQuerySysValue(HWND_DESKTOP, SV_CYHSCROLL);
  95.     cyVScrollArrow = (USHORT)WinQuerySysValue(HWND_DESKTOP, SV_CYVSCROLLARROW);
  96.     cyHScroll = (USHORT)WinQuerySysValue(HWND_DESKTOP, SV_CXVSCROLL);
  97.  
  98.     cxScreen = (USHORT)WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
  99.     cyScreen = (USHORT)WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
  100.  
  101.     cxMinmaxButton = (USHORT)WinQuerySysValue(HWND_DESKTOP, SV_CXMINMAXBUTTON);
  102. }
  103.  
  104.  
  105. BOOL RegisterWindowClasses(VOID)
  106. {
  107.     if (!WinRegisterClass(NULL, szMDIClass, (PFNWP)MDIWndProc,
  108.             CS_SYNCPAINT, 0))
  109.         return(FALSE);
  110.  
  111.     if (!WinRegisterClass(NULL, szDocClass, (PFNWP)DocWndProc,
  112.             0L, sizeof(NPVIEW)))
  113.         return(FALSE);
  114.  
  115.     return(TRUE);
  116. }
  117.  
  118.  
  119. VOID AppTerminate(VOID)
  120. {
  121.     WinDestroyWindow(hwndMDIFrame);
  122.  
  123.     WinDestroyHeap(hHeap);
  124.  
  125.     WinDestroyMsgQueue(hmqMDI);
  126.  
  127.     WinTerminate(hab);
  128. }
  129.