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

  1. // htbslider.cpp : Defines the initialization routines for the DLL.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "sliderdlg.h"
  6. #include "dialogthread.h"
  7. #include "htbslider.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 TEXTTOOLONG 1
  16. #define SLIDERACTIVE 2
  17. #define SUCCESS 0
  18.  
  19. //
  20. //    Note!
  21. //
  22. //        If this DLL is dynamically linked against the MFC
  23. //        DLLs, any functions exported from this DLL which
  24. //        call into MFC must have the AFX_MANAGE_STATE macro
  25. //        added at the very beginning of the function.
  26. //
  27. //        For example:
  28. //
  29. //        extern "C" BOOL PASCAL EXPORT ExportedFunction()
  30. //        {
  31. //            AFX_MANAGE_STATE(AfxGetStaticModuleState());
  32. //            // normal function body here
  33. //        }
  34. //
  35. //        It is very important that this macro appear in each
  36. //        function, prior to any calls into MFC.  This means that
  37. //        it must appear as the first statement within the 
  38. //        function, even before any object variable declarations
  39. //        as their constructors may generate calls into the MFC
  40. //        DLL.
  41. //
  42. //        Please see MFC Technical Notes 33 and 58 for additional
  43. //        details.
  44. //
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CHtbsliderApp
  48.  
  49. BEGIN_MESSAGE_MAP(CHtbsliderApp, CWinApp)
  50.     //{{AFX_MSG_MAP(CHtbsliderApp)
  51.         // NOTE - the ClassWizard will add and remove mapping macros here.
  52.         //    DO NOT EDIT what you see in these blocks of generated code!
  53.     //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55.  
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CHtbsliderApp construction
  58.  
  59. CHtbsliderApp::CHtbsliderApp()
  60. {
  61.     // TODO: add construction code here,
  62.     // Place all significant initialization in InitInstance
  63. }
  64.  
  65. /////////////////////////////////////////////////////////////////////////////
  66. // The one and only CHtbsliderApp object
  67.  
  68. CHtbsliderApp theApp;
  69.  
  70.  
  71. /////////////////////////////////
  72. // global variables
  73.  
  74. short g_DlgXCor;
  75. short g_DlgYCor;
  76. char g_Title[MAXTEXTLENGTH];
  77. char g_Description[MAXTEXTLENGTH];
  78. char g_LowText[MAXTEXTLENGTH];
  79. char g_HighText[MAXTEXTLENGTH];
  80. short g_TextWidth;
  81. long g_LowVal;
  82. long g_HighVal;
  83. short g_SliderWidth;
  84. long* g_pBasicVar;
  85. char g_Value[MAXTEXTLENGTH];
  86. SliderDlg* g_pSDlg = NULL;
  87.  
  88.  
  89. /////////////////////////////////
  90. // exported functions
  91.  
  92.  
  93. short Slider(short DlgXCor,short DlgYCor,char* Title, char* Description,char* LowText,char* HighText,short TextWidth,
  94.             long LowVal,long HighVal,short SliderWidth,long* var)
  95. {    if (!g_pSDlg)
  96.     {    g_DlgXCor = DlgXCor;
  97.         g_DlgYCor = DlgYCor;
  98.  
  99.         if (strlen(Title) > MAXTEXTLENGTH || strlen(Description) > MAXTEXTLENGTH || strlen(LowText) > MAXTEXTLENGTH ||
  100.             strlen(HighText) > MAXTEXTLENGTH)
  101.         {    return(TEXTTOOLONG);
  102.         }
  103.  
  104.         strcpy(g_Title,Title);
  105.         strcpy(g_Description,Description);
  106.         strcpy(g_LowText,LowText);
  107.         strcpy(g_HighText,HighText);
  108.         g_TextWidth = TextWidth;
  109.         g_LowVal = LowVal;
  110.         g_HighVal = HighVal;
  111.         g_SliderWidth = SliderWidth;
  112.         g_pBasicVar = var;
  113.  
  114.         AfxBeginThread(RUNTIME_CLASS (DialogThread));    // create thread to execute dialog
  115.  
  116.         return(SUCCESS);
  117.     }
  118.  
  119.     return(SLIDERACTIVE);
  120. }
  121.  
  122.  
  123. void Closeslider()
  124. {    if (g_pSDlg != NULL)
  125.     {    g_pSDlg->KillTimer(1);            // stop timer from updating dialog
  126.         g_pSDlg->EndDialog(1);            // tell dialog to end
  127.         g_pSDlg = NULL;                    // set pointer to NULL to show no dialog running (dialog is still shutting down)
  128.         //Sleep(0);                        // This line should help allow the thread to shut down before Basic
  129.                                         // regains control.  An error could result if a dll us unloaded right after a
  130.                                         // call to closeslider.  the basic program should allow time for the thread to
  131.                                         // shut down before unloading the DLL.  If desired this line can be un-commented
  132.                                         // to provide some help in getting the thread to shutdown faster.
  133.     }
  134. }
  135.  
  136.  
  137. // Setfocus -- used to bring the dialog box to the foreground and activate.
  138.  
  139. void Setfocus()
  140. {    if (g_pSDlg != NULL)
  141.     {    SetForegroundWindow(g_pSDlg->m_hWnd);        // bring window to foreground and activate
  142.     }
  143. }
  144.  
  145. // end exported functions
  146. ///////////////////////////////////////////