home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / MFCCALC.PAK / CALCDLG.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  2.9 KB  |  108 lines

  1. // calcdlg.h : header file
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CCalcDlg dialog
  15.  
  16. enum Operator { OpNone, OpAdd, OpSubtract, OpMultiply, OpDivide };
  17. enum CalcError { ErrNone, ErrDivideByZero };
  18.  
  19. class CCalcDlg : public CDialog
  20. {
  21. // Construction
  22. public:
  23.     CCalcDlg(CWnd* pParent = NULL);    // standard constructor
  24.  
  25. // Operations
  26.     BOOL RegisterActive();
  27.  
  28. // Dialog Data
  29.     //{{AFX_DATA(CCalcDlg)
  30.     enum { IDD = IDD_MFCCALC_DIALOG };
  31.         // NOTE: the ClassWizard will add data members here
  32.     //}}AFX_DATA
  33.  
  34.     // ClassWizard generated virtual function overrides
  35.     //{{AFX_VIRTUAL(CCalcDlg)
  36.     public:
  37.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  38.     protected:
  39.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  40.     virtual void PostNcDestroy();
  41.     //}}AFX_VIRTUAL
  42.  
  43. // Implementation
  44. protected:
  45.     virtual ~CCalcDlg();
  46.  
  47.     HICON m_hIcon;
  48.     HACCEL m_hAccel;
  49.  
  50.     BOOL m_bAutoDelete;        // delete in PostNcDestroy
  51.     DWORD m_dwRegister;        // active registration magic cookie
  52.  
  53.     // calculator state
  54.     long m_accum;
  55.     long m_operand;
  56.     Operator m_operator;
  57.     CalcError m_errorState;
  58.     BOOL m_bOperandAvail;
  59.  
  60.     // helper functions
  61.     void PerformOperation();
  62.     void ClickedNumber(long lNum);
  63.     void UpdateDisplay();
  64.  
  65. public:    
  66.     // Generated message map functions
  67.     //{{AFX_MSG(CCalcDlg)
  68.     virtual BOOL OnInitDialog();
  69.     afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
  70.     afx_msg void OnPaint();
  71.     afx_msg HCURSOR OnQueryDragIcon();
  72.     afx_msg void OnClickedNumber(UINT nID);
  73.     afx_msg void OnClickedClear();
  74.     afx_msg void OnClickedDivide();
  75.     afx_msg void OnClickedEqual();
  76.     afx_msg void OnClickedMinus();
  77.     afx_msg void OnClickedPlus();
  78.     afx_msg void OnClickedTimes();
  79.     virtual void OnCancel();
  80.     virtual void OnOK();
  81.     afx_msg void OnSetFocusAccum();
  82.     //}}AFX_MSG
  83.     DECLARE_MESSAGE_MAP()
  84.  
  85.     // to be OLE creatable, it must be DYNCREATE and OLECREATE
  86.     DECLARE_DYNCREATE(CCalcDlg)
  87.     DECLARE_OLECREATE(CCalcDlg)
  88.  
  89. public:
  90.     // Generated OLE dispatch map functions
  91.     //{{AFX_DISPATCH(CCalcDlg)
  92.     afx_msg long GetAccum();
  93.     afx_msg void SetAccum(long nNewValue);
  94.     afx_msg long GetOperand();
  95.     afx_msg void SetOperand(long nNewValue);
  96.     afx_msg short GetOperation();
  97.     afx_msg void SetOperation(short nNewValue);
  98.     afx_msg BOOL GetVisible();
  99.     afx_msg void SetVisible(BOOL bNewValue);
  100.     afx_msg BOOL Evaluate();
  101.     afx_msg void Clear();
  102.     afx_msg void Display();
  103.     afx_msg void Close();
  104.     afx_msg BOOL Button(LPCTSTR szButton);
  105.     //}}AFX_DISPATCH
  106.     DECLARE_DISPATCH_MAP()
  107. };
  108.