📄 cdialog.cpp
字号:
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "PromptProp", (ULONG*)&m_dwPromptProp);
// m_dwhWndProp = (LONG)m_pCMainWindow->m_hWnd;
//Properties Page
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "ProvString", m_wszProvString, MAX_NAME_LEN);
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "Catalog", m_wszCatalog, MAX_NAME_LEN);
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "lcidProp", (ULONG*)&m_dwlcidProp);
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "AsynchProp", (ULONG*)&m_dwAsynchProp);
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "TimeoutProp", (ULONG*)&m_dwTimeoutProp);
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "ModeProp", (ULONG*)&m_dwModeProp);
//Security Page
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "ProtectionProp", (ULONG*)&m_dwProtectionProp);
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "ImpersonateProp", (ULONG*)&m_dwImpersonateProp);
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "MaskPasswordProp", (ULONG*)&m_dwMaskPasswordProp);
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "EncryptPasswordProp",(ULONG*)&m_dwEncryptPasswordProp);
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "CacheProp", (ULONG*)&m_dwCacheProp);
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "PersistProp", (ULONG*)&m_dwPersistProp);
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "PersistEncryptProp", (ULONG*)&m_dwPersistEncryptProp);
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "Integrated", m_wszIntegrated, MAX_NAME_LEN);
//Options Page
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "CLSCTX", &m_dwCLSCTX);
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "RemoteServer", m_wszRemoteServer, MAX_NAME_LEN);
GetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "ConnectOptions", &m_dwConnectOpts);
//ServiceComponents
GetRegEnumValue(HKEY_ROWSETVIEWER, szRECENTINITSTRING_KEY, 0, m_wszInitString, MAX_QUERY_LEN);
return TRUE;
}
////////////////////////////////////////////////////////////////
// CConnectDlg::SaveDefaults
//
/////////////////////////////////////////////////////////////////
BOOL CConnectDlg::SaveDefaults()
{
//Configuration Name
if(m_szConfigName[0] == EOL)
strcpy(m_szConfigName, "(Default)");
//Save Configuration Name, so we know which configuration is the default
SetRegEntry(HKEY_ROWSETVIEWER, szCONFIG_KEY, "DefaultConfig", m_szConfigName);
//Formulate the key
CHAR szKeyName[MAX_NAME_LEN];
sprintf(szKeyName, "%s\\%s", szCONFIG_KEY, m_szConfigName);
//Selected Provider
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "Provider", m_EnumInfo.wszName);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "ParseName", m_EnumInfo.wszParseName);
//Provider Page
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "Location", m_wszLocation);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "DataSource", m_wszDataSource);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "UserID", m_wszUserID);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "Password", m_wszPassword);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "PromptProp", m_dwPromptProp);
// m_dwhWndProp = (LONG)m_pCMainWindow->m_hWnd;
//Properties Page
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "ProvString", m_wszProvString);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "Catalog", m_wszCatalog);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "lcidProp", m_dwlcidProp);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "AsynchProp", m_dwAsynchProp);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "TimeoutProp", m_dwTimeoutProp);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "ModeProp", m_dwModeProp);
//Security Page
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "ProtectionProp", m_dwProtectionProp);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "ImpersonateProp", m_dwImpersonateProp);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "MaskPasswordProp", m_dwMaskPasswordProp);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "EncryptPasswordProp",m_dwEncryptPasswordProp);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "CacheProp", m_dwCacheProp);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "PersistProp", m_dwPersistProp);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "PersistEncryptProp", m_dwPersistEncryptProp);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "Integrated", m_wszIntegrated);
//Options Page
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "CLSCTX", m_dwCLSCTX);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "RemoteServer", m_wszRemoteServer);
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "ConnectOptions", m_dwConnectOpts);
//Other Configuration Specific Saved Information
SetRegEntry(HKEY_ROWSETVIEWER, szKeyName, "CommandBuffer", m_wszCmdBuffer);
return TRUE;
}
////////////////////////////////////////////////////////////////
// CConnectDlg::LoadRecentConfig
//
/////////////////////////////////////////////////////////////////
BOOL CConnectDlg::LoadRecentConfig(ULONG iRecentConfig)
{
ASSERT(iRecentConfig < m_listConfigs.GetCount());
//Set the active config
strcpy(m_szConfigName, m_listConfigs.GetAt(m_listConfigs.FindIndex(iRecentConfig)));
//Load the saved properties and Connect
LoadDefaults();
FullConnect();
return TRUE;
}
////////////////////////////////////////////////////////////////
// CConnectDlg::AddRecentConfig
//
/////////////////////////////////////////////////////////////////
BOOL CConnectDlg::AddRecentConfig(CHAR* pszConfigName)
{
//Bascially the Alogythym for updating the Recent Configurations
//is similar to a FIFO stack. Lastest items become #1 and all other items
//are moved down. The only exception is if the item already exists
//then it is brought up to number one and all other items are reordered...
if(pszConfigName == NULL)
pszConfigName = m_szConfigName;
//Make sure it doesn't already exist in the list
RemoveRecentConfig(pszConfigName);
//Now add it to the list
m_listConfigs.AddHead(strDuplicate(pszConfigName));
//Make sure the list is less than the Max
if(m_listConfigs.GetCount() > MAX_RECENTCONFIGS)
{
pszConfigName = m_listConfigs.RemoveTail();
SAFE_FREE(pszConfigName);
}
return TRUE;
}
////////////////////////////////////////////////////////////////
// CConnectDlg::RemoveRecentConfig
//
/////////////////////////////////////////////////////////////////
BOOL CConnectDlg::RemoveRecentConfig(CHAR* pszConfigName)
{
ASSERT(pszConfigName);
//Make sure it doesn't allready exist in the list
LISTPOS pos = m_listConfigs.GetHeadPosition();
while(pos)
{
LISTPOS posSave = pos;
CHAR* pszName = m_listConfigs.GetNext(pos);
ASSERT(pszName);
if(strcmp(pszName, pszConfigName)==0)
{
//Remove this item and Add to the head
pszName = m_listConfigs.RemoveAt(posSave);
SAFE_FREE(pszName);
return TRUE;
}
}
return TRUE;
}
////////////////////////////////////////////////////////////////
// CConnectDlg::LoadRecentFile
//
/////////////////////////////////////////////////////////////////
BOOL CConnectDlg::LoadRecentFile(ULONG iRecentFile)
{
ASSERT(iRecentFile < m_listFiles.GetCount());
WCHAR wszBuffer[MAX_NAME_LEN+1];
//Obtain the Selected File
CHAR* pszFileName = m_listFiles.GetAt(m_listFiles.FindIndex(iRecentFile));
//Load the saved properties and Connect
ConvertToWCHAR(pszFileName, wszBuffer, MAX_NAME_LEN);
ConnectFromFile(wszBuffer);
return TRUE;
}
////////////////////////////////////////////////////////////////
// CConnectDlg::AddRecentFile
//
/////////////////////////////////////////////////////////////////
BOOL CConnectDlg::AddRecentFile(CHAR* pszFileName)
{
//Bascially the Alogythym for updating the Recent Files
//is similar to a FIFO stack. Lastest items become #1 and all other items
//are moved down. The only exception is if the item already exists
//then it is brought up to number one and all other items are reordered...
ASSERT(pszFileName);
//Make sure it doesn't already exist in the list
RemoveRecentFile(pszFileName);
//Now add it to the list
m_listFiles.AddHead(strDuplicate(pszFileName));
//Make sure the list is less than the Max
if(m_listFiles.GetCount() > MAX_RECENTFILES)
{
pszFileName = m_listFiles.RemoveTail();
SAFE_FREE(pszFileName);
}
return TRUE;
}
////////////////////////////////////////////////////////////////
// CConnectDlg::RemoveRecentFile
//
/////////////////////////////////////////////////////////////////
BOOL CConnectDlg::RemoveRecentFile(CHAR* pszFileName)
{
ASSERT(pszFileName);
//Make sure it doesn't allready exist in the list
LISTPOS pos = m_listFiles.GetHeadPosition();
while(pos)
{
LISTPOS posSave = pos;
CHAR* pszName = m_listFiles.GetNext(pos);
ASSERT(pszName);
if(strcmp(pszName, pszFileName)==0)
{
//Remove this item and Add to the head
pszName = m_listFiles.RemoveAt(posSave);
SAFE_FREE(pszName);
return TRUE;
}
}
return TRUE;
}
////////////////////////////////////////////////////////////////
// CConnectDlg::pIDataInitialize
//
/////////////////////////////////////////////////////////////////
IDataInitialize* const CConnectDlg::pIDataInitialize()
{
static BOOL fInitialized = FALSE;
//Obtain IDataInitialize
if(m_pIDataInitialize == NULL && !fInitialized)
{
CoCreateInstance(CLSID_MSDAINITIALIZE, NULL, CLSCTX_INPROC_SERVER, IID_IDataInitialize, (void**)&m_pIDataInitialize);
fInitialized = TRUE;
}
return m_pIDataInitialize;
}
////////////////////////////////////////////////////////////////
// CConnectDlg::pIDBPromptInitialize
//
/////////////////////////////////////////////////////////////////
IDBPromptInitialize* const CConnectDlg::pIDBPromptInitialize()
{
static BOOL fInitialized = FALSE;
//Obtain IDataInitialize
if(m_pIDBPromptInitialize == NULL && !fInitialized)
{
CoCreateInstance(CLSID_DataLinks, NULL, CLSCTX_INPROC_SERVER, IID_IDBPromptInitialize, (void**)&m_pIDBPromptInitialize);
fInitialized = TRUE;
}
return m_pIDBPromptInitialize;
}
////////////////////////////////////////////////////////////////
// CConnectDlg::Display
//
/////////////////////////////////////////////////////////////////
ULONG CConnectDlg::Display(IParseDisplayName* pIParseDisplayName, ENUMINFO* pEnumInfo)
{
//Need to first bring up connection...
SAFE_RELEASE(m_pIUnknown)
SAFE_RELEASE(m_pIParseDisplayName);
//If a IParseDisplayName interface is passed in, it represents
//the enumerator to use for instanting the object...
//Otherwise if NULL - it uses the Root Enumerator Object...
SAFE_ADDREF(pIParseDisplayName);
m_pIParseDisplayName = pIParseDisplayName;
if(pEnumInfo)
memcpy(&m_EnumInfo, pEnumInfo, sizeof(ENUMINFO));
//Create an image list
HIMAGELIST hImageList = ImageList_LoadImage(m_hInst, MAKEINTRESOURCE(IDB_TOOLBAR), 16, 16, CLR_DEFAULT , IMAGE_BITMAP, LR_DEFAULTCOLOR);
HICON hIcon = ImageList_GetIcon(hImageList, 1, ILD_NORMAL);
//Now Display the dialog
PROPSHEETPAGE psp[5];
PROPSHEETHEADER psh;
//Header
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_USEHICON | PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
psh.hwndParent = m_hWnd;
psh.hInstance = m_hInst;
psh.hIcon = hIcon;
psh.pszCaption = "Full Connect";
psh.nPages = NUMELE(psp);
psh.nStartPage = 0;
psh.ppsp = (LPCPROPSHEETPAGE) &psp;
//Provider
psp[0].dwSize = sizeof(PROPSHEETPAGE);
psp[0].dwFlags = PSP_USETITLE;
psp[0].hInstance = m_hInst;
psp[0].pszTemplate = MAKEINTRESOURCE(IDD_FULLCONNECT_PROVIDER);
psp[0].pszIcon = NULL;
psp[0].pfnDlgProc = ProviderProc;
psp[0].pszTitle = "Provider";
psp[0].lParam = (LONG)this;
//Properties
psp[1].dwSize = sizeof(PROPSHEETPAGE);
psp[1].dwFlags = PSP_USETITLE;
psp[1].hInstance = m_hInst;
psp[1].pszTemplate = MAKEINTRESOURCE(IDD_FULLCONNECT_PROPERTIES);
psp[1].pszIcon = NULL;
psp[1].pfnDlgProc = PropertiesProc;
psp[1].pszTitle = "Properties";
psp[1].lParam = (LONG)this;
//Security
psp[2].dwSize = sizeof(PROPSHEETPAGE);
psp[2].dwFlags = PSP_USETITLE;
psp[2].hInstance = m_hInst;
psp[2].pszTemplate = MAKEINTRESOURCE(IDD_FULLCONNECT_SECURITY);
psp[2].pszIcon = NULL;
psp[2].pfnDlgProc = SecurityProc;
psp[2].pszTitle = "Security";
psp[2].lParam = (LONG)this;
//Options
psp[3].dwSize = sizeof(PROPSHEETPAGE);
psp[3].dwFlags = PSP_USETITLE;
psp[3].hInstance = m_hInst;
psp[3].pszTemplate = MAKEINTRESOURCE(IDD_FULLCONNECT_OPTIONS);
psp[3].pszIcon = NULL;
psp[3].pfnDlgProc = OptionsProc;
psp[3].pszTitle = "Options";
psp[3].lParam = (LONG)this;
//Trace
psp[4].dwSize = sizeof(PROPSHEETPAGE);
psp[4].dwFlags = PSP_USETITLE;
psp[4].hInstance = m_hInst;
psp[4].pszTemplate = MAKEINTRESOURCE(IDD_FULLCONNECT_TRACE);
psp[4].pszIcon = NULL;
psp[4].pfnDlgProc = TraceProc;
psp[4].pszTitle = "Trace";
psp[4].lParam = (LONG)this;
//Display the Property Sheet
PropertySheet(&psh);
//Now display focus to the new MDIChildWindow
SetFocus(GetWindow(m_pCMainWindow->m_hWndMDIClient, GW_CHILD));
return TRUE;
}
////////////////////////////////////////////////////////////////
// CConnectDlg::ProviderProc
//
/////////////////////////////////////////////////////////////////
BOOL CALLBACK CConnectDlg::ProviderProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static PROPSHEETPAGE* ps = NULL;
switch (message)
{
case WM_INITDIALOG:
{
EXC_BEGIN
// save off the PROPSHEETPAGE information
ps = (PROPSHEETPAGE*)lParam;
CConnectDlg* pThis = (CConnectDlg*)SetThis(hWnd, ps->lParam);
pThis->InitProvider(hWnd);
EXC_END_(hWnd, EndDialog(hWnd, FALSE));
return TRUE;
}
case WM_COMMAND:
{
//Filter out any Control Notification codes
if(GET_WM_COMMAND_CMD(wParam, lParam) > 1)
{
return UNHANDLED_MSG;
}
//LBN_SELCHANGE ListBox Selection change
switch(GET_WM_COMMAND_CMD(wParam, lParam))
{
//Selection change in a list box occurred
case LBN_SELCHANGE:
{
//See which combo box has changed
switch(GET_WM_COMMAND_ID(wParam, lParam))
{
case IDC_CONFIG:
{
//Obtain Config From Drop Down
CConnectDlg* pThis = (CConnectDlg*)GetThis(hWnd);
HWND hWndConfig = GetDlgItem(hWnd, IDC_CONFIG);
//Obtain the Selected Combo Text
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -