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

  1. // HTBLineChart.cpp : Defines the initialization routines for the DLL.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "HTBLineChart.h"
  6. #include "dialogthread.h"
  7. #include "linechartdlg.h"
  8. #include "chartline.h"
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. //
  17. //    Note!
  18. //
  19. //        If this DLL is dynamically linked against the MFC
  20. //        DLLs, any functions exported from this DLL which
  21. //        call into MFC must have the AFX_MANAGE_STATE macro
  22. //        added at the very beginning of the function.
  23. //
  24. //        For example:
  25. //
  26. //        extern "C" BOOL PASCAL EXPORT ExportedFunction()
  27. //        {
  28. //            AFX_MANAGE_STATE(AfxGetStaticModuleState());
  29. //            // normal function body here
  30. //        }
  31. //
  32. //        It is very important that this macro appear in each
  33. //        function, prior to any calls into MFC.  This means that
  34. //        it must appear as the first statement within the 
  35. //        function, even before any object variable declarations
  36. //        as their constructors may generate calls into the MFC
  37. //        DLL.
  38. //
  39. //        Please see MFC Technical Notes 33 and 58 for additional
  40. //        details.
  41. //
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CHTBLineChartApp
  45.  
  46. BEGIN_MESSAGE_MAP(CHTBLineChartApp, CWinApp)
  47.     //{{AFX_MSG_MAP(CHTBLineChartApp)
  48.         // NOTE - the ClassWizard will add and remove mapping macros here.
  49.         //    DO NOT EDIT what you see in these blocks of generated code!
  50.     //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CHTBLineChartApp construction
  55.  
  56. CHTBLineChartApp::CHTBLineChartApp()
  57. {
  58.     // TODO: add construction code here,
  59.     // Place all significant initialization in InitInstance
  60. }
  61.  
  62. /////////////////////////////////////////////////////////////////////////////
  63. // The one and only CHTBLineChartApp object
  64.  
  65. CHTBLineChartApp theApp;
  66.  
  67. LineChartDlg* g_pLCDlg = NULL;
  68. int g_UpperBound = 100;
  69. int g_LowerBound = 0;
  70. int g_Timer = 100;
  71. CChartLine * g_pChartLines = NULL;
  72. int g_Width;
  73. int g_Height;
  74. CString g_Title;
  75. CString g_Label;
  76.  
  77. void Linechart(char * Title,char * Label,int Width,int Height,int Lower, int Upper, long Timer)
  78. {    if (g_pLCDlg != NULL)
  79.     {    return;
  80.     }
  81.  
  82.     g_Title = Title;
  83.     g_Label = Label;
  84.     g_Width = Width;
  85.     g_Height = Height;
  86.     g_LowerBound = Lower;
  87.     g_UpperBound = Upper;
  88.     g_Timer = Timer;
  89.  
  90.     CWinThread * pThread = AfxBeginThread(RUNTIME_CLASS (DialogThread));    // create thread to execute dialog
  91. }
  92.  
  93. short Addline(short LineNumber,short red, short blue, short green,long * pData)
  94. {    CChartLine * pLine=NULL;
  95.     
  96.     if (g_pLCDlg == NULL)
  97.     {    return(-1);
  98.     }
  99.  
  100.     if (red < 0 || red > 255)
  101.     {    return(-1);
  102.     }
  103.  
  104.     if (blue < 0 || blue > 255)
  105.     {    return (-1);
  106.     }
  107.  
  108.     if (green < 0 || green > 255)
  109.     {    return (-1);
  110.     }
  111.  
  112.     if (pData == NULL)
  113.     {    return(-1);
  114.     }
  115.  
  116.     pLine = new CChartLine(LineNumber,pData);
  117.     if (g_pChartLines != NULL)
  118.     {    g_pChartLines->AddToList(pLine);
  119.     }
  120.     else
  121.     {    g_pChartLines = pLine;
  122.     }
  123.  
  124.  
  125.     g_pLCDlg->Chartline(red,blue,green);
  126.  
  127.   
  128.     return(0);
  129. }
  130.  
  131. void Viewlinechart()
  132. {    if (g_pLCDlg == NULL)
  133.     {    return;
  134.     }
  135.  
  136.     g_pLCDlg->SetForegroundWindow();
  137. }
  138.  
  139. void Closelinechart()
  140. {    if (g_pLCDlg == NULL)
  141.     { return;
  142.     }
  143.     
  144.     g_pLCDlg->KillTimer(1);
  145.  
  146.     g_pLCDlg->EndDialog(0);
  147.  
  148.     g_pLCDlg = NULL;
  149. }
  150.  
  151. void Signalabove(short LineNumber, int Value,short signal)
  152. {    if (g_pChartLines != NULL)
  153.     {    g_pChartLines->SetSignalAbove(LineNumber,Value,signal);
  154.     }
  155. }
  156.  
  157. void Signalbelow(short LineNumber, int Value,short signal)
  158. {    if (g_pChartLines != NULL)
  159.     {    g_pChartLines->SetSignalBelow(LineNumber,Value,signal);
  160.     }
  161. }
  162.