Category : OS/2 Files
Archive   : MEM1.ZIP
Filename : MEM.C

 
Output of file : MEM.C contained in archive : MEM1.ZIP
#define INCL_PM
#define INCL_DOSMEMMGR
#include
#include
#include
#include
#include "mem.h"

HAB hAB;
HMQ hmqMem;
HWND hwndMem;
HWND hwndMemFrame;
CHAR szMessage[80];
ULONG avail;

SHORT cdecl main( )
{
QMSG qmsg;

hAB = WinInitialize(NULL);

hmqMem = WinCreateMsgQueue(hAB, 0);
if(!MemInitApp())
return(1);

while( WinGetMsg( hAB, (PQMSG)&qmsg, (HWND)NULL, 0, 0 ) )
{
WinDispatchMsg( hAB, (PQMSG)&qmsg );
}

WinDestroyWindow( hwndMemFrame );
WinDestroyMsgQueue( hmqMem );
WinTerminate( hAB );
}

MRESULT EXPENTRY MemWndProc( hWnd, msg, mp1, mp2 )
HWND hWnd;
USHORT msg;
MPARAM mp1;
MPARAM mp2;
{
HPS hPS;
static SHORT timer_delay = IDM_1;
RECTL rect;
LONG clrFore;
LONG clrBack;
USHORT rgfCmd;

switch (msg)
{
case WM_CREATE:
WinStartTimer(hAB,hWnd,ID_TIMER,timer_delay * 1000);
CheckMenuItem(hWnd,timer_delay,TRUE);
break;
case WM_COMMAND:
switch(LOUSHORT(mp1))
{
case IDM_60:
case IDM_30:
case IDM_10:
case IDM_1:
CheckMenuItem(hWnd,timer_delay,FALSE);
timer_delay = LOUSHORT(mp1);
CheckMenuItem(hWnd,timer_delay,TRUE);
WinPostMsg( hWnd, WM_TIMER, 0L, 0L );
WinStartTimer(hAB,hWnd,ID_TIMER,timer_delay * 1000);
break;
case IDM_EXITMEM:
WinPostMsg( hWnd, WM_QUIT, 0L, 0L );
break;
case IDM_RESUME:
break;
}
break;
case WM_CLOSE:
WinPostMsg( hWnd, WM_QUIT, 0L, 0L );
break;

case WM_TIMER:
WinInvalidateRegion(hWnd,NULL, TRUE);
break;
case WM_PAINT:
hPS = WinBeginPaint( hWnd, (HPS)NULL, (PWRECT)NULL );
WinQueryWindowRect( hWnd, (PRECTL)&rect );
clrFore = CLR_BLACK;
clrBack = CLR_BACKGROUND;
rgfCmd = DT_CENTER | DT_VCENTER | DT_TEXTATTRS |
DT_ERASERECT;
DosMemAvail(&avail);
sprintf(szMessage,"Free memory : %.f bytes",(double)avail);
WinDrawText(hPS, 0xFFFF, szMessage, &rect, clrFore, clrBack, rgfCmd);
WinEndPaint( hPS );
break;

case WM_ERASEBACKGROUND:
return( TRUE );
break;

default:
return( WinDefWindowProc( hWnd, msg, mp1, mp2 ) );
break;
}
return(0L);
}

VOID CheckMenuItem(HWND hwnd, SHORT iMenuItem, BOOL bCheck)
{
HWND hwndParent = WinQueryWindow(hwnd,QW_PARENT,FALSE);
HWND hwndMenu = WinWindowFromID(hwndParent,FID_MENU);

WinSendMsg(hwndMenu,MM_SETITEMATTR,(MPARAM)MAKEULONG(iMenuItem,TRUE),
(MPARAM)MAKEULONG(MIA_CHECKED,bCheck ? MIA_CHECKED : 0));
}


  3 Responses to “Category : OS/2 Files
Archive   : MEM1.ZIP
Filename : MEM.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/