Category : Files from Magazines
Archive   : VOL10N18.ZIP
Filename : SAVELIB.C

 
Output of file : SAVELIB.C contained in archive : VOL10N18.ZIP
/***************************************************************************

File: savelib.c

Date: 5/31/91

CFGSAVE 1.0 Copyright (c) 1991 Gene Kavner
First published in PC Magazine, October 29, 1991

***************************************************************************/


/***************************************************************************
Includes
***************************************************************************/
#include
#include
#include

#include "save.h"

/***************************************************************************
Globals
***************************************************************************/
FARPROC FAR lpPrevSendMsgProc;
HWND hwndExitWindows, hwndTop;

/***************************************************************************
SetMessageHook()
***************************************************************************/
BOOL FAR PASCAL SetMessageHook(hwnd)
HWND hwnd;
{

/*-----------------------------------------*\
| Set the Message Hook to start trapping |
| messages. |
\*-----------------------------------------*/

lpPrevSendMsgProc = SetWindowsHook(WH_CALLWNDPROC,(FARPROC)SendMessageProc);
hwndTop = hwnd; /* get handle to main window of the CfgSave app */
hwndExitWindows = NULL; /* reset handle to Exit Windows window */
return(TRUE);
}


/***************************************************************************
SendMessageProc()
***************************************************************************/
void FAR PASCAL SendMessageProc(nCode,wParam,lParam)
int nCode;
WORD wParam;
LPPARAM lParam;
{
if (nCode < 0) {
DefHookProc(nCode,wParam,(LONG)lParam, (FARPROC FAR*)&lpPrevSendMsgProc);
return;
}

/* if this is WM_QUERYENDSESSION message, divert it to CfgSave top level window */
if (lParam->wMsg == WM_QUERYENDSESSION) {
lParam->hwnd=hwndTop;
DefHookProc(nCode,wParam,(LONG)lParam,(FARPROC FAR*)&lpPrevSendMsgProc);
return;
}

/* check if a WM_CREATE message was received */
if (lParam->wMsg == WM_CREATE) {

/* if Exit Windows window hasn't been detected yet, check if this is it */
if (!hwndExitWindows) {
hwndExitWindows = FindWindow (NULL, "Exit Windows");
}

/* if Exit Windows window does exist, check if Save Changes checkbox
control is being created (its ID is 111 decimal)
*/
else if (GetDlgItem(hwndExitWindows,111)==lParam->hwnd) {
/* if this is Save Changes checkbox, check it and simulate user
pressing the OK button.
*/
PostMessage(lParam->hwnd, BM_SETCHECK, 1, NULL);
PostMessage(hwndExitWindows, WM_COMMAND, IDOK, NULL);
}
}

DefHookProc(nCode,wParam,(LONG)lParam,(FARPROC FAR*)&lpPrevSendMsgProc);
return;
}

/***************************************************************************
CancelMessageHook(VOID)
***************************************************************************/
VOID FAR PASCAL CancelMessageHook(VOID)
{
UnhookWindowsHook(WH_CALLWNDPROC, (FARPROC)SendMessageProc);
}


  3 Responses to “Category : Files from Magazines
Archive   : VOL10N18.ZIP
Filename : SAVELIB.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/