home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / 93win / data1.cab / DLL_Toolkit / Source / HTBLineChart / LineChartDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2005-03-02  |  2.9 KB  |  119 lines

  1. // LineChartDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "HTBLineChart.h"
  6. #include "LineChartDlg.h"
  7. #include "Chartline.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. #define TEXTHEIGHT 25
  16. #define WIDTHADJUST 30
  17. #define HEIGHTADJUST 75
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // LineChartDlg dialog
  21.  
  22.  
  23. LineChartDlg::LineChartDlg(CWnd* pParent /*=NULL*/)
  24.     : CDialog(LineChartDlg::IDD, pParent)
  25. {
  26.     //{{AFX_DATA_INIT(LineChartDlg)
  27.         // NOTE: the ClassWizard will add member initialization here
  28.     //}}AFX_DATA_INIT
  29. }
  30.  
  31.  
  32. void LineChartDlg::DoDataExchange(CDataExchange* pDX)
  33. {
  34.     CDialog::DoDataExchange(pDX);
  35.     //{{AFX_DATA_MAP(LineChartDlg)
  36.         // NOTE: the ClassWizard will add DDX and DDV calls here
  37.     //}}AFX_DATA_MAP
  38. }
  39.  
  40.  
  41. BEGIN_MESSAGE_MAP(LineChartDlg, CDialog)
  42.     //{{AFX_MSG_MAP(LineChartDlg)
  43.     ON_WM_TIMER()
  44.     ON_WM_CLOSE()
  45.     //}}AFX_MSG_MAP
  46. END_MESSAGE_MAP()
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // LineChartDlg message handlers
  50.  
  51. BOOL LineChartDlg::OnInitDialog() 
  52. {
  53.     CDialog::OnInitDialog();
  54.     
  55.     SetWindowText(g_Title);                                    // set window title
  56.     SetDlgItemText(IDC_LABEL,g_Label);                        // set static text control text
  57.  
  58.     CWnd* pStaticText = GetDlgItem(IDC_LABEL);                // get pointer to static text control text
  59.     pStaticText->SetWindowPos(NULL,0,0,g_Width,TEXTHEIGHT,SWP_NOZORDER | SWP_NOMOVE);    // set width of static text control
  60.  
  61.     m_wndLineChart.SubclassDlgItem(IDC_LINE_CHART_CTRL, this);
  62.  
  63.     CWnd* pLineChart = GetDlgItem(IDC_LINE_CHART_CTRL);                    // get pointer to static text control text
  64.     pLineChart->SetWindowPos(NULL,0,0,g_Width,g_Height,SWP_NOZORDER | SWP_NOMOVE);    // set width of static text control
  65.  
  66.     // set window size
  67.     SetWindowPos(NULL,0,0,g_Width+WIDTHADJUST,g_Height+HEIGHTADJUST,SWP_NOZORDER );    
  68.  
  69.     SetForegroundWindow();
  70.  
  71.     SetTimer(1, m_TimerValue, NULL);    
  72.     return TRUE;  // return TRUE unless you set the focus to a control
  73.                   // EXCEPTION: OCX Property Pages should return FALSE
  74. }
  75.  
  76. void LineChartDlg::OnTimer(UINT nIDEvent) 
  77. {    CChartLine * pCurrent = g_pChartLines;
  78.  
  79.     BringWindowToTop();
  80.  
  81.     if (pCurrent != NULL)
  82.     {    do
  83.         {    m_wndLineChart.SetPos(pCurrent->GetID(),*(pCurrent->GetDataPtr()));
  84.             pCurrent->SendSignals();
  85.             pCurrent = pCurrent->GetNextLine();
  86.         } while(pCurrent != NULL);
  87.     
  88.         m_wndLineChart.Go();
  89.     }
  90.     CDialog::OnTimer(nIDEvent);
  91. }
  92.  
  93. void LineChartDlg::SetBounds(int Lower, int Upper)
  94. {    m_LowerBound = Lower;
  95.     m_UpperBound = Upper;
  96.  
  97. }
  98.  
  99. void LineChartDlg::Chartline(short red, short blue, short green)
  100. {
  101.     
  102.  
  103.     m_wndLineChart.Add(RGB(red,blue,green),m_UpperBound,m_LowerBound);
  104.  
  105. }
  106.  
  107. void LineChartDlg::SetTimerValue(long Timer)
  108. {
  109.     m_TimerValue = Timer;
  110. }
  111.  
  112. void LineChartDlg::OnClose() 
  113. {    g_pLCDlg = NULL;
  114.  
  115.     KillTimer(1);
  116.     
  117.     CDialog::OnClose();
  118. }
  119.