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

  1. // Progress.cpp : Defines the initialization routines for the DLL.
  2.  
  3.  
  4. #include "stdafx.h"
  5. #include "Progress.h"
  6. #include "dialogthread.h"
  7. #include "progressdlg.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. //
  16. //    Note!
  17. //
  18. //        If this DLL is dynamically linked against the MFC
  19. //        DLLs, any functions exported from this DLL which
  20. //        call into MFC must have the AFX_MANAGE_STATE macro
  21. //        added at the very beginning of the function.
  22. //
  23. //        For example:
  24. //
  25. //        extern "C" BOOL PASCAL EXPORT ExportedFunction()
  26. //        {
  27. //            AFX_MANAGE_STATE(AfxGetStaticModuleState());
  28. //            // normal function body here
  29. //        }
  30. //
  31. //        It is very important that this macro appear in each
  32. //        function, prior to any calls into MFC.  This means that
  33. //        it must appear as the first statement within the 
  34. //        function, even before any object variable declarations
  35. //        as their constructors may generate calls into the MFC
  36. //        DLL.
  37. //
  38. //        Please see MFC Technical Notes 33 and 58 for additional
  39. //        details.
  40. //
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CProgressApp
  44.  
  45. BEGIN_MESSAGE_MAP(CProgressApp, CWinApp)
  46.     //{{AFX_MSG_MAP(CProgressApp)
  47.         // NOTE - the ClassWizard will add and remove mapping macros here.
  48.         //    DO NOT EDIT what you see in these blocks of generated code!
  49.     //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP()
  51.  
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CProgressApp construction
  54.  
  55. CProgressApp::CProgressApp()
  56. {
  57.     // TODO: add construction code here,
  58.     // Place all significant initialization in InitInstance
  59. }
  60.  
  61. /////////////////////////////////////////////////////////////////////////////
  62. // The one and only CProgressApp object
  63.  
  64. CProgressApp theApp;
  65.  
  66.  
  67. //***********************************************************************************
  68. // global variables used to hold user input until accessed by new thread
  69.  
  70. CString g_text1;
  71. CString g_text2;
  72. long g_xpos;
  73. long g_ypos;
  74. long g_width;
  75. long g_height;
  76. long g_begin;
  77. long g_end;
  78. long * g_pBasicVar;
  79. ProgressDlg * g_pProgBar;
  80.  
  81.  
  82. // end global variables
  83. //************************************************************************************
  84. // begin exported functions
  85.  
  86.  
  87. // Progbar -- Save user input and create new thread for progress bar
  88.  
  89. void Progbar(char* text1,char* text2,long xpos,long ypos,long width,long height,long begin,long end,long* pBasicVar)
  90. {    if (g_pProgBar == NULL)
  91.     {    g_text1 = text1;
  92.         g_text2 = text2;
  93.         g_xpos = xpos;
  94.         g_ypos = ypos;
  95.         g_width = width;
  96.         g_height = height;
  97.         g_begin = begin;
  98.         g_end = end;
  99.         g_pBasicVar = pBasicVar;
  100.  
  101.         AfxBeginThread(RUNTIME_CLASS (DialogThread));    // create thread to execute dialog
  102.     }
  103. }
  104.  
  105.  
  106. // Closebar -- close progress bar dialog box in other thread.
  107.  
  108. void Closebar()
  109. {    if (g_pProgBar != NULL)
  110.     {    g_pProgBar->KillTimer(1);            // stop timer from updating dialog
  111.         g_pProgBar->EndDialog(1);            // tell dialog to end
  112.         g_pProgBar = NULL;                    // set pointer to NULL to show no dialog running (dialog is still shutting down)
  113.         //Sleep(0);                        // This line should help allow the thread to shut down before Basic
  114.                                         // regains control.  An error could result if a dll us unloaded right after a
  115.                                         // call to closeslider.  the basic program should allow time for the thread to
  116.                                         // shut down before unloading the DLL.  If desired this line can be un-commented
  117.                                         // to provide some help in getting the thread to shutdown faster.
  118.     }
  119. }
  120.  
  121.  
  122. // Settext -- set static text while progbar is running
  123.  
  124. void Settext(char* text1, char* text2)
  125. {    g_text1 = text1;
  126.     g_text2 = text2;
  127. }
  128.  
  129.  
  130. // Setfocus -- used to bring the button dialog box to the foreground and activate.
  131.  
  132. void Setfocus()
  133. {    if (g_pProgBar != NULL)
  134.     {    SetForegroundWindow(g_pProgBar->m_hWnd);        // bring window to foreground and activate
  135.     }
  136. }
  137.  
  138.  
  139. // end exported functions
  140. //************************************************************************************