home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Computer Buyer 1998 October
/
dpcb1098.iso
/
Business
/
Maxim
/
MAX5
/
data.z
/
MaxWizard.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1998-05-15
|
14KB
|
353 lines
//////////////////////////////////////////////////////////////////////////////
// NAME.......: MaxWizard.CPP
// PURPOSE....: Defines exported functions for the DLL(Wizard)
// WRITTEN....: 96/09/27 by Darko Juvan
// DESCRIPTION: Defines the initialization routines (entry point for dll)
// and exported functions for the DLL
//
// This code and information is provided "as is" without warranty of any
// kind, either expressed or implied, including but not limited to the
// implied warranties of merchantability and/or fitness for a particular
// purpose..
//
// Copyright (c) 1998 Multiactive Software Inc. All Rights Reserved.
//
//////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include <afxdllx.h>
#include "MaxInterface.h"
#include "WizPropertySheet.h"
#include "WizPages.h"
#include "MaxWizard.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//aplication and wizard resource handle
HINSTANCE g_hAppResources;
HINSTANCE g_hDllResources;
//Maximizer Automation objects
IMaxApp* g_pApplication;
ICurrentRec* g_pCurrentRecord;
//user information structure
WIZ_STRUCT* g_pWizSsuBuf;
//state of extension DLL module
static AFX_EXTENSION_MODULE MaxWizardDLL = { NULL, NULL };
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION...: DllMain()
//
// DESCRIPTION: Dll(wizard) entry point
//
//////////////////////////////////////////////////////////////////////////////
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("MAXWIZARD.DLL Initializing!\n");
// Extension DLL one-time initialization
AfxInitExtensionModule(MaxWizardDLL, hInstance);
g_hDllResources = MaxWizardDLL.hModule;
//This function (now commented out)
//inserts this DLL into the resource chain.
//We are not going to do that, instead we will
//change pointer(handle) to resource
//with SetAppResources() and SetDllResources()
//depending what resources we need at that moment.
//new CDynLinkLibrary(MaxWizardDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("MAXWIZARD.DLL Terminating!\n");
}
return 1; // OK
}
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION...: GetWizardAVI() exprted function
//
// DESCRIPTION: return AVI file path (in this version always return empty string)
//
//////////////////////////////////////////////////////////////////////////////
void GetWizardAVI(CString& str)
{
str = "";
}
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION...: GetWizardBMP() exprted function
//
// DESCRIPTION: return BMP file path.
// That bmp will be displayed
// in Wizard Menu Dialog
// (Yellow dialog with list of available wizards)
//
//////////////////////////////////////////////////////////////////////////////
void GetWizardBMP(CString& str)
{
//set to dll resources to load string
SetDllResources();
str.LoadString(IDS_WIZ_BMP);
//return back to App resources
SetAppResources();
}
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION...: GetWizardTitle() exprted function
//
// DESCRIPTION: return wizard title string
// That bmp will be displayed
// in Wizard Menu Dialog
//
//////////////////////////////////////////////////////////////////////////////
void GetWizardTitle(CString& str)
{
//set to dll resources to load string
SetDllResources();
str.LoadString(IDS_WIZ_TITLE);
//return back to App resources
SetAppResources();
}
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION...: GetWizardDescription() exprted function
//
// DESCRIPTION: return wizard description text
// That bmp will be displayed
// in Wizard Menu Dialog
//
//////////////////////////////////////////////////////////////////////////////
void GetWizardDescription(CString& str)
{
//set to dll resources to load string
SetDllResources();
str.LoadString(IDS_WIZ_DESCRIPTION);
//return back to App resources
SetAppResources();
}
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION...: StartWizard() exprted function
//
// DESCRIPTION: start wizard as wizard property sheet dialog
// sending IDispatch pointers of Application and CurrentRecord object, and
// pointer of WIZ_STRUCT structure which has
// SSUREC pointer inside (user rights, user ID,...).
//
//////////////////////////////////////////////////////////////////////////////
void StartWizard(void* pAppDisp, void* pCurRecDisp, void* pWizStruct)
{
//structure sent from Maximizer with user information
g_pWizSsuBuf = (WIZ_STRUCT*)pWizStruct;
//=================================================================================================================
//at this point using user record sent in pWizStruct,
//you can check user data (for example user rights).
//We don't need this information cause adding appointment doesn't have assign rights
//Next lines are just example of checking different user access rights
//------------------------------------------------------------
//Exaple of checking user Access rights for Address Book, Documents,
//User Defined Field and User Defined Field Setup(creation, modification and deletion of UDFs)
//Access rights (Menu: File/Preferences/Security page)
//this will check user rights for address book
BOOL bAddressBookReadRights = (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsClient & READRIGHTS);
BOOL bAddressBookInsertRights = (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsClient & INSERTRIGHTS);
BOOL bAddressBookModufyRights = (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsClient & MODIFYRIGHTS);
BOOL bAddressBookDeleteRights = (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsClient & DELETERIGHTS);
//this will check user rights for Documents
BOOL bDocumentReadRights= (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsDocuments & READRIGHTS);
BOOL bDocumentInsertRights= (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsDocuments & INSERTRIGHTS);
BOOL bDocumentModufyRights= (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsDocuments & MODIFYRIGHTS);
BOOL bDocumentDeleteRights= (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsDocuments & DELETERIGHTS);
//this will check user rights for User Defined Fields
BOOL bUdfReadRights= (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsUDF & READRIGHTS);
BOOL bUdfInsertRights= (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsUDF & INSERTRIGHTS);
BOOL bUdfModufyRights= (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsUDF & MODIFYRIGHTS);
BOOL bUdfDeleteRights= (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsUDF & DELETERIGHTS);
//this will check user rights for User Defined Fields in User Defined Fields setup.
BOOL bUdfSetupReadRights= (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsUDFSet & READRIGHTS);
BOOL bUdfSetupInsertRights= (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsUDFSet & INSERTRIGHTS);
BOOL bUdfSetupModufyRights= (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsUDFSet & MODIFYRIGHTS);
BOOL bUdfSetupDeleteRights= (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsUDFSet & DELETERIGHTS);
//checking access rights for Contact, Notes, Dates,
//Alt. Address, Documents, Strategy Libraries and Opportunities are the same
//------------------------------------------------------------
//Exaple of checking user Privileges (File menu/Preferences/Security page)
//Allow global edit
//default on
BOOL bAllowGlobalEdit = (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.globalEdit == ALLOW_GLOBAL_EDIT);
//Private entries allowed
//default on
BOOL bPrivateEntriesAllowed = (BOOL)!(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsClient & ALLOW_PRIVATE_ENTRIES);
//Open other users' private entries
//default off
BOOL bOpenPrivateEntries = (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.rightsClient & ALLOW_SEE_ALL);
//Modify/delete other user notes
//default on
BOOL bModifyDeleteOtherUserNotes = (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.noModDelOtherNotes == ALLOW_MODIFY_NOTES);
//Other users who can view my calendar
//APPT_RIGHTS_NONE 0//default
//APPT_RIGHTS_MASTER 1
//APPT_RIGHTS_ALL 2
UINT iAppointmentRights = (g_pWizSsuBuf->pSsuBufCopy->UserData.apptRights);
//Add or modify group appointments
//default on
BOOL bGroupAppointmentRights = (BOOL)(g_pWizSsuBuf->pSsuBufCopy->UserData.groupApptRights == GROUP_APPT);
//------------------------------------------------------------
//Exaple of checking user Log options (File menu/Preferences/History page)
//NOLOG 0
//LOG_TO_NOTES 1//default
//LOG_TO_DIARY 2
//LOG_TO_BOTH 3
//Log Documents
UINT iLogDocuments = (g_pWizSsuBuf->pSsuBufCopy->UserData.logDocuments);
//Log Phone Calls
UINT iPhoneCalls = (g_pWizSsuBuf->pSsuBufCopy->UserData.logPhoneCalls);
//Log Scheduled tasks
UINT iLogScheduledTasks = (g_pWizSsuBuf->pSsuBufCopy->UserData.logSchTasks);
//=================================================================================================================
//create Application object from IDispatch pointer we get from Maximizer
IMaxApp Application((LPDISPATCH)pAppDisp);
Application.m_bAutoRelease = FALSE; //Maximizer will take care of desctruction/deletion
//create CurrentRecord object from IDispatch pointer we get from Maximizer
ICurrentRec CurrentRecord((LPDISPATCH)pCurRecDisp);
CurrentRecord.m_bAutoRelease = FALSE; //Maximizer will take care of desctruction/deletion
//assign to globals
g_pApplication = &Application;
g_pCurrentRecord = &CurrentRecord;
//set alarm off while we are in wizard
g_pApplication->SetAlarm("Off");
//set resources to dll(wizard)
//we will soon start wizard dialog
SetDllResources();
CWizPropertySheet wiz;
//construct pages
CPage1 page1(&wiz);
CPage2 page2(&wiz);
CPage3 page3(&wiz);
CPage4 page4(&wiz);
//add pages to wizard
wiz.AddPage(&page1);
wiz.AddPage(&page2);
wiz.AddPage(&page3);
wiz.AddPage(&page4);
//set CWizPropertySheet to be in wizard mode
wiz.SetWizardMode();
//start wizard dialog
if(wiz.DoModal() == ID_WIZFINISH)
{
//return back to application(Maximizer) resources
SetAppResources();
//ole automation uses VARIANT type to send parameters.
//convert all data we colect in wizard (stored in CWizPropertySheet)
COleVariant var_personal(wiz.m_personal, VT_I2);
COleVariant var_alarm(wiz.m_alarm, VT_I2);
COleVariant var_alarm_time(wiz.m_alarm_time, VT_I2);
COleVariant var_iconType(wiz.m_iconType, VT_I2);
COleVariant var_priority(wiz.m_priority, VT_BSTR);
COleVariant var_completed(wiz.m_completed, VT_I2);
//this will add our appointment to current user
g_pCurrentRecord->AddAppointment( wiz.m_date, wiz.m_time1, wiz.m_time2,
wiz.m_text, var_personal, var_alarm,
var_alarm_time, var_iconType,
var_priority, var_completed);
}
else
{
//return back to application(Maximizer) resources
SetAppResources();
}
//set alarm back on
g_pApplication->SetAlarm("On");
}
//////////////////////////////////////////////////////////////////////////////
//INTERNAL HELPER FUNCTIONS
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION...: SetAppResources()
//
// DESCRIPTION: set application resource instance handle
//
//////////////////////////////////////////////////////////////////////////////
void SetAppResources()
{
AfxSetResourceHandle(g_hAppResources); // restore the App resource
}
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION...: SetDllResources()
//
// DESCRIPTION: set dll resource instance handle
//
//////////////////////////////////////////////////////////////////////////////
void SetDllResources()
{
g_hAppResources = AfxGetResourceHandle();
AfxSetResourceHandle(g_hDllResources);
}