=== modified file 'setupgui/callbacks.c' --- setupgui/callbacks.c 2008-02-07 15:04:53 +0000 +++ setupgui/callbacks.c 2009-09-24 11:14:17 +0000 @@ -81,13 +81,16 @@ SQLWCHAR szCatalog[MYODBC_DB_NAME_MAX]; SQLLEN nCatalog; LIST *dbs= NULL; - SQLWCHAR *preserve= params->database; + SQLWCHAR *preservedDatabase= params->database; + BOOL preservedNoCatalog= params->no_catalog; params->database= NULL; + params->no_catalog= FALSE; nReturn= Connect(&hDbc, &hEnv, params); - params->database= preserve; + params->database= preservedDatabase; + params->no_catalog= preservedNoCatalog; if (nReturn != SQL_SUCCESS) ShowDiagnostics(nReturn, SQL_HANDLE_DBC, hDbc); @@ -140,3 +143,74 @@ return list_reverse(dbs); } + + +LIST *mygetcharsets(HWND hwnd, DataSource* params) +{ + SQLHENV hEnv= SQL_NULL_HENV; + SQLHDBC hDbc= hDBC; + SQLHSTMT hStmt; + SQLRETURN nReturn; + SQLWCHAR szCharset[MYODBC_DB_NAME_MAX]; + SQLLEN nCharset; + LIST *csl= NULL; + SQLWCHAR *preservedDatabase= params->database; + BOOL preservedNoCatalog= params->no_catalog; + + params->database= NULL; + params->no_catalog= FALSE; + + nReturn= Connect(&hDbc, &hEnv, params); + + params->database= preservedDatabase; + params->no_catalog= preservedNoCatalog; + + if (nReturn != SQL_SUCCESS) + ShowDiagnostics(nReturn, SQL_HANDLE_DBC, hDbc); + if (!SQL_SUCCEEDED(nReturn)) + { + Disconnect(hDbc,hEnv); + return NULL; + } + + nReturn= SQLAllocHandle(SQL_HANDLE_STMT, hDbc, &hStmt); + if (nReturn != SQL_SUCCESS) + ShowDiagnostics(nReturn, SQL_HANDLE_DBC, hDbc); + if (!SQL_SUCCEEDED(nReturn)) + { + Disconnect(hDbc,hEnv); + return NULL; + } + + + nReturn = SQLExecDirectW( hStmt, L"SHOW CHARACTER SET", SQL_NTS); + if (nReturn != SQL_SUCCESS) + ShowDiagnostics(nReturn, SQL_HANDLE_STMT, hStmt); + if (!SQL_SUCCEEDED(nReturn)) + { + SQLFreeHandle(SQL_HANDLE_STMT, hStmt); + Disconnect(hDbc, hEnv); + return NULL; + } + + nReturn= SQLBindCol(hStmt, 1, SQL_C_WCHAR, szCharset, MYODBC_DB_NAME_MAX, + &nCharset); + while (TRUE) + { + nReturn= SQLFetch(hStmt); + + if (nReturn == SQL_NO_DATA) + break; + else if (nReturn != SQL_SUCCESS) + ShowDiagnostics(nReturn, SQL_HANDLE_STMT, hStmt); + if (SQL_SUCCEEDED(nReturn)) + csl= list_cons(sqlwchardup(szCharset, SQL_NTS), csl); + else + break; + } + + SQLFreeHandle(SQL_HANDLE_STMT, hStmt); + Disconnect(hDbc, hEnv); + + return list_reverse(csl); +} \ No newline at end of file === modified file 'setupgui/setupgui.h' --- setupgui/setupgui.h 2009-05-02 20:53:50 +0000 +++ setupgui/setupgui.h 2009-09-20 19:46:45 +0000 @@ -50,6 +50,7 @@ wchar_t *mytest(HWND hwnd, DataSource *params); BOOL mytestaccept(HWND hwnd, DataSource *params); LIST *mygetdatabases(HWND hwnd, DataSource *params); +LIST *mygetcharsets(HWND hwnd, DataSource *params); /** This is the function implemented by the platform-specific code. === modified file 'setupgui/windows/odbcdialogparams.cpp' --- setupgui/windows/odbcdialogparams.cpp 2009-05-02 20:53:50 +0000 +++ setupgui/windows/odbcdialogparams.cpp 2009-09-20 20:13:42 +0000 @@ -29,6 +29,7 @@ #define DEBUG_TAB 4 #define SSL_TAB 5 +#define MISC_TAB 6 #include #include @@ -189,6 +190,9 @@ #define SET_STRING(name) \ Edit_SetText(GetDlgItem(hwnd,IDC_EDIT_##name), params.name) +#define SET_CSTRING(name) \ + ComboBox_SetText(GetDlgItem(hwnd,IDC_EDIT_##name), params.name) + #define GET_UNSIGNED(name) getUnsignedFieldData(hwnd,params.name,IDC_EDIT_##name) #define SET_UNSIGNED(name) setUnsignedFieldData(hwnd,params.name,IDC_EDIT_##name) @@ -257,6 +261,9 @@ getStrFieldData(¶ms.sslcapath , SSL_TAB, IDC_EDIT_sslcapath); getStrFieldData(¶ms.sslcipher , SSL_TAB, IDC_EDIT_sslcipher); GET_BOOL(SSL_TAB,sslverify); + + getStrFieldData(¶ms.charset , MISC_TAB, IDC_EDIT_charset); + getStrFieldData(¶ms.initstmt , MISC_TAB, IDC_EDIT_initstmt); } void syncTabs(HWND hwnd, DataSource ¶ms) @@ -303,6 +310,14 @@ SET_BOOL(SSL_TAB, sslverify); } + if ( TabCtrl_1.hTabPages[MISC_TAB-1]) + { + HWND tabHwndMisc = TabCtrl_1.hTabPages[MISC_TAB-1]; + HWND charsetCtrl = GetDlgItem(tabHwndMisc,IDC_EDIT_charset); + ComboBox_SetText(charsetCtrl, params.charset); + Edit_SetText( GetDlgItem( tabHwndMisc, IDC_EDIT_initstmt), params.initstmt); + } + } void FillParameters(HWND hwnd, DataSource & params) @@ -345,12 +360,13 @@ if(!flag && mod==1) { - static PWSTR tabnames[]= {L"Flags 1", L"Flags 2", L"Flags 3", L"Debug", L"SSL Settings", 0}; + static PWSTR tabnames[]= {L"Flags 1", L"Flags 2", L"Flags 3", L"Debug", L"SSL Settings", L"Misc Options", 0}; static PWSTR dlgnames[]= {MAKEINTRESOURCE(IDD_TAB1), MAKEINTRESOURCE(IDD_TAB2), MAKEINTRESOURCE(IDD_TAB3), MAKEINTRESOURCE(IDD_TAB4), - MAKEINTRESOURCE(IDD_TAB5),0}; + MAKEINTRESOURCE(IDD_TAB5), + MAKEINTRESOURCE(IDD_TAB6),0}; New_TabControl( &TabCtrl_1, // address of TabControl struct GetDlgItem(hwnd, IDC_TAB1), // handle to tab control @@ -527,6 +543,37 @@ } +/** +Processing commands for charset combobox (hwndCtl). +*/ +void processCharsetCombobox(HWND hwnd, HWND hwndCtl, UINT codeNotify) +{ + switch(codeNotify) + { + /* Loading list and adjust its height if button clicked and on user input */ + case(CBN_DROPDOWN): + { + //FillParameters(hwnd, *pParams); + LIST *csl= mygetcharsets(hwnd, pParams); + LIST *cstmp= csl; + + ComboBox_ResetContent(hwndCtl); + + adjustDropdownHeight(hwndCtl,list_length(csl)); + + for (; cstmp; cstmp= list_rest(cstmp)) + ComboBox_AddString(hwndCtl, (SQLWCHAR *)cstmp->data); + + list_free(csl, 1); + + ComboBox_SetText(hwndCtl,pParams->charset); + + break; + } + } +} + + void FormMain_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { switch (id) @@ -563,6 +610,10 @@ case IDC_EDIT_dbname: processDbCombobox(hwnd, hwndCtl, codeNotify); + break; + + case IDC_EDIT_charset: + processCharsetCombobox(hwnd, hwndCtl, codeNotify); } return; === modified file 'setupgui/windows/odbcdialogparams.rc' --- setupgui/windows/odbcdialogparams.rc 2009-05-02 20:53:50 +0000 +++ setupgui/windows/odbcdialogparams.rc 2009-09-20 19:54:08 +0000 @@ -152,6 +152,16 @@ END +IDD_TAB6 DIALOGEX 0, 0, 209, 151 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + RTEXT "Character Set:",IDC_STATIC,12,14,67,8 + RTEXT "Initial Statement:",IDC_STATIC,12,32,67,8 + COMBOBOX IDC_EDIT_charset,90,12,97,8,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_EDIT_initstmt,90,32,97,12,ES_AUTOHSCROLL +END + #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // === modified file 'setupgui/windows/resource.h' --- setupgui/windows/resource.h 2009-05-02 20:53:50 +0000 +++ setupgui/windows/resource.h 2009-09-20 19:55:48 +0000 @@ -22,6 +22,7 @@ #define IDD_TAB3 133 #define IDD_TAB4 134 #define IDD_TAB5 136 +#define IDD_TAB6 137 #define IDC_LOGO 1000 #define IDC_EDIT_DRVNAME 1004 #define IDC_EDIT_DRVDESC 1005 @@ -52,6 +53,8 @@ #define IDC_EDIT_pwd 10005 #define IDC_EDIT_dbname 10006 #define IDC_EDIT_database 10006 +#define IDC_EDIT_charset 10038 +#define IDC_EDIT_initstmt 10039 #define IDC_CHECK_dont_optimize_column_width 10007 #define IDC_CHECK_return_matching_rows 10008 #define IDC_CHECK_allow_big_results 10009