Code:
case WM_CREATE:
{
GetClientRect(hwnd, &clientRECT);
// Client area width & height
cScreenX=GetSystemMetrics(SM_CXSCREEN);
cScreenY=GetSystemMetrics(SM_CYSCREEN);
// Client Device Context
hDC=GetDC(hwnd);
memDC = CreateCompatibleDC(hDC);
// Memory Device Context
hBitmap = CreateCompatibleBitmap(hDC,cScreenX,cScreenY);
hOldBitmap = SelectObject(memDC,hBitmap);
// Paint screen background on mem DC grey
hBrush = CreateSolidBrush( RGB(0xD3, 0xD3, 0xD3) );
FillRect(memDC, &clientRECT, hBrush);
DeleteObject(hBrush);
ReleaseDC(hwnd,hDC);
/* Screen refresh time */
SetTimer(hwnd, IDT_REFRESH, REFRESHTIME, NULL);
/* Create edit controls */
EditBoxes(hwnd, cs);
/* Create radio buttons */
RadioButtons(hwnd, cs);
}
return 0;
case WM_PAINT:
{
hdc = BeginPaint(hwnd, &pntS);
BitBlt(hdc, 0, 0, cScreenX, cScreenY, memDC, 0, 0, SRCCOPY);
EndPaint(hwnd, &pntS);
}
return 0;
case WM_TIMER:
{
/* Begin rendering Data on Mem DC */
// Displaying text
PrintText(hwnd, rdrTrans_recv[FREQ], initRecArea(395,45,0,0), hdc,
fntClr[1].boldStyle, fntClr[0].bkgrngColor[0], fntClr[0].txtColor, fntClr[1].italicStyle);
// Retrieve data, calculate & display
output = ProcessData(hwnd);
DisplayResults(hwnd, memDC, &output, rsltFont);
InvalidateRect (hwnd, NULL, FALSE);
UpdateWindow(hwnd);
}
break;
// PrintText function
// Display text on screen
void PrintText(HWND hWnd, TCHAR txt[], RECT rc, HDC hDC, DWORD fnWeight,
COLORREF bkgrndClr, COLORREF txtColor, BOOL italics)
{
long lfHeight=-MulDiv(12, GetDeviceCaps(hDC, LOGPIXELSY), 72);
HFONT font=CreateFont(lfHeight, 0, 0, 0, fnWeight, italics,
0, 0, 0, 0, 0, 0, 0, _T("Times New Roman"));
HGDIOBJ hDefFont=SelectObject(hDC, font);
SetBkColor(hDC, bkgrndClr);
SetTextColor(hDC, txtColor);
TextOut(hDC, rc.left, rc.top, txt,(int)_tcslen(txt));
SelectObject(hDC, hDefFont);
DeleteObject(hDefFont);
}