home *** CD-ROM | disk | FTP | other *** search
- // Checkbutton.cpp : Defines the initialization routines for the DLL and the exported functions
- // High Tech BASIC, Copyright (C) TransEra Corp 1999, All Rights Reserved.
-
- /*************************************************************************
- * *
- * Checkbutton DLL (Win32 / MFC) *
- * Author: Sven Henze, Tech Soft GmbH *
- * Date: 12-Aug-1999 *
- * Last Update: 12-Oct-1999 *
- * *
- * This code is intended for the usage under BASIC for Windows V8.X *
- * *
- *************************************************************************/
-
-
- #include "stdafx.h"
- #include "Checkbutton.h"
- #include "CheckbuttonDlg.h"
- #include "DialogThread.h"
- #include "assert.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
-
-
- //
- // 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.
- //
-
- /////////////////////////////////////////////////////////////////////////////
- // CCheckButtonApp
-
- BEGIN_MESSAGE_MAP(CCheckButtonApp, CWinApp)
- //{{AFX_MSG_MAP(CCheckButtonApp)
- // 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()
-
- /////////////////////////////////////////////////////////////////////////////
- // CCheckButtonApp construction
-
- CCheckButtonApp::CCheckButtonApp()
- {
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // The one and only CCheckButtonApp object
-
- CCheckButtonApp theApp;
-
-
- //****************************************************************************************************
- // begin global variables -- used to communicate between threads and different instances of classes
-
-
- short g_SavePressed;
- CString g_Title; // Window title
- CString g_Description; // Text above buttons will wrap to two lines if too long
- CString g_grouptext;
- long g_Width; // width of the dialog box
- short g_BtnCount; // the number of buttons desired
- CString g_Text[MAXBUTTON]; // Checkbutton text
- short *g_pPress; // pointer into HTBasic memory for updateing user input
- OPTION g_Option; // 1 for modal, 2 for threaded variable update, 3 for threaded with signals
- CheckButtonDlg *g_pBtnDlg = NULL; // global pointer to CheckButton dialog used for setting focus and closing
-
- // end global variables
- //***************************************************************************************************
- // begin global functions not exported
-
- // end global functions not exported
- //*****************************************************************************************************
- // begin exported functions
-
-
- // Showcbutton is the main function for setting up and displaying the button dialog box.
- // Params:
- // option is a value between 1 and MAXOPTION. a 1 will call a modal dialog box suspending Program execution and returning
- // the number of the button pushed or a zero if the dialog is closed with no button push.
- // count is the number of Checkboxes from 0 to MAXBUTTON
- // width is the desired width of the dialog window and buttons
- // title is the text for the window title
- // description is the text that will appear above the buttons
- // grouptext is the text for the group frame
- // text1 - text10 is the button text
- // press is a pointer to a short in Basic memory used as an alternative for the return value.
-
- short Showcbutton(short option,short count,long width,short * pressed, char * title,char * description,char * grouptext,char * text1,char * text2,char * text3
- ,char * text4,char * text5,char * text6,char * text7,char * text8,char * text9,char * text10)
- { AFX_MANAGE_STATE(AfxGetStaticModuleState());
-
- long result = 0;
-
- if (g_pBtnDlg != NULL) // CheckButton dialog already active
- {
- return((short)result);
- }
-
- if ((count < MINBUTTON) || (count > MAXBUTTON))
- {
- g_BtnCount = MINBUTTON; // default to 2 buttons for bad input
- }
- else
- {
- g_BtnCount = count; // save number of buttons
- }
-
- g_Width = width; // save width
- if (width < MINWIDTH)
- {
- g_Width = MINWIDTH;
- }
-
- g_SavePressed = *pressed;
-
- if (option < 1 || option > MAXOPTION)
- {
- g_Option = modal; // default to modal for bad input
- }
- else
- {
- g_Option = (OPTION)(option); // 1 = modal
- } // 2 = threaded with variable
- // 3 = threaded with signal
-
-
- g_Title = title;
- g_Description = description;
- g_grouptext = grouptext;
- g_Text[0] = text1;
- g_Text[1] = text2;
- g_Text[2] = text3;
- g_Text[3] = text4;
- g_Text[4] = text5;
- g_Text[5] = text6;
- g_Text[6] = text7;
- g_Text[7] = text8;
- g_Text[8] = text9;
- g_Text[9] = text10;
-
- g_pPress = pressed; // save pointer to press
-
- switch (g_Option)
- {
- case modal:
- {
- CheckButtonDlg Btn; // create dialog object
- g_pBtnDlg = &Btn;
- result = Btn.DoModal();
- g_pBtnDlg = NULL; // reset pointer to dialog
- break;
- }
-
- case variable:
- case signal:
- {
- CWinThread * pThread = AfxBeginThread(RUNTIME_CLASS (DialogThread)); // create thread to execute dialog
- result = 1;
- break;
- }
-
- default:
- assert(0);
- break;
- }
-
- return((short)result);
- }
-
-
- // end Showcbutton
- //*****************************************************************************************
- // Setfocus -- used to bring the CheckButton dialog box to the foreground and activate.
-
-
- void Setfocus()
- {
- SetForegroundWindow(g_pBtnDlg->m_hWnd); // bring window to foreground and activate
- }
-
-
- // end Setfocus
- //*****************************************************************************************
- // Closecbutton -- Used to close CheckButton dialog box when running in its own thread.
-
-
- void Closecbutton()
- {
- if (g_pBtnDlg != NULL)
- {
- g_pBtnDlg->EndDialog(0); // close dialog and allow spawned thread to run out
- g_pBtnDlg = NULL; // reset pointer to dialog
- }
- }
-
-
- // end Closecbutton
- //*****************************************************************************************
-