Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/oledb32/dslocator.c | 113 ++++++++++++++++++++++++++++++++++++--- dlls/oledb32/resource.h | 20 +++++++ dlls/oledb32/version.rc | 26 +++++++++ 3 files changed, 151 insertions(+), 8 deletions(-)
diff --git a/dlls/oledb32/dslocator.c b/dlls/oledb32/dslocator.c index 26ee12de53..556390fdf8 100644 --- a/dlls/oledb32/dslocator.c +++ b/dlls/oledb32/dslocator.c @@ -289,11 +289,102 @@ static LRESULT CALLBACK data_link_properties_dlg_proc(HWND hwnd, UINT msg, WPARA return 0; }
+static void connection_fill_odbc_list(HWND parent) +{ + LONG res; + HKEY key; + DWORD index = 0; + WCHAR name[MAX_PATH]; + DWORD nameLen; + + HWND combo = GetDlgItem(parent, IDC_CBO_NAMES); + if (!combo) + return; + + res = RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\ODBC\ODBC.INI\ODBC Data Sources", 0, KEY_READ, &key); + if (res == ERROR_FILE_NOT_FOUND) + return; + + SendMessageW (combo, CB_RESETCONTENT, 0, 0); + + for(;; index++) + { + nameLen = MAX_PATH; + if (RegEnumValueW(key, index, name, &nameLen, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) + break; + + SendMessageW(combo, CB_ADDSTRING, 0, (LPARAM)name); + } + + RegCloseKey(key); +} + +static void connection_initialize_controls(HWND parent) +{ + HWND hwnd = GetDlgItem(parent, IDC_RDO_SRC_NAME); + if (hwnd) + SendMessageA(hwnd, BM_SETCHECK, BST_CHECKED, 0); +} + +static void connection_toggle_controls(HWND parent) +{ + BOOL checked = TRUE; + HWND hwnd = GetDlgItem(parent, IDC_RDO_SRC_NAME); + if (hwnd) + checked = SendMessageA(hwnd, BM_GETCHECK, 0, 0); + + EnableWindow(GetDlgItem(parent, IDC_CBO_NAMES), checked); + EnableWindow(GetDlgItem(parent, IDC_BTN_REFRESH), checked); + + EnableWindow(GetDlgItem(parent, IDC_LBL_CONNECTION), !checked); + EnableWindow(GetDlgItem(parent, IDC_EDT_CONNECTION), !checked); + EnableWindow(GetDlgItem(parent, IDC_BTN_BUILD), !checked); +} + +static LRESULT CALLBACK data_link_connection_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) +{ + TRACE("(%p, %08x, %08lx, %08lx)\n", hwnd, msg, wp, lp); + + switch (msg) + { + case WM_INITDIALOG: + { + connection_initialize_controls(hwnd); + connection_fill_odbc_list(hwnd); + connection_toggle_controls(hwnd); + break; + } + case WM_COMMAND: + { + switch LOWORD(wp) + { + case IDC_RDO_SRC_NAME: + case IDC_BTN_CONNECTION: + connection_toggle_controls(hwnd); + break; + case IDC_BTN_REFRESH: + connection_fill_odbc_list(hwnd); + break; + case IDC_BTN_BUILD: + case IDC_BTN_TEST: + /* TODO: Implement dialogs */ + MessageBoxA(hwnd, "Not implemented yet.", "Error", MB_OK | MB_ICONEXCLAMATION); + break; + } + + break; + } + default: + break; + } + return 0; +} + static HRESULT WINAPI dslocator_PromptNew(IDataSourceLocator *iface, IDispatch **connection) { DSLocatorImpl *This = impl_from_IDataSourceLocator(iface); PROPSHEETHEADERW hdr; - PROPSHEETPAGEW page; + PROPSHEETPAGEW pages[2]; INT_PTR ret;
FIXME("(%p, %p) Semi-stub\n", iface, connection); @@ -303,11 +394,17 @@ static HRESULT WINAPI dslocator_PromptNew(IDataSourceLocator *iface, IDispatch *
*connection = NULL;
- memset(&page, 0, sizeof(PROPSHEETPAGEW)); - page.dwSize = sizeof(page); - page.hInstance = instance; - page.u.pszTemplate = MAKEINTRESOURCEW(IDD_PROVIDER); - page.pfnDlgProc = data_link_properties_dlg_proc; + memset(&pages, 0, sizeof(pages)); + + pages[0].dwSize = sizeof(PROPSHEETPAGEW); + pages[0].hInstance = instance; + pages[0].u.pszTemplate = MAKEINTRESOURCEW(IDD_PROVIDER); + pages[0].pfnDlgProc = data_link_properties_dlg_proc; + + pages[1].dwSize = sizeof(PROPSHEETPAGEW); + pages[1].hInstance = instance; + pages[1].u.pszTemplate = MAKEINTRESOURCEW(IDD_CONNECTION); + pages[1].pfnDlgProc = data_link_connection_dlg_proc;
memset(&hdr, 0, sizeof(hdr)); hdr.dwSize = sizeof(hdr); @@ -315,8 +412,8 @@ static HRESULT WINAPI dslocator_PromptNew(IDataSourceLocator *iface, IDispatch * hdr.dwFlags = PSH_NOAPPLYNOW | PSH_PROPSHEETPAGE; hdr.hInstance = instance; hdr.pszCaption = MAKEINTRESOURCEW(IDS_PROPSHEET_TITLE); - hdr.u3.ppsp = &page; - hdr.nPages = 1; + hdr.u3.ppsp = pages; + hdr.nPages = ARRAY_SIZE(pages); ret = PropertySheetW(&hdr);
return ret ? S_OK : S_FALSE; diff --git a/dlls/oledb32/resource.h b/dlls/oledb32/resource.h index df88a10829..7944e42cc4 100644 --- a/dlls/oledb32/resource.h +++ b/dlls/oledb32/resource.h @@ -22,3 +22,23 @@
#define IDS_PROPSHEET_TITLE 2000 #define IDS_COL_PROVIDER 2001 + +#define IDD_CONNECTION 3000 +#define IDC_BTN_EDIT 3001 +#define IDC_RDO_SRC_NAME 3002 +#define IDC_CBO_NAMES 3003 +#define IDC_BTN_REFRESH 3004 +#define IDC_BTN_CONNECTION 3005 +#define IDC_EDT_CONNECTION 3006 +#define IDC_BTN_BUILD 3007 +#define IDC_EDT_NAME 3008 +#define IDC_EDT_PASSWORD 3009 +#define IDC_CHK_BLANK 3010 +#define IDC_CHK_SAVE_PASS 3011 +#define IDC_CBO_INITIAL 3012 +#define IDC_BTN_TEST 3013 +#define IDC_LBL_SOURCE 3014 +#define IDC_LBL_LOGIN 3015 +#define IDC_LBL_INITIAL 3016 +#define IDC_LBL_CONNECTION 3017 + diff --git a/dlls/oledb32/version.rc b/dlls/oledb32/version.rc index 3a200d1cd6..63d1d6c002 100644 --- a/dlls/oledb32/version.rc +++ b/dlls/oledb32/version.rc @@ -46,3 +46,29 @@ BEGIN CONTROL "",IDC_LST_CONNECTIONS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,14,20,206,162 PUSHBUTTON "&Next >",IDC_BTN_NEXT,170,194,50,14 END + +IDD_CONNECTION DIALOG 0, 0, 227, 225 +STYLE DS_SETFONT | WS_CHILD | WS_DISABLED | WS_CAPTION +CAPTION "Connection" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "Specify the following to connect to ODBC data:",-1,7,7,213,8 + LTEXT "1. Specify the source of data:",IDC_LBL_SOURCE,14,18,206,8 + CONTROL "Use &data source name",IDC_RDO_SRC_NAME,"Button",BS_AUTORADIOBUTTON | WS_GROUP,29,29,192,10 + COMBOBOX IDC_CBO_NAMES,36,40,150,128,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "&Refresh",IDC_BTN_REFRESH,189,39,31,14 + CONTROL "Use c&onnection string",IDC_BTN_CONNECTION,"Button",BS_AUTORADIOBUTTON,29,57,192,10 + LTEXT "&Connection string:",IDC_LBL_CONNECTION,36,68,182,8 + EDITTEXT IDC_EDT_CONNECTION,36,78,148,12,ES_AUTOHSCROLL + PUSHBUTTON "B&uild...",IDC_BTN_BUILD,189,77,31,14 + LTEXT "2. Enter information to log on to the server",IDC_LBL_LOGIN,14,98,206,8 + LTEXT "User &name:",-1,29,110,38,8 + EDITTEXT IDC_EDT_NAME,67,108,153,12,ES_AUTOHSCROLL + LTEXT "&Password:",-1,29,126,34,8 + EDITTEXT IDC_EDT_PASSWORD,67,124,153,12,ES_PASSWORD | ES_AUTOHSCROLL + CONTROL "&Blank password",IDC_CHK_BLANK,"Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,29,140,69,10 + CONTROL "Allow &saving password",IDC_CHK_SAVE_PASS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,103,140,103,10 + LTEXT "3. Enter the &initial catalog to use:",IDC_LBL_INITIAL,14,159,206,8 + COMBOBOX IDC_CBO_INITIAL,29,170,191,64,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "&Test Connection",IDC_BTN_TEST,140,194,81,14,WS_GROUP +END