Category : Files from Magazines
Archive   : PROGJRNL.ZIP
Filename : PMAUXFN.C

 
Output of file : PMAUXFN.C contained in archive : PROGJRNL.ZIP
/*
* PMAUXFN - function support module for PMAUX
*
* Written by Bill Hall
* 3665 Benton Street, #66
* Santa Clara, CA 95051
*
*/

#define INCL_PM
#include
#include
#include
#include
#include "pmaux.h"

/* set the window handle (might be NULL) into OS2.ini */
BOOL SetOS2Ini(HWND hWnd)
{
char buf[30];
return(WinWriteProfileString(hAB,szAppName,"hWnd",ltoa((LONG)hWnd,buf,10)));
}

/* respond to menu commands */
void NEAR WndCommand(HWND hWnd, USHORT wParam)
{

HWND hMenu;

switch (wParam) {
case IDM_CRONLF:
MWnd.CRonLF = (MWnd.CRonLF ? FALSE : TRUE); /* toggle parameter */
hMenu = WinWindowFromID(hwndFrame, FID_MENU); /* get menu */
/* set or remove check mark on menu */
WinSendMsg(hMenu, MM_SETITEMATTR, MPFROM2SHORT(wParam, TRUE),
MPFROM2SHORT(MIA_CHECKED, MWnd.CRonLF ? MIA_CHECKED : 0));
break;

case IDM_ABOUT: /* display about box */
WinDlgBox(HWND_DESKTOP, hWnd, AboutBoxProc, NULL, DT_ABOUT, NULL);
break;
}
}

/* send the received buffer to the display */
void NEAR DispatchString(HWND hWnd, MPARAM mp1, MPARAM mp2)
{

#define LBUFLEN 80

BYTE buf[LBUFLEN];
int len, i, count;
BYTE FAR *bufptr;
SEL sel;

len = (int)LOUSHORT(mp1); /* read the length */
sel = (SEL)LOUSHORT(mp2); /* get the selector of the shared buffer */
bufptr = MAKEP(sel,0); /* make it into a pointer */

if (DosGetSeg(sel) == 0) { /* access the shared buffer */
while (len > 0) { /* read and dispatch each part of buffer until done */
count = min(len, LBUFLEN);
for (i = 0; i < count; i++)
buf[i] = *bufptr++;
TTYDisplay(&MWnd, (short)count, buf);
len -= count;
}
}
else /* something wrong, ring the bell */
WinAlarm(HWND_DESKTOP, WA_WARNING);
}

/* repaint the window if needed */
void NEAR MainWndPaint(HWND hWnd, HPS hPS, short top, short bottom)
{

/*
If Microsoft ever gets WinQueryWindowPos working correctly, then
replace the line 'if (WindowIsIconic(hWnd))' with the following:
*/
/*
SWP swp;

WinQueryWindowPos(hWnd, &swp);

if ((swp.fs & SWP_MINIMIZE) && (!(swp.fs & SWP_MAXIMIZE))) {
*/

if (WindowIsIconic(hWnd)) {
POINTL pt;
pt.x = 0;
pt.y = 0;
GpiMove(hPS, (PPOINTL)&pt);
pt.x = xIconsize-1;
pt.y = yIconsize-1;
GpiBox(hPS, 2L, (PPOINTL)&pt, 0L, 0L);
pt.x = 0;
pt.y = 2 * (yIconsize - MWnd.CHeight) / 3;
GpiCharStringAt( hPS, (PPOINTL)&pt, (LONG)strlen(szIcon), (PCH)szIcon);
}
else
TTYWndPaint(&MWnd, hPS, top, bottom);
}

/*
* Return TRUE if main window is iconic.
* This kludge is needed since WinQueryWindowPos is not yet fully implemented.
*/
BOOL NEAR WindowIsIconic(HWND hWnd)
{

RECTL cRect;

/* get the current window client rectangle */
WinQueryWindowRect(hWnd, (PRECTL)&cRect);

/* compare with size when window is iconic */
if ((cRect.xRight == xIconsize) && (cRect.yTop == yIconsize))
return TRUE;

return FALSE;
}

/* simple procedure to handle the about box */
MRESULT EXPENTRY AboutBoxProc(HWND hDlg, USHORT msg, MPARAM mp1, MPARAM mp2)
{

switch (msg) {

case WM_COMMAND:
switch(COMMANDMSG(&msg)->cmd) {
case DID_OK:
WinDismissDlg (hDlg, TRUE);
break;
default:
break;
}
break;

default:
return WinDefDlgProc(hDlg, msg, mp1, mp2);
}
return FALSE;
}
/*
* PMAUXFN - function support module for PMAUX
*
* Written by Bill Hall
* 3665 Benton Street, #66
* Santa Clara, CA 95051
*
*/

#define INCL_PM
#include
#include
#include
#include
#include "pmaux.h"

/* set the window handle (might be NULL) into OS2.ini */
BOOL SetOS2Ini(HWND hWnd)
{
char buf[30];
return(WinWriteProfileString(hAB,szAppName,"hWnd",ltoa((LONG)hWnd,buf,10)));
}

/* respond to menu commands */
void NEAR WndCommand(HWND hWnd, USHORT wParam)
{

HWND hMenu;

switch (wParam) {
case IDM_CLEAR:
TTYClear(&MWnd);
break;

case IDM_CRONLF:
MWnd.CRonLF = (MWnd.CRonLF ? FALSE : TRUE); /* toggle parameter */
hMenu = WinWindowFromID(hwndFrame, FID_MENU); /* get menu */
/* set or remove check mark on menu */
WinSendMsg(hMenu, MM_SETITEMATTR, MPFROM2SHORT(wParam, TRUE),
MPFROM2SHORT(MIA_CHECKED, MWnd.CRonLF ? MIA_CHECKED : 0));
break;

case IDM_ABOUT: /* display about box */
WinDlgBox(HWND_DESKTOP, hWnd, AboutBoxProc, NULL, DT_ABOUT, NULL);
break;
}
}

/* send the received buffer to the display */
void NEAR DispatchString(HWND hWnd, MPARAM mp1, MPARAM mp2)
{

#define LBUFLEN 80

BYTE buf[LBUFLEN];
int len, i, count;
BYTE FAR *bufptr;
SEL sel;

len = (int)LOUSHORT(mp1); /* read the length */
sel = (SEL)LOUSHORT(mp2); /* get the selector of the shared buffer */
bufptr = MAKEP(sel,0); /* make it into a pointer */

if (DosGetSeg(sel) == 0) { /* access the shared buffer */
while (len > 0) { /* read and dispatch each part of buffer until done */
count = min(len, LBUFLEN);
for (i = 0; i < count; i++)
buf[i] = *bufptr++;
TTYDisplay(&MWnd, (short)count, buf);
len -= count;
}
}
else /* something wrong, ring the bell */
WinAlarm(HWND_DESKTOP, WA_WARNING);
}

/* repaint the window if needed */
void NEAR MainWndPaint(HWND hWnd, HPS hPS, short top, short bottom)
{

/*
If Microsoft ever gets WinQueryWindowPos working correctly, then
replace the line 'if (WindowIsIconic(hWnd))' with the following:
*/
/*
SWP swp;

WinQueryWindowPos(hWnd, &swp);

if ((swp.fs & SWP_MINIMIZE) && (!(swp.fs & SWP_MAXIMIZE))) {
*/

if (WindowIsIconic(hWnd)) {
POINTL pt;
pt.x = 0;
pt.y = 0;
GpiMove(hPS, (PPOINTL)&pt);
pt.x = xIconsize-1;
pt.y = yIconsize-1;
GpiBox(hPS, 2L, (PPOINTL)&pt, 0L, 0L);
pt.x = 0;
pt.y = 2 * (yIconsize - MWnd.CHeight) / 3;
GpiCharStringAt( hPS, (PPOINTL)&pt, (LONG)strlen(szIcon), (PCH)szIcon);
}
else
TTYWndPaint(&MWnd, hPS, top, bottom);
}

/*
* Return TRUE if main window is iconic.
* This kludge is needed since WinQueryWindowPos is not yet fully implemented.
*/
BOOL NEAR WindowIsIconic(HWND hWnd)
{

RECTL cRect;

/* get the current window client rectangle */
WinQueryWindowRect(hWnd, (PRECTL)&cRect);

/* compare with size when window is iconic */
if ((cRect.xRight == xIconsize) && (cRect.yTop == yIconsize))
return TRUE;

return FALSE;
}

/* simple procedure to handle the about box */
MRESULT EXPENTRY AboutBoxProc(HWND hDlg, USHORT msg, MPARAM mp1, MPARAM mp2)
{

switch (msg) {

case WM_COMMAND:
switch(COMMANDMSG(&msg)->cmd) {
case DID_OK:
WinDismissDlg (hDlg, TRUE);
break;
default:
break;
}
break;

default:
return WinDefDlgProc(hDlg, msg, mp1, mp2);
}
return FALSE;
}


  3 Responses to “Category : Files from Magazines
Archive   : PROGJRNL.ZIP
Filename : PMAUXFN.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/