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

  1. /*****************************************************
  2. HTBSwitch.dll
  3.  
  4. HTBswitch.cpp
  5.     
  6. Copyright 1999 TransEra Corporation
  7.  
  8. *****************************************************/
  9. #include "stdafx.h"
  10. #include "HTBswitch.h"
  11. #include "DialogThread.h"
  12. #include "SwitchDlg.h"
  13.  
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19.  
  20. short g_Xpos;
  21. short g_Ypos;
  22. long * g_pBasicVar;
  23. short * RetVal;
  24. SwitchDlg * g_SwitchVar;
  25.  
  26. BEGIN_MESSAGE_MAP(CHTBswitchApp, CWinApp)
  27.     //{{AFX_MSG_MAP(CHTBswitchApp)
  28.         // NOTE - the ClassWizard will add and remove mapping macros here.
  29.         //    DO NOT EDIT what you see in these blocks of generated code!
  30.     //}}AFX_MSG_MAP
  31. END_MESSAGE_MAP()
  32.  
  33. CHTBswitchApp::CHTBswitchApp()
  34. {
  35. }
  36.  
  37. CHTBswitchApp theApp;
  38.  
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. /*
  42.     Function:        Switch
  43.  
  44.     Description:    starts the switch from HTBasic
  45.  
  46.     Return type:    void 
  47.     Argument:        long* pBasicVar
  48.     Argument:        short * ShortPtr
  49.     Argument:        short xpos
  50.     Argument:        short ypos
  51.  
  52.     Notes:            This function takes input from HTBasic as parameters
  53.                     it also establishes communication between HTBasic and
  54.                     the user input from teh mouse to turn the switch on  and
  55.                     off.
  56.         
  57. */
  58. void Switch(long* pBasicVar, short * ShortPtr, short xpos, short ypos) 
  59. {    
  60.         g_Xpos = xpos;
  61.         g_Ypos = ypos;
  62.  
  63.     if (g_SwitchVar == NULL) 
  64.     {
  65.         g_pBasicVar = pBasicVar;
  66.         RetVal = ShortPtr;
  67.         CWinThread * pThread = AfxBeginThread(RUNTIME_CLASS (DialogThread));    // create thread to execute dialog
  68.     }
  69. }
  70.  
  71.  
  72. /////////////////////////////////////////////////////////////////////////////
  73. /*
  74.     Function:        Closeswitch
  75.  
  76.     Description:    Closes switch
  77.  
  78.     Return type:    void 
  79.  
  80.     Notes:            Closes switch and shuts it down along with the
  81.                     worker thread that it was running  on.
  82.         
  83. */
  84. void Closeswitch() 
  85. {    
  86.     if (g_SwitchVar != NULL) 
  87.     {    
  88.         g_SwitchVar->KillTimer(1);            // stop timer from updating dialog
  89.         g_SwitchVar->EndDialog(1);            // tell dialog to end
  90.         g_SwitchVar = NULL;                    // set pointer to NULL to show no dialog running (dialog is still shutting down)
  91.         
  92.     }
  93. }
  94.