Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

CatchCulator

, 18 Oct 2005 CPOL
A tool used to catch and combine values output by different applications.
catchculator_demo.zip
TestValues2.exe
TestValues1.exe
CatchCulator.exe
catchculator_sourcecode.zip
CatchCulator.clw
CatchCulator.dsp
CatchCulator.dsw
res
bitmap1.bmp
bmp00001.bmp
bmp00002.bmp
bmp00003.bmp
bmp00004.bmp
bmp00005.bmp
bmp00006.bmp
bmp00007.bmp
bmp00008.bmp
bmp00009.bmp
bmp00010.bmp
CatchCulator.ico
catchd1.bmp
catchu1.bmp
catchu2.bmp
catchu3.bmp
d1u1.bmp
d1u2.bmp
d1u3.bmp
d2u1.bmp
d2u2.bmp
d2u3.bmp
d3u1.bmp
d3u2.bmp
d3u3.bmp
delitemu.bmp
delu1.bmp
delu2.bmp
delu3.bmp
display_1.bmp
display_2.bmp
display_3.bmp
grad.bmp
settimer.bmp
timerset.bmp
timeru2.bmp
timeru3.bmp
// Author: Dr. Mircea Puiu
// Created on: October 2005 for CodeProject
//
// StaticDisplay.cpp : implementation file
//

#include "stdafx.h"
#include "CatchCulator.h"
#include "StaticDisplay.h"

#include "DisplayFormatDlg.h"
#include "CatchCulatorDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CStaticDisplay

CStaticDisplay::CStaticDisplay()
{
	ID = 1;
	m_strDisplayFormat = "%.5lf";
}

CStaticDisplay::~CStaticDisplay()
{
}


BEGIN_MESSAGE_MAP(CStaticDisplay, CStatic)
	//{{AFX_MSG_MAP(CStaticDisplay)
	ON_WM_PAINT()
	ON_WM_RBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CStaticDisplay message handlers

void CStaticDisplay::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	char	chCaption[256];

	// Create the script dialog (only once)
	if ( !m_dlgScript.GetSafeHwnd() )
	{
		sprintf(chCaption, " Script > D%d", ID);
		m_dlgScript.m_strCaption = chCaption;
		m_dlgScript.Create(IDD_DIALOG_SCRIPT);
	}
	
	// TODO: Add your message handler code here
	CDC			memDC;
	CBitmap		*oldB, B;
	CRect		rcControl;
	CString		strText;
	UINT		oldTA;
	int			w, h, oldBkMode;

	// Create the memory resources
	memDC.CreateCompatibleDC(&dc);
	GetClientRect(&rcControl);
	w = rcControl.Width();
	h = rcControl.Height();
	switch ( ID )
	{
		case 1:		B.LoadBitmap(IDB_BITMAP_D1);	break;
		case 2:		B.LoadBitmap(IDB_BITMAP_D2);	break;
		case 3:		B.LoadBitmap(IDB_BITMAP_D3);	break;
		default:	B.LoadBitmap(IDB_BITMAP_D1);
	}
	oldB = (CBitmap *)memDC.SelectObject(&B);
	oldBkMode = memDC.SetBkMode(TRANSPARENT);
	oldTA = memDC.SetTextAlign(TA_RIGHT);

	// Write the text
	memDC.TextOut(w - 4, 5, m_strDisplay);

	// Put everything on the screen
	dc.BitBlt(0, 0, w, h, &memDC, 0, 0, SRCCOPY);
	// Clean the garbage
	memDC.SetBkMode(oldBkMode);
	memDC.SetTextAlign(oldTA);
	if ( oldB ) memDC.SelectObject(oldB);
	B.DeleteObject();
	ReleaseDC(&memDC);
}

void CStaticDisplay::OnRButtonDown(UINT nFlags, CPoint point) 
{
	CDisplayFormatDlg	dlgFormat;
	CCatchCulatorDlg	*pMain = (CCatchCulatorDlg *)AfxGetMainWnd();

	if ( nFlags == MK_RBUTTON )
	{
		// Erase the display
		m_strDisplay = "";
		Invalidate(FALSE);
	}
	else if ( nFlags == (MK_RBUTTON | MK_CONTROL) )
	{
		// Show the script for this display
		m_dlgScript.ShowWindow(SW_SHOW);
	}
	else if ( nFlags == (MK_RBUTTON | MK_SHIFT) )
	{
		// Change the display format
		dlgFormat.m_nDisplayID = ID;
		dlgFormat.m_strCrtFormat = m_strDisplayFormat;
		if ( dlgFormat.DoModal() == IDOK )
		{
			m_strDisplayFormat = dlgFormat.m_strNewDisplayFormat;
			if ( pMain ) pMain->UpdateDisplay(ID);
		}
	}
	
	CStatic::OnRButtonDown(nFlags, point);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Mircea Puiu
Software Developer (Senior)
Europe Europe
More than 22 years of software development experience.
SCRUM Master nowadays

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150302.1 | Last Updated 18 Oct 2005
Article Copyright 2005 by Mircea Puiu
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid