home *** CD-ROM | disk | FTP | other *** search
- // htbslider.cpp : Defines the initialization routines for the DLL.
- //
-
- #include "stdafx.h"
- #include "sliderdlg.h"
- #include "dialogthread.h"
- #include "htbslider.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- #define TEXTTOOLONG 1
- #define SLIDERACTIVE 2
- #define SUCCESS 0
-
- //
- // Note!
- //
- // If this DLL is dynamically linked against the MFC
- // DLLs, any functions exported from this DLL which
- // call into MFC must have the AFX_MANAGE_STATE macro
- // added at the very beginning of the function.
- //
- // For example:
- //
- // extern "C" BOOL PASCAL EXPORT ExportedFunction()
- // {
- // AFX_MANAGE_STATE(AfxGetStaticModuleState());
- // // normal function body here
- // }
- //
- // It is very important that this macro appear in each
- // function, prior to any calls into MFC. This means that
- // it must appear as the first statement within the
- // function, even before any object variable declarations
- // as their constructors may generate calls into the MFC
- // DLL.
- //
- // Please see MFC Technical Notes 33 and 58 for additional
- // details.
- //
-
- /////////////////////////////////////////////////////////////////////////////
- // CHtbsliderApp
-
- BEGIN_MESSAGE_MAP(CHtbsliderApp, CWinApp)
- //{{AFX_MSG_MAP(CHtbsliderApp)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code!
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CHtbsliderApp construction
-
- CHtbsliderApp::CHtbsliderApp()
- {
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // The one and only CHtbsliderApp object
-
- CHtbsliderApp theApp;
-
-
- /////////////////////////////////
- // global variables
-
- short g_DlgXCor;
- short g_DlgYCor;
- char g_Title[MAXTEXTLENGTH];
- char g_Description[MAXTEXTLENGTH];
- char g_LowText[MAXTEXTLENGTH];
- char g_HighText[MAXTEXTLENGTH];
- short g_TextWidth;
- long g_LowVal;
- long g_HighVal;
- short g_SliderWidth;
- long* g_pBasicVar;
- char g_Value[MAXTEXTLENGTH];
- SliderDlg* g_pSDlg = NULL;
-
-
- /////////////////////////////////
- // exported functions
-
-
- short Slider(short DlgXCor,short DlgYCor,char* Title, char* Description,char* LowText,char* HighText,short TextWidth,
- long LowVal,long HighVal,short SliderWidth,long* var)
- { if (!g_pSDlg)
- { g_DlgXCor = DlgXCor;
- g_DlgYCor = DlgYCor;
-
- if (strlen(Title) > MAXTEXTLENGTH || strlen(Description) > MAXTEXTLENGTH || strlen(LowText) > MAXTEXTLENGTH ||
- strlen(HighText) > MAXTEXTLENGTH)
- { return(TEXTTOOLONG);
- }
-
- strcpy(g_Title,Title);
- strcpy(g_Description,Description);
- strcpy(g_LowText,LowText);
- strcpy(g_HighText,HighText);
- g_TextWidth = TextWidth;
- g_LowVal = LowVal;
- g_HighVal = HighVal;
- g_SliderWidth = SliderWidth;
- g_pBasicVar = var;
-
- AfxBeginThread(RUNTIME_CLASS (DialogThread)); // create thread to execute dialog
-
- return(SUCCESS);
- }
-
- return(SLIDERACTIVE);
- }
-
-
- void Closeslider()
- { if (g_pSDlg != NULL)
- { g_pSDlg->KillTimer(1); // stop timer from updating dialog
- g_pSDlg->EndDialog(1); // tell dialog to end
- g_pSDlg = NULL; // set pointer to NULL to show no dialog running (dialog is still shutting down)
- //Sleep(0); // This line should help allow the thread to shut down before Basic
- // regains control. An error could result if a dll us unloaded right after a
- // call to closeslider. the basic program should allow time for the thread to
- // shut down before unloading the DLL. If desired this line can be un-commented
- // to provide some help in getting the thread to shutdown faster.
- }
- }
-
-
- // Setfocus -- used to bring the dialog box to the foreground and activate.
-
- void Setfocus()
- { if (g_pSDlg != NULL)
- { SetForegroundWindow(g_pSDlg->m_hWnd); // bring window to foreground and activate
- }
- }
-
- // end exported functions
- ///////////////////////////////////////////