|
|
Microsoft OS/2 SDK 2.0 05-30-1990
/****************************** Module Header ******************************\
* Module Name: options.c - Spy code for several options type dialogs.
*
* Created: Microsoft, IBM Corporation 1990
*
\***************************************************************************/
#define INCL_WIN
#define INCL_WINSYS
#define INCL_DOSPROCESS
#include <os2.h>
#include <stdio.h>
#include <string.h>
#include "spy.h"
#include "spyhk32.h"
#include <time.h>
#include <stdlib.h>
/**************************** Public Function ******************************\
* MRESULT EXPENTRY SpyOutputsDlgProc (hwnd, msg, mp1, mp2)
*
* Effects: Output Options dialog procedure
*
*
* Return value:
\***************************************************************************/
MRESULT EXPENTRY SpyOutputsDlgProc(hwnd, msg, mp1, mp2)
HWND hwnd;
USHORT msg;
MPARAM mp1;
MPARAM mp2;
{
ULONG ulAction;
switch (msg) {
case WM_INITDLG:
/*
* Now initialize the output options in the dialog
*/
WinSendDlgItemMsg(hwnd, DID_WINDOW, BM_SETCHECK,
(MPARAM)spyopt.fWindow, 0L);
WinSendDlgItemMsg(hwnd, DID_DEBUG, BM_SETCHECK,
(MPARAM)spyopt.fDebugOutput, 0L);
WinSendDlgItemMsg(hwnd, DID_FILE, BM_SETCHECK,
(MPARAM)spyopt.fFile, 0L);
WinSetDlgItemShort(hwnd, DID_WINDOWLINES, spyopt.cWindowLines, FALSE);
WinSetDlgItemText(hwnd, DID_FILENAME, spystr.szFileName);
break;
case WM_COMMAND:
switch (SHORT1FROMMP(mp1)) {
case DID_OK:
/*
* Now retrieve the output options from the
* dialog
*/
spyopt.fWindow = (BOOL)WinSendDlgItemMsg(hwnd,
DID_WINDOW, BM_QUERYCHECK, 0L, 0L);
spyopt.fDebugOutput = (BOOL)WinSendDlgItemMsg(hwnd,
DID_DEBUG, BM_QUERYCHECK, 0L, 0L);
spyopt.fFile = (BOOL)WinSendDlgItemMsg(hwnd,
DID_FILE, BM_QUERYCHECK, 0L, 0L);
WinQueryDlgItemShort(hwnd, DID_WINDOWLINES, &spyopt.cWindowLines, FALSE);
WinQueryDlgItemText(hwnd, DID_FILENAME,
sizeof(spystr.szFileName), spystr.szFileName);
/*
* Now take care of file operations
* If a file is already active, we will continue to use it, and
* ignore the case where the user may have changed file names
* Will truncate any file.
*/
if (spyopt.fFile) {
if (spyopt.hfileSpy == NULL)
if (DosOpen((PSZ)spystr.szFileName, &spyopt.hfileSpy,
&ulAction, 0L, 0,
0x0012, 0x00C1, 0L) != 0)
spyopt.hfileSpy = NULL; /* Failed on open */
} else {
if (spyopt.hfileSpy != NULL) {
/* file open, not outputing, close it now */
DosClose (spyopt.hfileSpy);
spyopt.hfileSpy = NULL;
}
}
/* Fall through to DID_CANCEL */
case DID_CANCEL:
/* Now dismiss the dialog */
WinDismissDlg(hwnd, SHORT1FROMMP(mp1));
break;
}
break;
default:
return(WinDefDlgProc(hwnd, msg, mp1, mp2));
break;
}
return 0L;
}
/**************************** Public Function ******************************\
* MRESULT EXPENTRY SpySaveListDlgProc(hwnd, msg, mp1, mp2)
*
* Effects: The Spy Windows Dialog procedure
*
* Return value: none
\***************************************************************************/
MRESULT EXPENTRY SpySaveListDlgProc(hwnd, msg, mp1, mp2)
HWND hwnd;
USHORT msg;
MPARAM mp1;
MPARAM mp2;
{
HFILE hfileOut;
char szTemp[100];
char szTime[10];
char szDate[10];
SHORT cItems;
SHORT iItem;
ULONG cch;
ULONG cchWritten;
ULONG ulAction;
ULONG lTemp;
switch (msg) {
case WM_INITDLG:
WinSendDlgItemMsg(hwnd, DID_APPEND, BM_SETCHECK,
(MPARAM)spyopt.fAppend, 0L);
/* Initialize the dialog items */
WinSetDlgItemText(hwnd, DID_FILENAME, spystr.szSaveFileName);
break;
case WM_COMMAND:
switch (SHORT1FROMMP(mp1)) {
case DID_OK:
/*
* Get the file name, and try to open the file,
* Then loop through and dump the listbox contents to the
* file.
*/
spyopt.fAppend = (BOOL)WinSendDlgItemMsg(hwnd,
DID_APPEND, BM_QUERYCHECK, 0L, 0L);
WinQueryDlgItemText(hwnd, DID_FILENAME,
sizeof(spystr.szSaveFileName), spystr.szSaveFileName);
if (DosOpen((PSZ)spystr.szSaveFileName, &hfileOut,
&ulAction, 0L, 0,
spyopt.fAppend? 0x0011 : 0x0012, 0x00C1, 0L) == 0) {
/* If append, get to the end of the file */
if (spyopt.fAppend)
DosChgFilePtr(hfileOut, 0L, 2, (PULONG)&lTemp);
/* Get count of items */
cItems = (SHORT)WinSendMsg(hwndSpyList, LM_QUERYITEMCOUNT,
0L, 0L);
/* Write out a title block to the file */
_strdate(szDate);
_strtime(szTime);
DosWrite(hfileOut,
(PSZ)"***************************************\r\n",
41L, &cchWritten);
cch = sprintf(szTemp, "* Spy: %-10s %-10s *\r\n",
szDate, szTime);
DosWrite(hfileOut, (PSZ)szTemp, cch, &cchWritten);
DosWrite(hfileOut,
(PSZ)"***************************************\r\n",
41L, &cchWritten);
/* Now output the list to the file */
for (iItem = 0; iItem < cItems; iItem++) {
cch = (SHORT)WinSendMsg(hwndSpyList, LM_QUERYITEMTEXT,
MPFROM2SHORT(iItem, sizeof(szTemp)),
(MPARAM)(PSZ)szTemp);
/* Add Newline at end of string */
szTemp[cch++] = '\r';
szTemp[cch++] = '\n';
szTemp[cch] = '\0';
DosWrite(hfileOut, (PSZ)szTemp, cch,
&cchWritten);
}
DosClose(hfileOut);
}
case DID_CANCEL:
/* Now dismiss the dialog */
WinDismissDlg(hwnd, SHORT1FROMMP(mp1));
break;
break;
}
default:
return(WinDefDlgProc(hwnd, msg, mp1, mp2));
}
return 0L;
}
/**************************** Public Function *****************************\
* AboutWndProc(HWND hwnd, USHORT message, MPARAM mp1, MPARAM mp2)
*
* Effects: About Spy Dialog procedure
*
*
* Return value:
\***************************************************************************/
MRESULT EXPENTRY AboutWndProc(hwnd, message, mp1, mp2)
HWND hwnd;
USHORT message;
MPARAM mp1;
MPARAM mp2;
{
HPOINTER hptrO;
HPOINTER hptrN;
extern BOOL fV11;
switch (message) {
case WM_COMMAND:
WinDismissDlg(hwnd, TRUE);
break;
default:
return(WinDefDlgProc(hwnd, message, mp1, mp2));
break;
}
return 0L;
} /* end aboutwndproc */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.