// read out all controls, and if value is altered, remember it and send it to the engine\r
{\r
HANDLE hwndCombo;\r
- int i, k, new=0, changed=0;\r
- char **choices, newText[MSG_SIZ], buf[MSG_SIZ];\r
+ int i, k, new=0, changed=0, len;\r
+ char **choices, newText[MSG_SIZ], buf[MSG_SIZ], *text;\r
BOOL success;\r
\r
for(i=0; i<layout; i++) {\r
case TextBox:\r
case FileName:\r
case PathName:\r
- success = GetDlgItemText( hDlg, 2001+2*i, newText, MSG_SIZ - strlen(optionList[j].name) - 9 );\r
+ if(cps) len = MSG_SIZ - strlen(optionList[j].name) - 9, text = newText;\r
+ else len = GetWindowTextLength(GetDlgItem(hDlg, 2001+2*i)) + 1, text = (char*) malloc(len);\r
+ success = GetDlgItemText( hDlg, 2001+2*i, text, len );\r
if(!success) break;\r
if(!cps) {\r
+ char *p;\r
if(*(char**)optionList[j].target) free(*(char**)optionList[j].target);\r
- *(char**)optionList[j].target = strdup(newText);\r
+ *(char**)optionList[j].target = p = text;\r
+ while(*p++ = *text++) if(p[-1] == '\r') p--; // crush CR\r
break;\r
}\r
changed = strcmp(optionList[j].textValue, newText) != 0;\r
if(!cps && okFunc) ((ButtonCallback*) okFunc)(0);\r
}\r
\r
+char *defaultExt[] = { NULL, "pgn", "fen", "exe", "trn", "bin", "log", "ini" };\r
+\r
LRESULT CALLBACK SettingsProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
{\r
char buf[MSG_SIZ];\r
- int i, j;\r
+ int i, j, ext;\r
\r
switch( message )\r
{\r
ofn.hwndOwner = hDlg;\r
ofn.hInstance = hInst;\r
ofn.lpstrFilter = filter;\r
- ofn.nFilterIndex = 1L + (activeCps ? 0 : activeList[layoutList[(i-2000)/2+1]].max);\r
+ ofn.nFilterIndex = 1L + (ext = activeCps ? 0 : activeList[layoutList[(i-2000)/2+1]].max);\r
+ ofn.lpstrDefExt = defaultExt[ext];\r
ofn.lpstrFile = buf;\r
ofn.nMaxFile = sizeof(buf);\r
ofn.lpstrTitle = _("Choose File");\r
{ 0, 0, 4, NULL, (void*) &appData.tourneyFile, "", NULL, FileName, N_("Tournament file:") },\r
{ 0, 1, 0, NULL, (void*) &engineChoice, (char*) (engineMnemonic+1), (engineMnemonic+1), ComboBox, N_("Select Engine:") },\r
{ 0xD, 7, 0, NULL, (void*) &engineName, "", NULL, TextBox, "Tourney participants:" },\r
- { 0, -1, 10, NULL, (void*) &appData.tourneyType, "", NULL, Spin, N_("Tourney type (0=RR, 1=gauntlet):") },\r
+ { 0, 0, 10, NULL, (void*) &appData.tourneyType, "", NULL, Spin, N_("Tourney type (0=RR, 1=gauntlet):") },\r
{ 0, 0, 0, NULL, (void*) &appData.cycleSync, "", NULL, CheckBox, N_("Sync after cycle") },\r
{ 0, 1, 1000000000, NULL, (void*) &appData.tourneyCycles, "", NULL, Spin, N_("Number of tourney cycles:") },\r
{ 0, 0, 0, NULL, (void*) &appData.roundSync, "", NULL, CheckBox, N_("Sync after round") },\r
// strncat(buf, "\r\n", MSG_SIZ);\r
int i = ComboBox_GetCurSel(GetDlgItem(hDlg, 2001+2*3));\r
snprintf(buf, MSG_SIZ, "%s\r\n", engineMnemonic[i+1]);\r
- SendMessage( GetDlgItem(hDlg, 2001+2*5), EM_SETSEL, 0, 0 );\r
+ SendMessage( GetDlgItem(hDlg, 2001+2*5), EM_SETSEL, 99999, 99999 );\r
SendMessage( GetDlgItem(hDlg, 2001+2*5), EM_REPLACESEL, (WPARAM) FALSE, (LPARAM) buf );\r
}\r
\r