Annotation of pmsdk/samples/btntest/btntest.c, revision 1.1

1.1     ! root        1: /*      btntest.c  - List box control test application          */
        !             2: /*      Created by Microsoft Corp., 1988                        */
        !             3: /*                                                              */
        !             4: 
        !             5: #define  INCL_PM
        !             6: #include <os2.h>
        !             7: #include "btntest.h"
        !             8: 
        !             9: /************* GLOBAL VARIABLES         */
        !            10: 
        !            11: char szBtntestClass[] = "Btntest";
        !            12: char szAppName[] = "Btntest Application";
        !            13: 
        !            14: HAB    habBtntest;
        !            15: HMQ    hmqBtntest;
        !            16: HWND   hwndBtntest;
        !            17: HWND   hwndBtntestFrame;
        !            18: 
        !            19: INT fOwnerDraw;
        !            20: INT cyText;
        !            21: 
        !            22: void FAR PASCAL WinExitWindows(PCH);
        !            23: 
        !            24: /************* PROCEDURE DECLARATIONS   */
        !            25: 
        !            26: MRESULT FAR PASCAL BtnDlgProc(HWND, USHORT, MPARAM, MPARAM);
        !            27: MRESULT FAR PASCAL StyleDlgProc(HWND, USHORT, MPARAM, MPARAM);
        !            28: 
        !            29: 
        !            30: BOOL BtntestInit()
        !            31: {
        !            32:     /*
        !            33:      * Initialize the HAB
        !            34:      * (just usSet to -1L for now until we get WinInitialize()
        !            35:      */
        !            36:     habBtntest = WinInitialize(NULL);
        !            37:     hmqBtntest = WinCreateMsgQueue(habBtntest, 0);
        !            38: 
        !            39:     return(TRUE);
        !            40: }
        !            41: 
        !            42: int cdecl main(argc, argv)
        !            43: int argc;
        !            44: char *argv[];
        !            45: {
        !            46:     QMSG qmsg;
        !            47:     USHORT wResult;
        !            48:     WRECT rc;
        !            49: 
        !            50:     if (!BtntestInit())
        !            51:         return(0);
        !            52: 
        !            53:     wResult = WinDlgBox(HWND_DESKTOP, (HWND)NULL, (PFNWP)BtnDlgProc, 
        !            54:             (HMODULE)NULL, IDD_BTNTEST, (PCH)NULL);
        !            55: 
        !            56:     WinDestroyMsgQueue(hmqBtntest);
        !            57: 
        !            58:     WinTerminate(habBtntest);
        !            59:     DosExit(EXIT_PROCESS, 0);
        !            60: }
        !            61: 
        !            62: USHORT seed;
        !            63: INT   cPushed;
        !            64: 
        !            65: MRESULT FAR PASCAL BtnDlgProc(hwnd, msg, mp1, mp2)
        !            66: HWND hwnd;
        !            67: USHORT msg;
        !            68: MPARAM mp1;
        !            69: MPARAM mp2;
        !            70: {
        !            71:     HWND hwnd1, hwnd2;
        !            72:     CHAR rgch[256];
        !            73:     ULONG flStyle;
        !            74:     BOOL fParse;
        !            75:     HPS hps;
        !            76:     INT result;
        !            77:     ULONG lseed;
        !            78:     WRECT rc;
        !            79: 
        !            80:     hwnd2 = WinWindowFromID(hwnd, 11);      /* Input/output edit control */
        !            81:     hwnd1 = WinWindowFromID(hwnd, 10);      /* button control */
        !            82: 
        !            83:     switch (msg) {
        !            84:     case WM_COMMAND:
        !            85:         switch (LOUSHORT(mp1)) {
        !            86:         case DID_OK:
        !            87:             WinDismissDlg(hwnd, 1234);
        !            88:             break;
        !            89:         case 14: /* click */
        !            90:             WinSendMsg(hwnd1, BM_CLICK, (MPARAM)TRUE, 0L);
        !            91:             break;
        !            92:         case 15: /* querycheckindex */
        !            93:             result = (INT)WinSendMsg(hwnd1, BM_QUERYCHECKINDEX, 0L, 0L);
        !            94:             WinSetDlgItemShort(hwnd, 31, result, TRUE);
        !            95:             break;
        !            96:         case 16: /* queryhilite */
        !            97:             result = (INT)WinSendMsg(hwnd1, BM_QUERYHILITE, 0L, 0L);
        !            98:             WinSetDlgItemShort(hwnd, 31, result, TRUE);
        !            99:             break;
        !           100:         case 17: /* sethilite */
        !           101:             WinQueryDlgItemShort(hwnd, 31, (PSHORT)&result, FALSE);
        !           102:             WinSendMsg(hwnd1, BM_SETHILITE, (MPARAM)result, 0L);
        !           103:             break;
        !           104:         case 18: /* querycheck */
        !           105:             result = (INT)WinSendMsg(hwnd1, BM_QUERYCHECK, 0L, 0L);
        !           106:             WinSetDlgItemShort(hwnd, 31, result, TRUE);
        !           107:             break;
        !           108:         case 19: /* setcheck */
        !           109:             WinQueryDlgItemShort(hwnd, 31, (PSHORT)&result, FALSE);
        !           110:             WinSendMsg(hwnd1, BM_SETCHECK, (MPARAM)result, 0L);
        !           111:             break;
        !           112:         case 20: /* querydlgcode */
        !           113:             result = (INT)WinSendMsg(hwnd1, WM_QUERYDLGCODE, 0L, 0L);
        !           114:             WinSetDlgItemShort(hwnd, 31, result, TRUE);
        !           115:             break;
        !           116:         case 21: /* querytext */
        !           117:             result = WinQueryWindowText(hwnd1, 255, (PSZ)rgch);
        !           118:             WinSetWindowText(hwnd2, (PSZ)rgch);
        !           119:             WinSetDlgItemShort(hwnd, 31, result, TRUE);
        !           120:             break;
        !           121:         case 22: /* querytextlength */
        !           122:             result = WinQueryWindowTextLength(hwnd1);
        !           123:             WinSetDlgItemShort(hwnd, 31, result, TRUE);
        !           124:             break;
        !           125:         case 23: /* settext */
        !           126:             result = WinQueryWindowText(hwnd2, 255, (PSZ)rgch);
        !           127:             result = WinSetWindowText(hwnd1, (PSZ)rgch);
        !           128:             WinSetDlgItemShort(hwnd, 31, result, TRUE);
        !           129:             break;
        !           130:         case 25: /* Change flStyle */
        !           131:             flStyle = WinQueryWindowULong(hwnd1, QWL_STYLE);
        !           132:             result = WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)StyleDlgProc, 
        !           133:                                                 (HMODULE)NULL, 2, (PCH)&flStyle);
        !           134:             flStyle = (flStyle & 0xffff0000) + result;
        !           135: 
        !           136:             if (WinSendDlgItemMsg(hwnd, 26, BM_QUERYCHECK, 0L, 0L))
        !           137:                 flStyle |= BS_HELP;
        !           138:             if (WinSendDlgItemMsg(hwnd, 27, BM_QUERYCHECK, 0L, 0L))
        !           139:                 flStyle |= BS_NOPOINTERFOCUS;
        !           140:             if (WinSendDlgItemMsg(hwnd, 28, BM_QUERYCHECK, 0L, 0L))
        !           141:                 flStyle |= BS_NOBORDER;
        !           142: 
        !           143:             WinSetWindowULong(hwnd1, QWL_STYLE, flStyle);
        !           144:             WinInvalidateRect(hwnd1, (PWRECT)NULL, TRUE);
        !           145:             break;
        !           146:         default:
        !           147:             break;
        !           148:         }
        !           149:         break;
        !           150:     case WM_CONTROL:
        !           151:         switch(LOUSHORT(mp1)) {
        !           152:         case 10:
        !           153:             WinSetDlgItemShort(hwnd, 33, HIUSHORT(mp1), FALSE);
        !           154:             switch (HIUSHORT(mp1)) {
        !           155:             case BN_CLICKED:
        !           156:                 break;
        !           157:             case BN_PAINT:
        !           158:                 WinQueryWindowRect(hwnd1, (PRECTL)&rc);
        !           159:                 seed = ((seed * 23) + 15) & 0xffff;
        !           160:                 lseed = -(long)(seed % SYSCLR_CSYSCOLORS + 10);
        !           161:                 hps = WinGetPS(hwnd1);
        !           162:                 WinFillRect(hps, (PRECTL)&rc, lseed);
        !           163:                 WinReleasePS(hps);
        !           164:                 break;
        !           165:             default:
        !           166:                 break;
        !           167:             }
        !           168:             break;
        !           169:         case 24:
        !           170:             fParse = (BOOL)WinSendMsg(WinWindowFromID(hwnd, 24), BM_QUERYCHECK,
        !           171:                     0L, 0L);
        !           172:             WinEnableWindow(hwnd1, !fParse);
        !           173:             break;
        !           174:         case 26:
        !           175:             fParse = (BOOL)WinSendDlgItemMsg(hwnd, 26, BM_QUERYCHECK, 0L, 0L);
        !           176:             flStyle = WinQueryWindowULong(hwnd1, QWL_STYLE);
        !           177:             if (fParse)
        !           178:                 flStyle |= BS_HELP;
        !           179:             else
        !           180:                 flStyle &= ~BS_HELP;
        !           181:             WinSetWindowULong(hwnd1, QWL_STYLE, flStyle);
        !           182:             WinInvalidateRect(hwnd1, (PWRECT)NULL, TRUE);
        !           183:             break;
        !           184:         case 27:
        !           185:             fParse = (BOOL)WinSendDlgItemMsg(hwnd, 27, BM_QUERYCHECK, 0L, 0L);
        !           186:             flStyle = WinQueryWindowULong(hwnd1, QWL_STYLE);
        !           187:             if (fParse)
        !           188:                 flStyle |= BS_NOPOINTERFOCUS;
        !           189:             else
        !           190:                 flStyle &= ~BS_NOPOINTERFOCUS;
        !           191:             WinSetWindowULong(hwnd1, QWL_STYLE, flStyle);
        !           192:             break;
        !           193:         case 28:
        !           194:             fParse = (BOOL)WinSendDlgItemMsg(hwnd, 28, BM_QUERYCHECK, 0L, 0L);
        !           195:             flStyle = WinQueryWindowULong(hwnd1, QWL_STYLE);
        !           196:             if (fParse)
        !           197:                 flStyle |= BS_NOBORDER;
        !           198:             else
        !           199:                 flStyle &= ~BS_NOBORDER;
        !           200:             WinSetWindowULong(hwnd1, QWL_STYLE, flStyle);
        !           201:             WinInvalidateRect(hwnd1, (PWRECT)NULL, TRUE);
        !           202:             break;
        !           203:         }
        !           204:         break;
        !           205:     case WM_INITDLG:
        !           206:         /* Set up user button redraws */
        !           207:         seed = 12345;
        !           208:         cPushed = 0;
        !           209:         WinSetFocus(HWND_DESKTOP, hwnd1);
        !           210:         return((ULONG)TRUE);
        !           211:         break;
        !           212:     default:
        !           213:         return(WinDefDlgProc(hwnd, msg, mp1, mp2));
        !           214:         break;
        !           215:     }
        !           216:     return 0L;
        !           217: }
        !           218: 
        !           219: MRESULT FAR PASCAL StyleDlgProc(hwnd, msg, mp1, mp2)
        !           220: HWND hwnd;
        !           221: USHORT msg;
        !           222: MPARAM mp1;
        !           223: MPARAM mp2;
        !           224: {
        !           225:     ULONG flStyle;
        !           226:     INT result;
        !           227: 
        !           228:     switch (msg) {
        !           229:     case WM_COMMAND:
        !           230:         if (LOUSHORT(mp1) == DID_OK) {
        !           231:             result = (INT)WinSendDlgItemMsg(hwnd, 3, BM_QUERYCHECKINDEX, 0L, 0L);
        !           232:             WinDismissDlg(hwnd, result);
        !           233:         }
        !           234:         break;
        !           235:     case WM_INITDLG:
        !           236:         flStyle = *((ULONG FAR *)mp2);
        !           237:         WinSendDlgItemMsg(hwnd, 3 + LOUSHORT(flStyle), BM_SETCHECK,
        !           238:                 (MPARAM)TRUE, 0L);
        !           239:         break;
        !           240:     default:
        !           241:         return(WinDefDlgProc(hwnd, msg, mp1, mp2));
        !           242:         break;
        !           243:     }
        !           244:     return (FALSE);
        !           245: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.