www.pudn.com > warsrc.rar > IPchkMgr.cpp


// IPchkMgr.cpp : Defines the initialization routines for the DLL. 
// 
 
#include "stdafx.h" 
#include  
#include "WarClient.h" 
#include "resource.h" 
#include "IPextDlg.h" 
#include "IPShitlistUserTab.h" 
#include "UserDialog.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
static AFX_EXTENSION_MODULE IPchkMgrDLL = { NULL, NULL }; 
 
BOOL GetUserOptionTab(CUserDialog *pUserDlg, CWnd *pFatherWnd, CWarUserDlgTemplate **Ptr); 
 
extern "C" int APIENTRY 
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) 
{ 
	if (dwReason == DLL_PROCESS_ATTACH) 
	{ 
		TRACE0("IPCHKMGR.DLL Initializing!\n"); 
		 
		// Extension DLL one-time initialization 
		AfxInitExtensionModule(IPchkMgrDLL, hInstance); 
 
		// Insert this DLL into the resource chain 
		new CDynLinkLibrary(IPchkMgrDLL); 
	} 
	else if (dwReason == DLL_PROCESS_DETACH) 
	{ 
		TRACE0("IPCHKMGR.DLL Terminating!\n"); 
	} 
	return 1;   // ok 
} 
 
 
// Daemon properties tab 
// Add the dialog to the tab... Event is the server Option number 
CIPextDlg *pDaemonTab; 
int QueryForDaemonPropertyPage(int Event, WPARAM wParam, LPARAM lParam) 
{ 
	CRemoteInterface *pRemote = (CRemoteInterface *)wParam; 
	CPropertySheet *pSheet = (CPropertySheet *) lParam; 
	 
	pDaemonTab = new CIPextDlg; 
	if (pSheet) 
	{ 
		pDaemonTab->COptions::Create((LPVOID)pRemote, NULL, "IPchkExt", Event); 
		pDaemonTab->LoadAll(); 
		pSheet->AddPage(pDaemonTab); 
	}	 
	return 0; // ignored 
} 
 
 
int SaveDaemonPropertyPage(int Event, WPARAM wParam, LPARAM lParam) 
{ 
	if (pDaemonTab) 
		pDaemonTab->SaveAll(); 
 
	return 0; // ignored 
} 
 
int ReleaseDaemonPropertyPage(int Event, WPARAM wParam, LPARAM lParam) 
{ 
	if (pDaemonTab) 
	{ 
		delete pDaemonTab; 
		pDaemonTab = NULL; 
	} 
 
	return 0; // ignored 
} 
 
 
////////////////////////////////////////////////////////////////////////////////// 
// User dialog options tab. This is a 'normal' dialog, assigned to a 'tab number'. 
// Some of the option tabs are handled by CUserDialog itself, others 
// by plugins. The dialog must be derived from CWarUserDlgTemplate. 
// 
// The entry point will increment a tab counter and add information about 
// the dialog to the CUserDialog::m_DlgPlugins linked list. 
// The dialog object must be created and initialized by the 
// function GetUserOptionTab(CUserDialog *, CWnd *). 
// It will be deleted after use by the CUserDialog itself. 
// 
// One dll can add 0 - n option tabs by it's own choise. But if more than 
// one tab is used, it must have several GetUserOptionTab() functions, 
// with different names. The pointer to the function is initialized by 
// QueryUserDlgTabs() so this will not cause any problems. The name of 
// GetUserOptionTab is not looked up by the framework. 
// The only export function in the user option tab subsystem is  
// QueryUserDlgTabs() 
 
int QueryUserDlgTabs(int Event, WPARAM wParam, LPARAM lParam) 
{ 
	int *pTabNum = (int *)wParam; // First free tab number 
	CUserDialog *pUserDlg = (CUserDialog *)lParam; 
 
	CString cBuf; 
 
	CDllTab *pDLLtab = new CDllTab; 
	pDLLtab->m_Num = *pTabNum; 
	pDLLtab->m_GetDlg = GetUserOptionTab; 
	pUserDlg->m_DlgPlugins.AddLast((LPVOID)pDLLtab); 
	 
	*pTabNum = *pTabNum + 1; // Increment tab number 
	// Create the tab entry in the user dialog 
 
	TC_ITEM tI; 
	tI.mask = TCIF_TEXT | TCIF_PARAM; 
	tI.pszText = (LPSTR)LoadString(IDS_IPSEC_TABNAME, cBuf); 
	tI.cchTextMax = cBuf.GetLength(); 
	tI.lParam = pDLLtab->m_Num; 
	pUserDlg->m_Tab1.InsertItem(pDLLtab->m_Num, &tI); 
 
	return 0; // Always return 0 
} 
 
 
// Our own function to create and initialize an option tab 
BOOL GetUserOptionTab(CUserDialog *pUserDlg, CWnd *pFatherWnd, CWarUserDlgTemplate **Ptr) 
{ 
	CIPShitlistUserTab *pTab = new CIPShitlistUserTab; 
 
	// This is _requiered_! 
	pTab->m_pUserDlg = pUserDlg; 
 
	// Create the dialog 
	if (pTab->Create(CIPShitlistUserTab::IDD, pFatherWnd)) 
	{ 
		// Set the pointer to point at the dialog. This pointer is 
		// used by the framework to access the dialog. 
		*Ptr = pTab; 
		return TRUE; 
	} 
 
	return FALSE; 
}