May 04, 2024, 10:13:21 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


MemMonitor

Started by Ionic Wind Support Team, December 29, 2005, 09:08:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ionic Wind Support Team

Another conversion


/*
memory monitor 2.0
requires Aurora 1.0 or greater.
Compile as a WINDOWS target
*/
#typedef UINT unsigned int
#define barwidth 100
#define barheight 10

class memwindow:window
{
declare OnCreate(),int;
declare OnTimer(int nIDEvent),int;
declare OnClose(),int;
declare Update();
int textheight,textwidth;
}

struct MEMORYSTATUS
{
    DIM dwLength AS UINT;// sizeof(MEMORYSTATUS)
    DIM dwMemoryLoad AS UINT;// percent of memory in use
    DIM dwTotalPhys AS UINT; // bytes of physical memory
    DIM dwAvailPhys AS UINT; // free physical memory bytes
    DIM dwTotalPageFile AS UINT; // bytes of paging file
    DIM dwAvailPageFile AS UINT; // free bytes of paging file
    DIM dwTotalVirtual AS UINT;  // user bytes of address space
    DIM dwAvailVirtual AS UINT;  // free user bytes
}
DECLARE IMPORT,GlobalMemoryStatus(MEMORYSTATUS ms);

MEMORYSTATUS ms;

global sub main()
{
memwindow mainwin;
point pt;
ms.dwLength = LEN(MEMORYSTATUS);

mainwin.Create(0,0,268,110,AWS_CAPTION|AWS_SYSMENU|AWS_MINIMIZEBOX|AWS_AUTODRAW|AWS_VISIBLE,AWS_EX_TOPMOST,"Memory Monitor",0);
mainwin.SetFont("Arial",8,200);
pt = mainwin.GetTextSize("X");
mainwin.textwidth = pt.x;
mainwin.textheight = pt.y;
mainwin.Update();
do{ WAIT();}UNTIL mainwin.m_hWnd = 0;
return 0;
}


memwindow::OnCreate(),int
{
CenterWindow();
StartTimer(1400);
return true;
}

memwindow::OnClose(),int
{
StopTimer();
Destroy();
return true;
}

memwindow::OnTimer(int nIDEvent),int
{
Update();
return true;
}

memwindow::Update()
{
float calc1;
GlobalMemoryStatus(ms);
    WriteText(20,0,"Physical RAM Avail");
WriteText(20,textheight+2,USING("-#,#########&",ms.dwAvailPhys," Bytes     "));
calc1 = (ms.dwAvailPhys / (ms.dwTotalPhys + 0.0)) * barwidth;
DrawRect(20,(textheight * 2)+2,calc1,barheight,0,0);
DrawRect(calc1+20,(textheight * 2)+2,barwidth - calc1,barheight,RGB(255,0,0),RGB(255,0,0));

WriteText(140,0,"Page File Avail");
WriteText(140,textheight+2,USING("-#,#########&",ms.dwAvailPageFile," Bytes     "));
calc1 = ms.dwAvailPageFile / (ms.dwTotalPageFile + 0.0) * barwidth;
DrawRect(140,(textheight * 2)+2,calc1,barheight,0,0);
DrawRect(calc1+140,(textheight * 2)+2,barwidth - calc1,barheight,RGB(255,0,0),RGB(255,0,0));

WriteText(20,(textheight * 4)-4,USING("-Memory Load ###%%   ",ms.dwMemoryLoad));
calc1 = ms.dwMemoryLoad / 100.0 * barwidth;
DrawRect(20,(textheight * 5)-4,calc1,barheight,0,0);
DrawRect(calc1+20,(textheight * 5)-4,barwidth - calc1,barheight,RGB(255,0,0),RGB(255,0,0));
RETURN;
}
Ionic Wind Support Team