|
|
1.1 ! root 1: /****************************** Module Header ******************************\ ! 2: * Module Name: options.c - Spy code for several options type dialogs. ! 3: * ! 4: * Created: Microsoft, IBM Corporation 1990 ! 5: * ! 6: \***************************************************************************/ ! 7: ! 8: #define INCL_WIN ! 9: #define INCL_WINSYS ! 10: #define INCL_DOSPROCESS ! 11: #include <os2.h> ! 12: #include <stdio.h> ! 13: #include <string.h> ! 14: #include "spy.h" ! 15: #include "spyhk32.h" ! 16: #include <time.h> ! 17: #include <stdlib.h> ! 18: ! 19: ! 20: ! 21: ! 22: /**************************** Public Function ******************************\ ! 23: * MRESULT EXPENTRY SpyOutputsDlgProc (hwnd, msg, mp1, mp2) ! 24: * ! 25: * Effects: Output Options dialog procedure ! 26: * ! 27: * ! 28: * Return value: ! 29: \***************************************************************************/ ! 30: MRESULT EXPENTRY SpyOutputsDlgProc(hwnd, msg, mp1, mp2) ! 31: HWND hwnd; ! 32: USHORT msg; ! 33: MPARAM mp1; ! 34: MPARAM mp2; ! 35: { ! 36: ULONG ulAction; ! 37: ! 38: switch (msg) { ! 39: ! 40: case WM_INITDLG: ! 41: /* ! 42: * Now initialize the output options in the dialog ! 43: */ ! 44: WinSendDlgItemMsg(hwnd, DID_WINDOW, BM_SETCHECK, ! 45: (MPARAM)spyopt.fWindow, 0L); ! 46: WinSendDlgItemMsg(hwnd, DID_DEBUG, BM_SETCHECK, ! 47: (MPARAM)spyopt.fDebugOutput, 0L); ! 48: WinSendDlgItemMsg(hwnd, DID_FILE, BM_SETCHECK, ! 49: (MPARAM)spyopt.fFile, 0L); ! 50: ! 51: WinSetDlgItemShort(hwnd, DID_WINDOWLINES, spyopt.cWindowLines, FALSE); ! 52: WinSetDlgItemText(hwnd, DID_FILENAME, spystr.szFileName); ! 53: ! 54: ! 55: break; ! 56: ! 57: case WM_COMMAND: ! 58: switch (SHORT1FROMMP(mp1)) { ! 59: case DID_OK: ! 60: ! 61: /* ! 62: * Now retrieve the output options from the ! 63: * dialog ! 64: */ ! 65: spyopt.fWindow = (BOOL)WinSendDlgItemMsg(hwnd, ! 66: DID_WINDOW, BM_QUERYCHECK, 0L, 0L); ! 67: spyopt.fDebugOutput = (BOOL)WinSendDlgItemMsg(hwnd, ! 68: DID_DEBUG, BM_QUERYCHECK, 0L, 0L); ! 69: spyopt.fFile = (BOOL)WinSendDlgItemMsg(hwnd, ! 70: DID_FILE, BM_QUERYCHECK, 0L, 0L); ! 71: ! 72: WinQueryDlgItemShort(hwnd, DID_WINDOWLINES, &spyopt.cWindowLines, FALSE); ! 73: WinQueryDlgItemText(hwnd, DID_FILENAME, ! 74: sizeof(spystr.szFileName), spystr.szFileName); ! 75: ! 76: /* ! 77: * Now take care of file operations ! 78: * If a file is already active, we will continue to use it, and ! 79: * ignore the case where the user may have changed file names ! 80: * Will truncate any file. ! 81: */ ! 82: if (spyopt.fFile) { ! 83: if (spyopt.hfileSpy == NULL) ! 84: if (DosOpen((PSZ)spystr.szFileName, &spyopt.hfileSpy, ! 85: &ulAction, 0L, 0, ! 86: 0x0012, 0x00C1, 0L) != 0) ! 87: spyopt.hfileSpy = NULL; /* Failed on open */ ! 88: } else { ! 89: if (spyopt.hfileSpy != NULL) { ! 90: /* file open, not outputing, close it now */ ! 91: DosClose (spyopt.hfileSpy); ! 92: spyopt.hfileSpy = NULL; ! 93: } ! 94: } ! 95: /* Fall through to DID_CANCEL */ ! 96: case DID_CANCEL: ! 97: /* Now dismiss the dialog */ ! 98: WinDismissDlg(hwnd, SHORT1FROMMP(mp1)); ! 99: break; ! 100: } ! 101: break; ! 102: ! 103: default: ! 104: return(WinDefDlgProc(hwnd, msg, mp1, mp2)); ! 105: break; ! 106: } ! 107: return 0L; ! 108: } ! 109: ! 110: ! 111: ! 112: ! 113: /**************************** Public Function ******************************\ ! 114: * MRESULT EXPENTRY SpySaveListDlgProc(hwnd, msg, mp1, mp2) ! 115: * ! 116: * Effects: The Spy Windows Dialog procedure ! 117: * ! 118: * Return value: none ! 119: \***************************************************************************/ ! 120: MRESULT EXPENTRY SpySaveListDlgProc(hwnd, msg, mp1, mp2) ! 121: HWND hwnd; ! 122: USHORT msg; ! 123: MPARAM mp1; ! 124: MPARAM mp2; ! 125: { ! 126: HFILE hfileOut; ! 127: char szTemp[100]; ! 128: char szTime[10]; ! 129: char szDate[10]; ! 130: SHORT cItems; ! 131: SHORT iItem; ! 132: ULONG cch; ! 133: ULONG cchWritten; ! 134: ULONG ulAction; ! 135: ULONG lTemp; ! 136: ! 137: switch (msg) { ! 138: ! 139: case WM_INITDLG: ! 140: WinSendDlgItemMsg(hwnd, DID_APPEND, BM_SETCHECK, ! 141: (MPARAM)spyopt.fAppend, 0L); ! 142: /* Initialize the dialog items */ ! 143: WinSetDlgItemText(hwnd, DID_FILENAME, spystr.szSaveFileName); ! 144: break; ! 145: ! 146: case WM_COMMAND: ! 147: switch (SHORT1FROMMP(mp1)) { ! 148: case DID_OK: ! 149: /* ! 150: * Get the file name, and try to open the file, ! 151: * Then loop through and dump the listbox contents to the ! 152: * file. ! 153: */ ! 154: spyopt.fAppend = (BOOL)WinSendDlgItemMsg(hwnd, ! 155: DID_APPEND, BM_QUERYCHECK, 0L, 0L); ! 156: ! 157: WinQueryDlgItemText(hwnd, DID_FILENAME, ! 158: sizeof(spystr.szSaveFileName), spystr.szSaveFileName); ! 159: ! 160: if (DosOpen((PSZ)spystr.szSaveFileName, &hfileOut, ! 161: &ulAction, 0L, 0, ! 162: spyopt.fAppend? 0x0011 : 0x0012, 0x00C1, 0L) == 0) { ! 163: ! 164: /* If append, get to the end of the file */ ! 165: if (spyopt.fAppend) ! 166: DosChgFilePtr(hfileOut, 0L, 2, (PULONG)&lTemp); ! 167: ! 168: /* Get count of items */ ! 169: cItems = (SHORT)WinSendMsg(hwndSpyList, LM_QUERYITEMCOUNT, ! 170: 0L, 0L); ! 171: ! 172: /* Write out a title block to the file */ ! 173: _strdate(szDate); ! 174: _strtime(szTime); ! 175: DosWrite(hfileOut, ! 176: (PSZ)"***************************************\r\n", ! 177: 41L, &cchWritten); ! 178: cch = sprintf(szTemp, "* Spy: %-10s %-10s *\r\n", ! 179: szDate, szTime); ! 180: DosWrite(hfileOut, (PSZ)szTemp, cch, &cchWritten); ! 181: ! 182: DosWrite(hfileOut, ! 183: (PSZ)"***************************************\r\n", ! 184: 41L, &cchWritten); ! 185: ! 186: ! 187: /* Now output the list to the file */ ! 188: for (iItem = 0; iItem < cItems; iItem++) { ! 189: cch = (SHORT)WinSendMsg(hwndSpyList, LM_QUERYITEMTEXT, ! 190: MPFROM2SHORT(iItem, sizeof(szTemp)), ! 191: (MPARAM)(PSZ)szTemp); ! 192: /* Add Newline at end of string */ ! 193: szTemp[cch++] = '\r'; ! 194: szTemp[cch++] = '\n'; ! 195: szTemp[cch] = '\0'; ! 196: DosWrite(hfileOut, (PSZ)szTemp, cch, ! 197: &cchWritten); ! 198: } ! 199: DosClose(hfileOut); ! 200: } ! 201: ! 202: case DID_CANCEL: ! 203: /* Now dismiss the dialog */ ! 204: WinDismissDlg(hwnd, SHORT1FROMMP(mp1)); ! 205: break; ! 206: break; ! 207: } ! 208: ! 209: default: ! 210: return(WinDefDlgProc(hwnd, msg, mp1, mp2)); ! 211: } ! 212: return 0L; ! 213: } ! 214: ! 215: ! 216: ! 217: ! 218: /**************************** Public Function *****************************\ ! 219: * AboutWndProc(HWND hwnd, USHORT message, MPARAM mp1, MPARAM mp2) ! 220: * ! 221: * Effects: About Spy Dialog procedure ! 222: * ! 223: * ! 224: * Return value: ! 225: \***************************************************************************/ ! 226: MRESULT EXPENTRY AboutWndProc(hwnd, message, mp1, mp2) ! 227: HWND hwnd; ! 228: USHORT message; ! 229: MPARAM mp1; ! 230: MPARAM mp2; ! 231: { ! 232: HPOINTER hptrO; ! 233: HPOINTER hptrN; ! 234: extern BOOL fV11; ! 235: ! 236: switch (message) { ! 237: case WM_COMMAND: ! 238: WinDismissDlg(hwnd, TRUE); ! 239: break; ! 240: ! 241: default: ! 242: return(WinDefDlgProc(hwnd, message, mp1, mp2)); ! 243: break; ! 244: } ! 245: return 0L; ! 246: ! 247: } /* end aboutwndproc */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.