home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXTST8F.ZIP / EMX / TEST / PM1.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  2.3 KB  |  99 lines

  1. /* pm1.c (emx+gcc) */
  2.  
  3. #include <stdio.h>
  4. #define INCL_WIN
  5. #include <os2.h>
  6. #include "pm1.h"
  7.  
  8. /* Test exception handler */
  9.  
  10. static void crash (void)
  11. {
  12.   char *p;
  13.  
  14.   p = 0;
  15.   *p = 0;
  16. }
  17.  
  18.  
  19. #pragma linkage (ClientWndProc, system)         /* for ICC */
  20.  
  21. static MRESULT ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  22. {
  23.   HPS hps;
  24.   RECTL rcl;
  25.  
  26.   switch (msg)
  27.     {
  28.     case WM_PAINT:
  29.       hps = WinBeginPaint (hwnd, 0L, 0L);
  30.       /* GpiErase (hps); */
  31.       WinQueryWindowRect (hwnd, &rcl);
  32.       GpiSetColor (hps, CLR_DARKCYAN);
  33.       WinDrawText (hps, -1, "Hello, world!", &rcl, 0, 0,
  34.                    DT_TEXTATTRS | DT_CENTER | DT_VCENTER | DT_ERASERECT);
  35.       WinEndPaint (hps);
  36.       return (0);
  37.     case WM_COMMAND:
  38.       switch (SHORT1FROMMP (mp1))
  39.         {
  40.         case IDM_CRASH:
  41.           crash ();
  42.           return ((MRESULT)0);
  43.         case IDM_EXIT:
  44.           WinSendMsg (hwnd, WM_CLOSE, 0L, 0L);
  45.           return ((MRESULT)0);
  46.         }
  47.       break;
  48.     }
  49.   return (WinDefWindowProc (hwnd, msg, mp1, mp2));
  50. }
  51.  
  52.  
  53. int main (void)
  54. {
  55.   static ULONG flFrameFlags;
  56.   static char szClientClass[] = "pm1.child";
  57.   HAB hab;
  58.   HMQ hmq;
  59.   HWND hwndFrame;
  60.   QMSG qmsg;
  61.  
  62.   hab = WinInitialize (0) ;
  63.   hmq = WinCreateMsgQueue (hab, 0) ;
  64.  
  65.   WinRegisterClass (hab, szClientClass, ClientWndProc,
  66.                     CS_SIZEREDRAW, 0L);
  67.  
  68.   flFrameFlags = (FCF_TITLEBAR      | FCF_SYSMENU |
  69.                   FCF_SIZEBORDER    | FCF_MINMAX   |
  70.                   FCF_MENU          | FCF_ACCELTABLE |
  71.                   FCF_SHELLPOSITION | FCF_ICON |
  72.                   FCF_TASKLIST);
  73.  
  74.   hwndFrame = WinCreateStdWindow (
  75.                                   HWND_DESKTOP,
  76.                                   WS_VISIBLE,
  77.                                   &flFrameFlags,
  78.                                   szClientClass,
  79.                                   NULL,
  80.                                   0L,
  81.                                   0,
  82.                                   ID_PM1,
  83.                                   NULL) ;
  84.  
  85.   while (WinGetMsg (hab, &qmsg, 0L, 0, 0))
  86.     WinDispatchMsg (hab, &qmsg);
  87.  
  88.   WinDestroyWindow (hwndFrame);
  89.   WinDestroyMsgQueue (hmq);
  90.   WinTerminate (hab);
  91.   return (0);
  92. }
  93.  
  94. /*
  95.  * Local variables:
  96.  * compile-command: "make pm1.exe"
  97.  * end:
  98.  */
  99.