home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 8 Other
/
08-Other.zip
/
MEM.ZIP
/
MEM.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-03-03
|
3KB
|
114 lines
#define INCL_PM
#define INCL_DOSMEMMGR
#include <os2.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#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));
}