Index: CMakeLists.txt =================================================================== --- CMakeLists.txt (revision 1052) +++ CMakeLists.txt (working copy) @@ -35,6 +35,10 @@ windows/TabCtrl.cpp windows/TabCtrl.h windows/tooltip.cpp + windows/dbcombobox.cpp + windows/dbcombobox.h + windows/dataxchange.cpp + windows/dataxchange.h windows/connector_odbc_header.bmp) SET(PLATFORM_LIBS comctl32) ENDIF (WIN32) Index: windows/dataxchange.cpp =================================================================== --- windows/dataxchange.cpp (revision 0) +++ windows/dataxchange.cpp (revision 0) @@ -0,0 +1,230 @@ +/* +Copyright (C) 2007 MySQL AB + +This program is free software; you can redistribute it and/or modify +it under the terms of version 2 of the GNU General Public License as +published by the Free Software Foundation. + +There are special exceptions to the terms and conditions of the GPL +as it is applied to this software. View the full text of the exception +in file LICENSE.exceptions in the top-level directory of this software +distribution. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "../setupgui.h" + +#include + +#include "resource.h" +#include "../util/stringutil.h" +#include "TabCtrl.h" + +extern TABCTRL TabCtrl_1; +extern DataSource * pParams; + +#define DEBUG_TAB 4 +#define SSL_TAB 5 + +void getStrFieldData(HWND hwnd, SQLWCHAR **param, int idc) +{ + x_free(*param); + *param= NULL; + + int len = Edit_GetTextLength(GetDlgItem(hwnd,idc)); + + if (len>0) + { + *param= (SQLWCHAR *)my_malloc((len + 1) * sizeof(SQLWCHAR), MYF(0)); + if (*param) + Edit_GetText(GetDlgItem(hwnd,idc), *param, len+1); + } +} + +void getStrFieldData(SQLWCHAR **param, unsigned int framenum, int idc ) +{ + assert(TabCtrl_1.hTabPages); + HWND tab = TabCtrl_1.hTabPages[framenum-1]; + + assert(tab); + + getStrFieldData(tab, param, idc ); +} + +void setUnsignedFieldData(HWND hwnd, unsigned int & param, int idc ) +{ + wchar_t buf[20]; + _itow( param, (wchar_t*)buf, 10 ); + Edit_SetText(GetDlgItem(hwnd,idc), buf); +} + +void getUnsignedFieldData( HWND hwnd, unsigned int & param, int idc ) +{ + param = 0U; + int len = Edit_GetTextLength(GetDlgItem(hwnd,idc)); + + if(len>0) + { + SQLWCHAR *tmp1= (SQLWCHAR *)my_malloc((len + 1) * sizeof(SQLWCHAR), + MYF(0)); + if (tmp1) + { + Edit_GetText(GetDlgItem(hwnd,idc), tmp1, len+1); + param = _wtol(tmp1); + x_free(tmp1); + } + } +} + +bool getBoolFieldData(unsigned int framenum, int idc) +{ + assert(TabCtrl_1.hTabPages); + HWND checkbox = GetDlgItem(TabCtrl_1.hTabPages[framenum-1], idc); + + assert(checkbox); + if (checkbox) + return !!Button_GetCheck(checkbox); + + return false; +} + +#define GET_STRING(name) getStrFieldData(hwnd,¶ms.name,IDC_EDIT_##name) + +#define SET_STRING(name) \ + Edit_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) + +#define GET_BOOL(framenum,name) \ + params.name = getBoolFieldData(framenum,IDC_CHECK_##name) + +#define SET_BOOL(framenum,name) \ + Button_SetCheck(GetDlgItem(TabCtrl_1.hTabPages[framenum-1],IDC_CHECK_##name), params.name) + +void syncData(HWND hwnd, DataSource ¶ms) +{ + GET_STRING(name); + GET_STRING(description); + GET_STRING(server); + GET_UNSIGNED(port); + GET_STRING(uid); + GET_STRING(pwd); + GET_STRING(database); +} + +void syncForm(HWND hwnd, DataSource ¶ms) +{ + SET_STRING(name); + SET_STRING(description); + SET_STRING(server); + SET_UNSIGNED(port); + SET_STRING(uid); + SET_STRING(pwd); + SET_STRING(database); +} +void syncTabsData(HWND hwnd, DataSource ¶ms) +{ + GET_BOOL(1,return_matching_rows); + GET_BOOL(1,allow_big_results); + GET_BOOL(1,use_compressed_protocol); + GET_BOOL(1,change_bigint_columns_to_int); + GET_BOOL(1,safe); + GET_BOOL(1,enable_auto_reconnect); + GET_BOOL(1,enable_auto_increment_null_search); + /* flags 2*/ + GET_BOOL(2,dont_prompt_upon_connect); + GET_BOOL(2,enable_dynamic_cursor); + GET_BOOL(2,ignore_N_in_name_table); + GET_BOOL(2,user_manager_cursor); + GET_BOOL(2,dont_use_set_locale); + GET_BOOL(2,pad_char_to_full_length); + GET_BOOL(2,dont_cache_result); + /* flags 3 */ + GET_BOOL(3,return_table_names_for_SqlDesribeCol); + GET_BOOL(3,ignore_space_after_function_names); + GET_BOOL(3,force_use_of_named_pipes); + GET_BOOL(3,no_catalog); + GET_BOOL(3,read_options_from_mycnf); + GET_BOOL(3,disable_transactions); + GET_BOOL(3,force_use_of_forward_only_cursors); + GET_BOOL(3,allow_multiple_statements); + GET_BOOL(3,limit_column_size); + /* debug*/ + GET_BOOL(4,save_queries); + + /* ssl settings */ + getStrFieldData(¶ms.sslkey , SSL_TAB, IDC_EDIT_sslkey); + getStrFieldData(¶ms.sslcert , SSL_TAB, IDC_EDIT_sslcert); + getStrFieldData(¶ms.sslca , SSL_TAB, IDC_EDIT_sslca); + getStrFieldData(¶ms.sslcapath , SSL_TAB, IDC_EDIT_sslcapath); + getStrFieldData(¶ms.sslcipher , SSL_TAB, IDC_EDIT_sslcipher); + GET_BOOL(SSL_TAB,sslverify); +} + +void syncTabs(HWND hwnd, DataSource ¶ms) +{ + SET_BOOL(1,return_matching_rows); + SET_BOOL(1,allow_big_results); + SET_BOOL(1,use_compressed_protocol); + SET_BOOL(1,change_bigint_columns_to_int); + SET_BOOL(1,safe); + SET_BOOL(1,enable_auto_reconnect); + SET_BOOL(1,enable_auto_increment_null_search); + /* flags 2*/ + SET_BOOL(2,dont_prompt_upon_connect); + SET_BOOL(2,enable_dynamic_cursor); + SET_BOOL(2,ignore_N_in_name_table); + SET_BOOL(2,user_manager_cursor); + SET_BOOL(2,dont_use_set_locale); + SET_BOOL(2,pad_char_to_full_length); + SET_BOOL(2,dont_cache_result); + /* flags 3 */ + SET_BOOL(3,return_table_names_for_SqlDesribeCol); + SET_BOOL(3,ignore_space_after_function_names); + SET_BOOL(3,force_use_of_named_pipes); + SET_BOOL(3,no_catalog); + SET_BOOL(3,read_options_from_mycnf); + SET_BOOL(3,disable_transactions); + SET_BOOL(3,force_use_of_forward_only_cursors); + SET_BOOL(3,allow_multiple_statements); + SET_BOOL(3,limit_column_size); + /* debug*/ + SET_BOOL(DEBUG_TAB,save_queries); + + /* ssl related */ + if ( TabCtrl_1.hTabPages[SSL_TAB-1]) + { + HWND tabHwnd = TabCtrl_1.hTabPages[SSL_TAB-1]; + + Edit_SetText( GetDlgItem( tabHwnd, IDC_EDIT_sslkey) , params.sslkey); + Edit_SetText( GetDlgItem( tabHwnd, IDC_EDIT_sslcert) , params.sslcert); + Edit_SetText( GetDlgItem( tabHwnd, IDC_EDIT_sslca) , params.sslca); + Edit_SetText( GetDlgItem( tabHwnd, IDC_EDIT_sslcapath) , params.sslcapath); + Edit_SetText( GetDlgItem( tabHwnd, IDC_EDIT_sslcipher) , params.sslcipher); + SET_BOOL(SSL_TAB, sslverify); + } + +} + +void FillParameters(HWND hwnd, DataSource & params) +{ + syncData(hwnd, params ); + + if( TabCtrl_1.hTab ) + syncTabsData(hwnd, params); + + /* pack option values into bitmap */ + unsigned long opts= CompileOptions(pParams); + SQLWCHAR optstr[15]; + sqlwcharfromul(optstr, opts); + ds_set_strattr(&pParams->option, optstr); +} \ No newline at end of file Index: windows/dataxchange.h =================================================================== --- windows/dataxchange.h (revision 0) +++ windows/dataxchange.h (revision 0) @@ -0,0 +1,27 @@ +/* +Copyright (C) 2000-2007 MySQL AB + +This program is free software; you can redistribute it and/or modify +it under the terms of version 2 of the GNU General Public License as +published by the Free Software Foundation. + +There are special exceptions to the terms and conditions of the GPL +as it is applied to this software. View the full text of the exception +in file LICENSE.exceptions in the top-level directory of this software +distribution. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +void FillParameters(HWND hwnd, DataSource & params); + +void syncTabs(HWND hwnd, DataSource ¶ms); + +void syncForm(HWND hwnd, DataSource ¶ms); Index: windows/dbcombobox.cpp =================================================================== --- windows/dbcombobox.cpp (revision 0) +++ windows/dbcombobox.cpp (revision 0) @@ -0,0 +1,184 @@ +/* +Copyright (C) 2007 MySQL AB + +This program is free software; you can redistribute it and/or modify +it under the terms of version 2 of the GNU General Public License as +published by the Free Software Foundation. + +There are special exceptions to the terms and conditions of the GPL +as it is applied to this software. View the full text of the exception +in file LICENSE.exceptions in the top-level directory of this software +distribution. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#include "../setupgui.h" + +#include +#include +#include + +#include "dataxchange.h" + +extern DataSource * pParams; + +#define MAX_DBNAME_LENGTH 64 + +#ifndef MAX_VISIBLE_CB_ITEMS +#define MAX_VISIBLE_CB_ITEMS 20 +#endif + + +void changeDropdownHeight(HWND cbHwnd, unsigned int itemsCount) +{ + //ComboBox_SetMinVisible introduced in XP, so using custom + COMBOBOXINFO dbcbinfo; + RECT ddRect; + int newHeight = 0; + + dbcbinfo.cbSize= sizeof(COMBOBOXINFO); + ComboBox_GetDroppedControlRect(cbHwnd, &ddRect); + newHeight= ddRect.bottom - ddRect.top; + + if ( GetComboBoxInfo(cbHwnd, &dbcbinfo) ) + { + itemsCount= itemsCount < 1 ? 1 : (itemsCount > MAX_VISIBLE_CB_ITEMS ? MAX_VISIBLE_CB_ITEMS : itemsCount ); + + newHeight= itemsCount*ComboBox_GetItemHeight(cbHwnd) + (itemsCount - 1); + MoveWindow(dbcbinfo.hwndList, ddRect.left, ddRect.top, ddRect.right-ddRect.left, newHeight, FALSE); + + /* Refresh(cbHwnd);*/ + } +} + + +void populateList(HWND hwnd, HWND hwndCtl) +{ + FillParameters(hwnd, *pParams); + LIST *dbs= mygetdatabases(hwnd, pParams); + LIST *dbtmp= dbs; + + ComboBox_ResetContent(hwndCtl); + + for (; dbtmp; dbtmp= list_rest(dbtmp)) + ComboBox_AddString(hwndCtl, (SQLWCHAR *)dbtmp->data); + + list_free(dbs, 1); + + ComboBox_SetText(hwndCtl,pParams->database); +} + + +void doAutoComplete(HWND hwnd, wchar_t ch) +{ + wchar_t buff[MAX_DBNAME_LENGTH]; + wchar_t unselected[MAX_DBNAME_LENGTH]; + int index=0; + + /* Return - hiding list, selecting everything, and select list item */ + if (ch == VK_RETURN) + { + ComboBox_ShowDropdown(hwnd, FALSE); + ComboBox_SetEditSel(hwnd, 0, -1); + ComboBox_GetText(hwnd, buff, sizeof(buff)); + ComboBox_SetCurSel(hwnd, ComboBox_FindStringExact(hwnd, 0, buff)); + + return; + } + else if (ch == VK_BACK) + { + /* On backspace - expand highlighting one position back */ + index= ComboBox_GetCurSel(hwnd); + int beforeSelectionStart= LOWORD(ComboBox_GetEditSel(hwnd)) - 1; + + /* keep current list item selection */ + ComboBox_SetCurSel(hwnd, index); + + ComboBox_SetEditSel(hwnd, beforeSelectionStart, -1); + return; + } + else if (iscntrl(ch)) + return; + + if (ComboBox_GetDroppedState(hwnd) == FALSE) + ComboBox_ShowDropdown(hwnd, TRUE); + + + /* Getting unselected part of text */ + ComboBox_GetText(hwnd, buff,sizeof(buff)); + buff[LOWORD(ComboBox_GetEditSel(hwnd))]=0; + swprintf(unselected, MAX_DBNAME_LENGTH, L"%s%c", buff, ch); + + /* Looking it in the list */ + if((index=ComboBox_FindStringExact(hwnd, -1, unselected)) == CB_ERR) + { + index= ComboBox_FindString(hwnd, -1, unselected); + } + + if (index == CB_ERR) + return; + + /* Selecting found list item */ + ComboBox_SetCurSel(hwnd, index); + ComboBox_SetEditSel(hwnd, wcslen(unselected), -1); +} + + +LRESULT CALLBACK procComboBox(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + HWND parent; + static WNDPROC defProc; + memset(&defProc, 0, sizeof(defProc)); + defProc= (WNDPROC)GetProp(hwnd, L"defProc"); + + if (msg == WM_DESTROY) + { + parent= GetParent(hwnd); + + if( hwnd == (HWND)GetWindowLongPtr(parent, GWL_USERDATA)) + { + SetWindowLongPtr(hwnd, GWL_WNDPROC, (LONG)GetProp(hwnd, L"defProc")); + RemoveProp(hwnd,L"defProc"); + + SetWindowLongPtr(parent, GWL_WNDPROC, (LONG)GetProp(parent, L"defProc")); + RemoveProp(parent, L"defProc"); + } + + return 0; + } + else if (msg == WM_CHAR) + { + parent = GetParent(hwnd); + + if (hwnd == (HWND)GetWindowLongPtr(parent, GWL_USERDATA)) + doAutoComplete(parent,(wchar_t)wParam); + } + + return CallWindowProc(defProc, hwnd, msg, wParam, lParam); +} + + +void makeAutoComplete (HWND comboBox) +{ + if (!comboBox) + return; + + HWND cbEdit= FindWindowEx(comboBox, NULL, L"Edit", NULL); + SetWindowLong(comboBox, GWL_USERDATA, (long)cbEdit); + + //Remembering and substituting msg processing functions + SetProp(comboBox, L"defProc", (HANDLE)GetWindowLong(comboBox, GWL_WNDPROC)); + SetWindowLongPtr(comboBox, GWL_WNDPROC, (LONG)procComboBox); + + SetProp(cbEdit, L"defProc", (HANDLE)GetWindowLong(cbEdit, GWL_WNDPROC)); + SetWindowLongPtr(cbEdit, GWL_WNDPROC, (LONG)procComboBox); + + ComboBox_LimitText(comboBox, MAX_DBNAME_LENGTH ); +} \ No newline at end of file Index: windows/dbcombobox.h =================================================================== --- windows/dbcombobox.h (revision 0) +++ windows/dbcombobox.h (revision 0) @@ -0,0 +1,29 @@ +/* +Copyright (C) 2007 MySQL AB + +This program is free software; you can redistribute it and/or modify +it under the terms of version 2 of the GNU General Public License as +published by the Free Software Foundation. + +There are special exceptions to the terms and conditions of the GPL +as it is applied to this software. View the full text of the exception +in file LICENSE.exceptions in the top-level directory of this software +distribution. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifndef _DBCOMBOBOX_H_ +#define _DBCOMBOBOX_H_ + +void makeAutoComplete (HWND comboBox); +void populateList(HWND hwnd, HWND hwndCtl); +void changeDropdownHeight(HWND cbHwnd, unsigned int itemsCount); + +#endif \ No newline at end of file Index: windows/odbcdialogparams.cpp =================================================================== --- windows/odbcdialogparams.cpp (revision 1052) +++ windows/odbcdialogparams.cpp (working copy) @@ -27,9 +27,6 @@ #define WIN32_LEAN_AND_MEAN -#define DEBUG_TAB 4 -#define SSL_TAB 5 - #include #include #include @@ -46,12 +43,14 @@ #include "../setupgui.h" #include "odbcdialogparams.h" +#include "dataxchange.h" +#include "dbcombobox.h" #include "stringutil.h" extern HINSTANCE ghInstance; -static DataSource* pParams = NULL; +DataSource* pParams = NULL; static PWCHAR pCaption = NULL; static int OkPressed = 0; @@ -59,7 +58,7 @@ static bool flag = false; static bool BusyIndicator = false; -static TABCTRL TabCtrl_1; +TABCTRL TabCtrl_1; /* Whether we are in SQLDriverConnect() prompt mode (used to disable fields) */ static BOOL g_isPrompt; @@ -97,226 +96,30 @@ static BOOL FormMain_OnNotify (HWND hwnd, WPARAM wParam, LPARAM lParam) { - OnWMNotify(wParam, lParam); - int id = (int)wParam; + OnWMNotify(wParam, lParam); + int id = (int)wParam; - switch(id) - { - case IDC_TAB1: - { - TabControl_Select(&TabCtrl_1); //update internal "this" pointer - LPNMHDR nm = (LPNMHDR)lParam; - switch (nm->code) - { - case TCN_KEYDOWN: - TabCtrl_1.OnKeyDown(lParam); - - case TCN_SELCHANGE: - TabCtrl_1.OnSelChanged(); - } - } - break; - } - - - return FALSE; -} - -void getStrFieldData(HWND hwnd, SQLWCHAR **param, int idc) -{ - x_free(*param); - *param= NULL; - - int len = Edit_GetTextLength(GetDlgItem(hwnd,idc)); - - if (len>0) + switch(id) + { + case IDC_TAB1: { - *param= (SQLWCHAR *)my_malloc((len + 1) * sizeof(SQLWCHAR), MYF(0)); - if (*param) - Edit_GetText(GetDlgItem(hwnd,idc), *param, len+1); - } -} + TabControl_Select(&TabCtrl_1); //update internal "this" pointer + LPNMHDR nm = (LPNMHDR)lParam; + switch (nm->code) + { + case TCN_KEYDOWN: + TabCtrl_1.OnKeyDown(lParam); -void getStrFieldData(SQLWCHAR **param, unsigned int framenum, int idc ) -{ - assert(TabCtrl_1.hTabPages); - HWND tab = TabCtrl_1.hTabPages[framenum-1]; - - assert(tab); - - getStrFieldData(tab, param, idc ); -} - -void setUnsignedFieldData(HWND hwnd, unsigned int & param, int idc ) -{ - wchar_t buf[20]; - _itow( param, (wchar_t*)buf, 10 ); - Edit_SetText(GetDlgItem(hwnd,idc), buf); -} - -void getUnsignedFieldData( HWND hwnd, unsigned int & param, int idc ) -{ - param = 0U; - int len = Edit_GetTextLength(GetDlgItem(hwnd,idc)); - - if(len>0) - { - SQLWCHAR *tmp1= (SQLWCHAR *)my_malloc((len + 1) * sizeof(SQLWCHAR), - MYF(0)); - if (tmp1) - { - Edit_GetText(GetDlgItem(hwnd,idc), tmp1, len+1); - param = _wtol(tmp1); - x_free(tmp1); - } + case TCN_SELCHANGE: + TabCtrl_1.OnSelChanged(); + } } -} + break; + } -bool getBoolFieldData(unsigned int framenum, int idc) -{ - assert(TabCtrl_1.hTabPages); - HWND checkbox = GetDlgItem(TabCtrl_1.hTabPages[framenum-1], idc); - - assert(checkbox); - if (checkbox) - return !!Button_GetCheck(checkbox); - - return false; + return FALSE; } -#define GET_STRING(name) getStrFieldData(hwnd,¶ms.name,IDC_EDIT_##name) - -#define SET_STRING(name) \ - Edit_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) - -#define GET_BOOL(framenum,name) \ - params.name = getBoolFieldData(framenum,IDC_CHECK_##name) - -#define SET_BOOL(framenum,name) \ - Button_SetCheck(GetDlgItem(TabCtrl_1.hTabPages[framenum-1],IDC_CHECK_##name), params.name) - -void syncData(HWND hwnd, DataSource ¶ms) -{ - GET_STRING(name); - GET_STRING(description); - GET_STRING(server); - GET_UNSIGNED(port); - GET_STRING(uid); - GET_STRING(pwd); - GET_STRING(database); -} - -void syncForm(HWND hwnd, DataSource ¶ms) -{ - SET_STRING(name); - SET_STRING(description); - SET_STRING(server); - SET_UNSIGNED(port); - SET_STRING(uid); - SET_STRING(pwd); - SET_STRING(database); -} -void syncTabsData(HWND hwnd, DataSource ¶ms) -{ - GET_BOOL(1,return_matching_rows); - GET_BOOL(1,allow_big_results); - GET_BOOL(1,use_compressed_protocol); - GET_BOOL(1,change_bigint_columns_to_int); - GET_BOOL(1,safe); - GET_BOOL(1,enable_auto_reconnect); - GET_BOOL(1,enable_auto_increment_null_search); - /* flags 2*/ - GET_BOOL(2,dont_prompt_upon_connect); - GET_BOOL(2,enable_dynamic_cursor); - GET_BOOL(2,ignore_N_in_name_table); - GET_BOOL(2,user_manager_cursor); - GET_BOOL(2,dont_use_set_locale); - GET_BOOL(2,pad_char_to_full_length); - GET_BOOL(2,dont_cache_result); - /* flags 3 */ - GET_BOOL(3,return_table_names_for_SqlDesribeCol); - GET_BOOL(3,ignore_space_after_function_names); - GET_BOOL(3,force_use_of_named_pipes); - GET_BOOL(3,no_catalog); - GET_BOOL(3,read_options_from_mycnf); - GET_BOOL(3,disable_transactions); - GET_BOOL(3,force_use_of_forward_only_cursors); - GET_BOOL(3,allow_multiple_statements); - GET_BOOL(3,limit_column_size); - /* debug*/ - GET_BOOL(4,save_queries); - - /* ssl settings */ - getStrFieldData(¶ms.sslkey , SSL_TAB, IDC_EDIT_sslkey); - getStrFieldData(¶ms.sslcert , SSL_TAB, IDC_EDIT_sslcert); - getStrFieldData(¶ms.sslca , SSL_TAB, IDC_EDIT_sslca); - getStrFieldData(¶ms.sslcapath , SSL_TAB, IDC_EDIT_sslcapath); - getStrFieldData(¶ms.sslcipher , SSL_TAB, IDC_EDIT_sslcipher); - GET_BOOL(SSL_TAB,sslverify); -} - -void syncTabs(HWND hwnd, DataSource ¶ms) -{ - SET_BOOL(1,return_matching_rows); - SET_BOOL(1,allow_big_results); - SET_BOOL(1,use_compressed_protocol); - SET_BOOL(1,change_bigint_columns_to_int); - SET_BOOL(1,safe); - SET_BOOL(1,enable_auto_reconnect); - SET_BOOL(1,enable_auto_increment_null_search); - /* flags 2*/ - SET_BOOL(2,dont_prompt_upon_connect); - SET_BOOL(2,enable_dynamic_cursor); - SET_BOOL(2,ignore_N_in_name_table); - SET_BOOL(2,user_manager_cursor); - SET_BOOL(2,dont_use_set_locale); - SET_BOOL(2,pad_char_to_full_length); - SET_BOOL(2,dont_cache_result); - /* flags 3 */ - SET_BOOL(3,return_table_names_for_SqlDesribeCol); - SET_BOOL(3,ignore_space_after_function_names); - SET_BOOL(3,force_use_of_named_pipes); - SET_BOOL(3,no_catalog); - SET_BOOL(3,read_options_from_mycnf); - SET_BOOL(3,disable_transactions); - SET_BOOL(3,force_use_of_forward_only_cursors); - SET_BOOL(3,allow_multiple_statements); - SET_BOOL(3,limit_column_size); - /* debug*/ - SET_BOOL(DEBUG_TAB,save_queries); - - /* ssl related */ - if ( TabCtrl_1.hTabPages[SSL_TAB-1]) - { - HWND tabHwnd = TabCtrl_1.hTabPages[SSL_TAB-1]; - - Edit_SetText( GetDlgItem( tabHwnd, IDC_EDIT_sslkey) , params.sslkey); - Edit_SetText( GetDlgItem( tabHwnd, IDC_EDIT_sslcert) , params.sslcert); - Edit_SetText( GetDlgItem( tabHwnd, IDC_EDIT_sslca) , params.sslca); - Edit_SetText( GetDlgItem( tabHwnd, IDC_EDIT_sslcapath) , params.sslcapath); - Edit_SetText( GetDlgItem( tabHwnd, IDC_EDIT_sslcipher) , params.sslcipher); - SET_BOOL(SSL_TAB, sslverify); - } - -} - -void FillParameters(HWND hwnd, DataSource & params) -{ - syncData(hwnd, params ); - - if( TabCtrl_1.hTab ) - syncTabsData(hwnd, params); - - /* pack option values into bitmap */ - unsigned long opts= CompileOptions(pParams); - SQLWCHAR optstr[15]; - sqlwcharfromul(optstr, opts); - ds_set_strattr(&pParams->option, optstr); -} - void OnDialogClose(); void FormMain_OnClose(HWND hwnd) @@ -414,25 +217,26 @@ // Initialize OPENFILENAME ZeroMemory(&dialog, sizeof(dialog)); - dialog.lStructSize = sizeof(dialog); - dialog.lpstrFile = szFile; + dialog.lStructSize = sizeof(dialog); + dialog.lpstrFile = szFile; - dialog.lpstrTitle = L"Select File"; - dialog.nMaxFile = sizeof(szFile); - dialog.lpstrFileTitle = NULL; - dialog.nMaxFileTitle = 0; - dialog.lpstrInitialDir = NULL; - dialog.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST ; + dialog.lpstrTitle = L"Select File"; + dialog.nMaxFile = sizeof(szFile); + dialog.lpstrFileTitle = NULL; + dialog.nMaxFileTitle = 0; + dialog.lpstrInitialDir= NULL; + dialog.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST ; dialog.hwndOwner = parent; dialog.lpstrCustomFilter = L"All Files\0*.*\0PEM\0*.pem\0"; - dialog.nFilterIndex = 2; + dialog.nFilterIndex = 2; - if ( GetOpenFileNameW( &dialog ) ) + if ( GetOpenFileNameW(&dialog) ) { Edit_SetText( hostControl, dialog.lpstrFile ); } } + void choosePath( HWND parent, int hostCtlId ) { HWND hostControl = GetDlgItem( parent, hostCtlId ); @@ -465,66 +269,15 @@ } } -#ifndef MAX_VISIBLE_CB_ITEMS -#define MAX_VISIBLE_CB_ITEMS 20 -#endif - - -/** - Adjusting height of dropped list of cbHwnd combobox to fit - itemsCount items, but not more than MAX_VISIBLE_CB_ITEMS - ComboBox_SetMinVisible not used because it was introduced in XP. -*/ -int adjustDropdownHeight(HWND cbHwnd, unsigned int itemsCount) -{ - COMBOBOXINFO dbcbinfo; - RECT ddRect; - int newHeight = 0; - - dbcbinfo.cbSize= sizeof(COMBOBOXINFO); - ComboBox_GetDroppedControlRect(cbHwnd, &ddRect); - newHeight= ddRect.bottom - ddRect.top; - - if ( GetComboBoxInfo(cbHwnd, &dbcbinfo) ) - { - itemsCount= itemsCount < 1 ? 1 : (itemsCount > MAX_VISIBLE_CB_ITEMS - ? MAX_VISIBLE_CB_ITEMS - : itemsCount ); - - /* + (itemsCount - 1) - 1 pixel spaces between list items */ - newHeight= itemsCount*ComboBox_GetItemHeight(cbHwnd) + (itemsCount - 1); - MoveWindow(dbcbinfo.hwndList, ddRect.left, ddRect.top, ddRect.right-ddRect.left, newHeight, FALSE); - } - - return newHeight; -} - - -/** - Processing commands for dbname combobox (hwndCtl). -*/ void processDbCombobox(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 *dbs= mygetdatabases(hwnd, pParams); - LIST *dbtmp= dbs; + populateList(hwnd,hwndCtl); + changeDropdownHeight(hwndCtl,ComboBox_GetCount(hwndCtl)); - ComboBox_ResetContent(hwndCtl); - - adjustDropdownHeight(hwndCtl,list_length(dbs)); - - for (; dbtmp; dbtmp= list_rest(dbtmp)) - ComboBox_AddString(hwndCtl, (SQLWCHAR *)dbtmp->data); - - list_free(dbs, 1); - - ComboBox_SetText(hwndCtl,pParams->database); - break; } } @@ -637,7 +390,7 @@ //Get the initial Width and height of the dialog //in order to fix the minimum size of dialog - DecompileOptions( pParams ); + DecompileOptions( pParams ); syncForm(hwnd,*pParams); /* Disable fields if in prompt mode */ @@ -647,6 +400,9 @@ EnableWindow(GetDlgItem(hwnd, IDC_EDIT_description), FALSE); } + //Adding auto-complete fuctionality to dbname dropdown + makeAutoComplete(GetDlgItem(hwnd,IDC_EDIT_dbname)); + BOOL b = DoCreateDialogTooltip(); return 0; } @@ -692,5 +448,4 @@ BusyIndicator= false; return OkPressed; -} - +} \ No newline at end of file