home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / os2 / programm / 3857 < prev    next >
Encoding:
Text File  |  1992-07-28  |  2.3 KB  |  89 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!darwin.sura.net!Sirius.dfn.de!chx400!bernina!neptune!ezeller
  3. From: ezeller@iiic.ethz.ch (Emil Johann Zeller)
  4. Subject: Problem with checkbox
  5. Message-ID: <1992Jul29.065258.19484@neptune.inf.ethz.ch>
  6. Sender: news@neptune.inf.ethz.ch (Mr News)
  7. Nntp-Posting-Host: c16
  8. Organization: Dept. Informatik, Swiss Federal Institute of Technology (ETH)
  9. Distribution: usa, local
  10. Date: Wed, 29 Jul 1992 06:52:58 GMT
  11. Lines: 76
  12.  
  13. #define INCL_WIN
  14. #include <os2.h>
  15.  
  16. MRESULT ClientWinProc(HWND, USHORT, MPARAM, MPARAM);
  17.  
  18. #define ID_BUTTON 1
  19. #define CWPM_CREATE WM_USER
  20.  
  21. main()
  22. {
  23.   HAB hab;
  24.   HMQ hmq;
  25.   QMSG qmsg;
  26.   HWND hwndFrame, hwndClient;
  27.  
  28.   ULONG flCreateFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
  29.                         FCF_MINMAX | FCF_SHELLPOSITION | FCF_TASKLIST;
  30.  
  31.   static CHAR szClientClass[] = "Client Messages";
  32.  
  33.   hab = WinInitialize(0);
  34.   hmq = WinCreateMsgQueue(hab, 0);
  35.  
  36.   WinRegisterClass(hab, szClientClass, ClientWinProc, CS_SIZEREDRAW, 0);
  37.  
  38.   hwndFrame = WinCreateStdWindow(HWND_DESKTOP, WS_VISIBLE, &flCreateFlags,
  39.             szClientClass, " - Controls", 0L, (HMODULE) NULL, 0, &hwndClient);
  40.  
  41.   while (WinGetMsg(hab, &qmsg, NULL, 0, 0))
  42.     WinDispatchMsg(hab, &qmsg);
  43.  
  44.   WinDestroyWindow(hwndFrame);
  45.   WinDestroyMsgQueue(hmq);
  46.   WinTerminate(hab);
  47.  
  48.   return 0;
  49. }
  50.  
  51. MRESULT ClientWinProc(HWND hwnd, USHORT msg, MPARAM mp1,
  52.            MPARAM mp2)
  53. {
  54.   HWND hwndControl;
  55.   RECTL rcl;
  56.   SHORT cx, cy;
  57.  
  58.   switch (msg)
  59.   {
  60.     case WM_CREATE:
  61.       WinPostMsg(hwnd, CWPM_CREATE, NULL, NULL);
  62.       return FALSE;
  63.       break;
  64.  
  65.     case CWPM_CREATE:
  66.       WinQueryWindowRect(hwnd, &rcl);
  67.       cx = (SHORT)((rcl.xRight - rcl.xLeft) / 2);
  68.       cy = (SHORT)((rcl.yTop -rcl.yBottom) / 2);
  69.       hwndControl = WinCreateWindow(hwnd, WC_BUTTON, "Beep on WM_PAINT", WS_VISIBLE | BS_AUTOCHECKBOX,
  70.                                     cx - 100, cy - 10, 200, 20, hwnd, HWND_TOP, ID_BUTTON, NULL, NULL);
  71.       break;
  72.  
  73.     case WM_PAINT:
  74.       if (SHORT1FROMMR(WinSendMsg(hwndControl, BM_QUERYCHECK, NULL, NULL))) WinAlarm(HWND_DESKTOP, WA_NOTE);
  75.       return(WinDefWindowProc(hwnd, msg, mp1, mp2));
  76.       break;
  77.  
  78.     case WM_ERASEBACKGROUND:
  79.       return TRUE;
  80.       break;
  81.  
  82.     default:
  83.       return(WinDefWindowProc(hwnd, msg, mp1, mp2));
  84.       break;
  85.   }
  86.  
  87.   return NULL;
  88. }
  89.