=== modified file 'setupgui/windows/odbcdialogparams.cpp' --- setupgui/windows/odbcdialogparams.cpp 2010-04-13 06:56:43 +0000 +++ setupgui/windows/odbcdialogparams.cpp 2010-04-19 12:24:10 +0000 @@ -72,9 +72,59 @@ static TABCTRL TabCtrl_1; /* Whether we are in SQLDriverConnect() prompt mode (used to disable fields) */ static BOOL g_isPrompt; +/* Variable to keep IDC of control where default value were put. It's reset if + user changes value. Used to verify if we can reset that control's value. + It won't work if for more than 1 field, but we have only one in visible future. */ +static long controlWithDefValue= 0; HelpButtonPressedCallbackType* gHelpButtonPressedCallback = NULL; + +/* Function that enables/disables groups of controls */ +#define SWITCHED_GROUPS 2 +#define MAX_GROUP_COTROLS 2 +void SwitchTcpOrPipe(HWND hwnd, BOOL usePipe) +{ + /* groups of fields to enable/disable*/ + const int switchedFields[SWITCHED_GROUPS][MAX_GROUP_COTROLS]= + {{IDC_EDIT_server, IDC_EDIT_port}, + {IDC_EDIT_socket, 0}}; + + /* Default value for enabled empty field */ + const LPCWSTR defaultValues[SWITCHED_GROUPS][MAX_GROUP_COTROLS]= + {{NULL, NULL}, {L"MySQL", NULL}}; + /* Can't be sure that usePipe contains 1 as TRUE*/ + long activeIndex= usePipe ? 1L : 0L; + + for (long i= 0; i < SWITCHED_GROUPS; ++i) + for (long j= 0; j < MAX_GROUP_COTROLS && switchedFields[i][j] != 0; ++j) + { + HWND control= GetDlgItem(hwnd, switchedFields[i][j]); + EnableWindow(control, i == activeIndex); + + if (defaultValues[i][j] != NULL) + { + if (i == activeIndex) + { + if (Edit_GetTextLength(control) == 0) + { + /* remember that we set that value */ + Edit_SetText(control, defaultValues[i][j]); + controlWithDefValue= switchedFields[i][j]; + } + } + else if (controlWithDefValue == switchedFields[i][j]) + { + /* we don't want to store the value we set instead of user */ + Edit_SetText(control,L""); + } + } + } +} +#undef SWITCHED_GROUPS +#undef MAX_GROUP_COTROLS + + void InitStaticValues() { BusyIndicator = true; @@ -89,10 +139,12 @@ gHelpButtonPressedCallback = NULL; } + #define Refresh(A) RedrawWindow(A,NULL,NULL,RDW_ERASE|RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_UPDATENOW); BOOL FormMain_DlgProc (HWND, UINT, WPARAM, LPARAM); + void DoEvents (void) { MSG Msg; @@ -103,8 +155,10 @@ } } + VOID OnWMNotify(WPARAM wParam, LPARAM lParam); + static BOOL FormMain_OnNotify (HWND hwnd, WPARAM wParam, LPARAM lParam) { OnWMNotify(wParam, lParam); @@ -128,10 +182,10 @@ break; } - return FALSE; } + void getStrFieldData(HWND hwnd, SQLWCHAR **param, int idc) { x_free(*param); @@ -147,6 +201,7 @@ } } + void getStrFieldData(SQLWCHAR **param, unsigned int framenum, int idc ) { assert(TabCtrl_1.hTabPages); @@ -157,6 +212,7 @@ getStrFieldData(tab, param, idc ); } + void setUnsignedFieldData(HWND hwnd, unsigned int & param, int idc ) { wchar_t buf[20]; @@ -164,6 +220,7 @@ Edit_SetText(GetDlgItem(hwnd,idc), buf); } + void getUnsignedFieldData( HWND hwnd, unsigned int & param, int idc ) { param = 0U; @@ -182,6 +239,7 @@ } } + bool getBoolFieldData(unsigned int framenum, int idc) { assert(TabCtrl_1.hTabPages); @@ -194,6 +252,7 @@ return false; } + #define GET_STRING(name) getStrFieldData(hwnd,¶ms.name,IDC_EDIT_##name) #define SET_STRING(name) \ @@ -211,6 +270,7 @@ #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); @@ -220,8 +280,11 @@ GET_STRING(uid); GET_STRING(pwd); GET_STRING(database); + GET_STRING(socket); + params.force_use_of_named_pipes = !!Button_GetCheck(GetDlgItem(hwnd, IDC_RADIO_pipe)); } + void syncForm(HWND hwnd, DataSource ¶ms) { SET_STRING(name); @@ -231,14 +294,23 @@ SET_STRING(uid); SET_STRING(pwd); SET_STRING(database); + SET_STRING(socket); + + if (params.force_use_of_named_pipes) + Button_SetCheck(GetDlgItem(hwnd,IDC_RADIO_pipe), TRUE); + else + Button_SetCheck(GetDlgItem(hwnd,IDC_RADIO_tcp), TRUE); + SwitchTcpOrPipe(hwnd, pParams->force_use_of_named_pipes); } + + void syncTabsData(HWND hwnd, DataSource ¶ms) { /* 1 - Connection */ GET_BOOL(CONNECTION_TAB, allow_big_results); GET_BOOL(CONNECTION_TAB, use_compressed_protocol); GET_BOOL(CONNECTION_TAB, dont_prompt_upon_connect); GET_BOOL(CONNECTION_TAB, auto_reconnect); - GET_BOOL(CONNECTION_TAB, force_use_of_named_pipes); +// GET_BOOL(CONNECTION_TAB, force_use_of_named_pipes); GET_BOOL(CONNECTION_TAB, allow_multiple_statements); GET_BOOL(CONNECTION_TAB, clientinteractive); @@ -284,6 +356,7 @@ GET_BOOL(MISC_TAB, min_date_to_zero); } + void syncTabs(HWND hwnd, DataSource ¶ms) { /* 1 - Connection */ @@ -291,7 +364,7 @@ SET_BOOL(CONNECTION_TAB, use_compressed_protocol); SET_BOOL(CONNECTION_TAB, dont_prompt_upon_connect); SET_BOOL(CONNECTION_TAB, auto_reconnect); - SET_BOOL(CONNECTION_TAB, force_use_of_named_pipes); +// SET_BOOL(CONNECTION_TAB, force_use_of_named_pipes); SET_BOOL(CONNECTION_TAB, allow_multiple_statements); SET_BOOL(CONNECTION_TAB, clientinteractive); @@ -347,6 +420,7 @@ SET_BOOL(MISC_TAB, min_date_to_zero); } + void FillParameters(HWND hwnd, DataSource & params) { syncData(hwnd, params ); @@ -355,8 +429,10 @@ syncTabsData(hwnd, params); } + void OnDialogClose(); + void FormMain_OnClose(HWND hwnd) { //PostQuitMessage(0);// turn off message loop @@ -367,6 +443,7 @@ EndDialog(hwnd, NULL); } + /**************************************************************************** * * * Functions: FormMain_OnCommand related event code * @@ -377,7 +454,6 @@ * 00/00/00 Created * * * ****************************************************************************/ - void btnDetails_Click (HWND hwnd) { RECT rect; @@ -409,6 +485,7 @@ MoveWindow( hwnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top + 280*mod, TRUE ); } + void btnOk_Click (HWND hwnd) { FillParameters(hwnd, *pParams); @@ -421,11 +498,13 @@ } } + void btnCancel_Click (HWND hwnd) { PostMessage(hwnd, WM_CLOSE, NULL, NULL); } + void btnTest_Click (HWND hwnd) { FillParameters(hwnd, *pParams); @@ -441,6 +520,7 @@ ShellExecute(NULL, L"open", L"http://dev.mysql.com/doc/refman/6.0/en/myodbc-configuration-dsn-windows.html" , NULL, NULL, SW_SHOWNORMAL); } + void chooseFile( HWND parent, int hostCtlId ) { OPENFILENAMEW dialog; @@ -472,6 +552,7 @@ } } + void choosePath( HWND parent, int hostCtlId ) { HWND hostControl = GetDlgItem( parent, hostCtlId ); @@ -603,6 +684,10 @@ void FormMain_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { + if (controlWithDefValue != 0 && id == controlWithDefValue + && codeNotify==EN_CHANGE) + controlWithDefValue= 0; + switch (id) { case IDOK: @@ -623,6 +708,10 @@ chooseFile( hwnd, IDC_EDIT_sslca ); break; case IDC_SSLCAPATHCHOOSER: choosePath( hwnd, IDC_EDIT_sslcapath ); break; + case IDC_RADIO_tcp: + case IDC_RADIO_pipe: + SwitchTcpOrPipe(hwnd, !!Button_GetCheck(GetDlgItem(hwnd, IDC_RADIO_pipe))); + break; case IDC_EDIT_name: { if (codeNotify==EN_CHANGE) @@ -646,14 +735,17 @@ return; } + void AlignWindowToBottom(HWND hwnd, int dY); void AdjustLayout(HWND hwnd); + void FormMain_OnSize(HWND hwnd, UINT state, int cx, int cy) { AdjustLayout(hwnd); } + void AdjustLayout(HWND hwnd) { RECT rc; @@ -678,6 +770,7 @@ Refresh(hwnd); } + void AlignWindowToBottom(HWND hwnd, int dY) { if(!hwnd) @@ -698,9 +791,11 @@ MoveWindow(hwnd, rect.left, rc.top -dY-h,w,h,FALSE); } + HWND g_hwndDlg; BOOL DoCreateDialogTooltip(void); + BOOL FormMain_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { g_hwndDlg = hwnd; @@ -718,13 +813,17 @@ { EnableWindow(GetDlgItem(hwnd, IDC_EDIT_name), FALSE); EnableWindow(GetDlgItem(hwnd, IDC_EDIT_description), FALSE); + } + /* if prompting without DSN, don't disable OK button */ - if (!pParams->name) + /* preserved here old logic + enabled OK if data source + name is not NULL when not prompting. I don't know why it should be disabled + when prompting and name is not NULL. */ + if (g_isPrompt == (pParams->name==NULL)) { Button_Enable(GetDlgItem(hwnd,IDOK), 1); Button_Enable(GetDlgItem(hwnd,IDC_BUTTON_TEST), 1); RedrawWindow(hwnd,NULL,NULL,RDW_INVALIDATE); - } } BOOL b = DoCreateDialogTooltip(); === modified file 'setupgui/windows/odbcdialogparams.rc' --- setupgui/windows/odbcdialogparams.rc 2010-04-13 06:56:43 +0000 +++ setupgui/windows/odbcdialogparams.rc 2010-04-19 13:05:23 +0000 @@ -61,27 +61,30 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN GROUPBOX "Connection Parameters",IDC_STATIC,18,53,248,148 - EDITTEXT IDC_EDIT_name,98,69,143,14,ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_description,98,89,143,14,ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_server,98,121,85,14,ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_port,212,121,28,14,ES_AUTOHSCROLL | ES_NUMBER - EDITTEXT IDC_EDIT_uid,98,140,85,14,ES_AUTOHSCROLL - EDITTEXT IDC_EDIT_pwd,98,158,85,14,ES_PASSWORD | ES_AUTOHSCROLL - RTEXT "Data Source Name:",IDC_STATIC,23,72,67,8 - RTEXT "Description:",IDC_STATIC,23,92,67,8 - RTEXT "Server:",IDC_STATIC,23,123,67,8 - RTEXT "Port:",IDC_STATIC,187,123,19,8 + EDITTEXT IDC_EDIT_name,98,64,143,14,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_description,98,83,143,14,ES_AUTOHSCROLL + GROUPBOX "",IDC_STATIC,31,105,59,26,NOT WS_VISIBLE + CONTROL "TCP/IP Server:",IDC_RADIO_tcp,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,32,105,60,13 + CONTROL "Named Pipe:",IDC_RADIO_pipe,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,32,122,60,13 + EDITTEXT IDC_EDIT_server,98,104,85,14,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_port,212,104,28,14,ES_AUTOHSCROLL | ES_NUMBER + EDITTEXT IDC_EDIT_socket,98,123,85,14,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_uid,98,142,85,14,ES_AUTOHSCROLL + EDITTEXT IDC_EDIT_pwd,98,161,85,14,ES_PASSWORD | ES_AUTOHSCROLL + RTEXT "Data Source Name:",IDC_STATIC,23,68,67,8 + RTEXT "Description:",IDC_STATIC,23,87,67,8 + RTEXT "Port:",IDC_STATIC,187,107,19,8 RTEXT "User:",IDC_STATIC,23,143,67,8 - RTEXT "Password:",IDC_STATIC,23,162,67,8 - RTEXT "Database:",IDC_STATIC,23,179,67,8 + RTEXT "Password:",IDC_STATIC,23,164,67,8 + RTEXT "Database:",IDC_STATIC,23,182,67,8 + COMBOBOX IDC_EDIT_database,98,180,85,42,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP CONTROL "",IDC_TAB1,"SysTabControl32",WS_TABSTOP,17,214,249,154 DEFPUSHBUTTON "OK",IDOK,111,375,50,15 PUSHBUTTON "&Cancel",IDCANCEL,165,375,50,15 - PUSHBUTTON "&Test",IDC_BUTTON_TEST,199,175,41,14 + PUSHBUTTON "&Test",IDC_BUTTON_TEST,199,179,41,14 PUSHBUTTON "&Details >>",IDC_BUTTON_DETAILS,17,376,50,14 PUSHBUTTON "&Help",IDC_BUTTON_HELP,217,375,49,15 CONTROL 130,IDC_STATIC,"Static",SS_BITMAP,0,0,279,39 - COMBOBOX IDC_EDIT_database,98,176,85,42,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP END IDD_TAB1 DIALOGEX 0, 0, 209, 151 @@ -96,18 +99,18 @@ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,42,105,10 CONTROL "Don't prompt when connecting",IDC_CHECK_dont_prompt_upon_connect, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,57,113,10 - CONTROL "Force use of named pipes",IDC_CHECK_force_use_of_named_pipes, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,72,98,10 CONTROL "Allow multiple statements",IDC_CHECK_allow_multiple_statements, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,87,97,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,72,97,10 + CONTROL "Interactive Client",IDC_CHECK_clientinteractive, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,87,79,10 RTEXT "Character Set:",IDC_STATIC,12,102,67,8 COMBOBOX IDC_EDIT_charset,90,102,97,8,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP RTEXT "Initial Statement:",IDC_STATIC,12,117,67,8 EDITTEXT IDC_EDIT_initstmt,90,117,97,12,ES_AUTOHSCROLL // Second Column - CONTROL "Interactive Client",IDC_CHECK_clientinteractive, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,130,12,79,10 +// CONTROL "Interactive Client",IDC_CHECK_clientinteractive, +// "Button",BS_AUTOCHECKBOX | WS_TABSTOP,130,12,79,10 END === modified file 'setupgui/windows/resource.h' --- setupgui/windows/resource.h 2010-04-13 06:56:43 +0000 +++ setupgui/windows/resource.h 2010-04-19 12:58:19 +0000 @@ -100,7 +100,7 @@ #define IDC_CHECK_pad_char_to_full_length2 10022 #define IDC_CHECK_zero_date_to_min 10022 #define IDC_CHECK_ignore_space_after_function_names 10023 -#define IDC_CHECK_force_use_of_named_pipes 10024 +//#define IDC_CHECK_force_use_of_named_pipes 10024 #define IDC_CHECK_no_catalog 10025 #define IDC_CHECK_read_options_from_mycnf 10026 #define IDC_CHECK_disable_transactions 10027 @@ -118,6 +118,9 @@ #define IDC_EDIT_initstmt 10039 #define IDC_CHECK_clientinteractive 10040 #define IDC_CHECK_no_information_schema 10041 +#define IDC_EDIT_socket 10042 +#define IDC_RADIO_tcp 10043 +#define IDC_RADIO_pipe 10044 #define IDC_BUTTON_TEST 11014 #define IDC_BUTTON_HELP 11015 #define IDC_STATIC -1