int get_font_setting(int ctrl) { char tmp[80]={0}; char key[80]={0}; get_control_name(ctrl,key,sizeof(key)); get_ini_str(INI_SETTINGS,key,tmp,sizeof(tmp)); return fontname_to_int(tmp); }
int populate_caption_open(HWND hwnd){ char str[MAX_PATH*2]; char key[80]; int index; index=SendDlgItemMessage(hwnd,IDC_SELECT_OPEN,CB_GETCURSEL,0,0); if(index<0 || index>max_open_with) index=0; index++; _snprintf(key,sizeof(key),"open%i",index); str[0]=0; get_ini_str("OPTIONS",key,str,sizeof(str)); pipe_to_quote(str); SetDlgItemText(hwnd,IDC_OPEN1,str); _snprintf(key,sizeof(key),"caption%i",index); str[0]=0; get_ini_str("OPTIONS",key,str,sizeof(str)); SetDlgItemText(hwnd,IDC_CAPTION,str); return TRUE; }
int select_current_font(HWND hwnd,int ctrl) { char tmp[80]; char key[80]; int index; key[0]=0; get_control_name(ctrl,key,sizeof(key)); tmp[0]=0; get_ini_str(INI_SETTINGS,key,tmp,sizeof(tmp)); index=SendDlgItemMessage(hwnd,ctrl,CB_FINDSTRINGEXACT,-1,tmp); if(index<0)index=0; SendDlgItemMessage(hwnd,ctrl,CB_SETCURSEL,index,0); return TRUE; }
int get_current_font(HWND hwnd,int ctrl) { char tmp[80]; char key[80]; int index; key[0]=0; get_dropdown_name(ctrl,key,sizeof(key)); tmp[0]=0; get_ini_str("OPTIONS",key,tmp,sizeof(tmp)); index=SendDlgItemMessage(hwnd,ctrl,CB_FINDSTRINGEXACT,-1,tmp); if(index<0){ int_to_fontname(DEFAULT_GUI_FONT,tmp,sizeof(tmp)); index=SendDlgItemMessage(hwnd,ctrl,CB_FINDSTRINGEXACT,-1,tmp); } SendDlgItemMessage(hwnd,ctrl,CB_SETCURSEL,index,0); return TRUE; }
int set_context_font(HWND hwnd) { int font; char key[80]; char font_name[80]; if(binary) font=ANSI_FIXED_FONT; else{ key[0]=0; get_dropdown_name(IDC_LISTBOX_FONT,key,sizeof(key)); font_name[0]=0; get_ini_str("OPTIONS",key,font_name,sizeof(font_name)); font=fontname_to_int(font_name); } SendDlgItemMessage(hwnd,IDC_ROWNUMBER,WM_SETFONT,GetStockObject(font),0); SendDlgItemMessage(hwnd,IDC_CONTEXT,WM_SETFONT,GetStockObject(font),0); return TRUE; }
int populate_buttons(HWND hwnd,HWND controller) { int i; int button; char str[255]; char key[40]; char config[80]; int x,y,w,h; RECT rect; if(init_list){ memset(guibuttons,0,sizeof(guibuttons)); init_list=FALSE; } sprintf(config,"CONFIG0"); i=SendMessage(controller,CB_GETCURSEL,0,0); SendMessage(controller,CB_GETLBTEXT,i,config); for(i=0;i<max_buttons;i++){ button=i+1; _snprintf(key,sizeof(key),"GUIB%u",button); memset(str,0,sizeof(str)); if(get_ini_str(config,key,str,sizeof(str))){ x=y=w=h=10; sscanf(str,"%u,%u,%u,%u",&x,&y,&w,&h); sprintf(str,"B%u",button); GetClientRect(hwnd,&rect); x=x*(rect.right-rect.left)/640; y=y*(rect.bottom-78-rect.top)/580; y+=78; w=w*(rect.right-rect.left)/640; h=h*(rect.bottom-rect.top)/580; if(guibuttons[i]==0){ guibuttons[i]=CreateWindow("BUTTON", str, WS_TABSTOP|WS_CHILD|WS_VISIBLE, x, y, w, h, hwnd, (HMENU)(2000+i), NULL, NULL); } else{ MoveWindow(guibuttons[i],x,y,w,h,TRUE); } } } return TRUE; }
int load_controller_image(HWND hwnd,BYTE *buf,int buf_size) { FILE *f; char config[MAX_PATH],fname[MAX_PATH]; int index,result=FALSE; index=SendMessage(hwnd,CB_GETCURSEL,0,0); memset(config,0,sizeof(config)); if(SendMessage(hwnd,CB_GETLBTEXT,index,(LPARAM)config)!=CB_ERR){ if(get_ini_str(config,"image",fname,sizeof(fname))){ f=fopen(fname,"rb"); if(f!=0){ fseek(f,0x36,SEEK_SET); fread(buf,1,buf_size,f); fclose(f); result=TRUE; } } } return result; }
int get_ini_entry(char *section,int num,char *str,int len) { char key[20]; _snprintf(key,sizeof(key),"ENTRY%02i",num); return get_ini_str(section,key,str,len); }
LRESULT CALLBACK settings_proc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam) { static HWND grippy=0; static int font_changed=FALSE; static int justify_changed=FALSE; switch(msg){ case WM_INITDIALOG: { extern int keep_closed; int val; get_ini_value(INI_SETTINGS,"KEEP_CLOSED",&keep_closed); if(!keep_closed) CheckDlgButton(hwnd,IDC_KEEP_CONNECTED,BST_CHECKED); val=0; get_ini_value(INI_SETTINGS,"SINGLE_INSTANCE",&val); if(val) CheckDlgButton(hwnd,IDC_SINGLE_INSTANCE,BST_CHECKED); val=0; get_ini_value(INI_SETTINGS,"DEBUG",&val); if(val) CheckDlgButton(hwnd,IDC_DEBUG,BST_CHECKED); get_ini_value(INI_SETTINGS,"TRIM_TRAILING",&trim_trailing); if(trim_trailing) CheckDlgButton(hwnd,IDC_TRIM_TRAILING,BST_CHECKED); get_ini_value(INI_SETTINGS,"LEFT_JUSTIFY",&left_justify); if(left_justify) CheckDlgButton(hwnd,IDC_LEFT_JUSTIFY,BST_CHECKED); get_ini_value(INI_SETTINGS,"SAVE_MDI_WIN_SIZE",&save_mdi_win_size); if(save_mdi_win_size) CheckDlgButton(hwnd,IDC_SAVE_MDI_WIN_SIZE,BST_CHECKED); add_fonts(hwnd,IDC_SQL_FONT); add_fonts(hwnd,IDC_LISTVIEW_FONT); add_fonts(hwnd,IDC_TREEVIEW_FONT); select_current_font(hwnd,IDC_SQL_FONT); select_current_font(hwnd,IDC_LISTVIEW_FONT); select_current_font(hwnd,IDC_TREEVIEW_FONT); font_changed=FALSE; justify_changed=FALSE; } grippy=create_grippy(hwnd); break; case WM_SIZE: grippy_move(hwnd,grippy); break; case WM_COMMAND: switch(LOWORD(wparam)){ case IDC_DEBUG: printf("debug %08X %08X\n",wparam,lparam); if(IsDlgButtonChecked(hwnd,IDC_DEBUG)==BST_CHECKED) open_console(); else hide_console(); break; case IDC_FILE_ASSOCIATIONS: DialogBoxParam(ghinstance,IDD_FILE_ASSOCIATIONS,hwnd,file_assoc_proc,0); break; case IDC_OPEN_INI: open_ini(hwnd,FALSE); break; case IDC_SQL_FONT: if(HIWORD(wparam)==CBN_SELENDOK){ int i,max=get_max_table_windows(); int font; char str[80]={0}; GetDlgItemText(hwnd,IDC_SQL_FONT,str,sizeof(str)); font=fontname_to_int(str); for(i=0;i<max;i++){ HWND hedit=0; if(get_win_hwnds(i,NULL,&hedit,NULL)){ SendMessage(hedit,WM_SETFONT,GetStockObject(font),0); InvalidateRect(hedit,NULL,TRUE); } } font_changed=TRUE; } break; case IDC_LISTVIEW_FONT: if(HIWORD(wparam)==CBN_SELENDOK){ int i,max=get_max_table_windows(); int font; char str[80]={0}; GetDlgItemText(hwnd,IDC_LISTVIEW_FONT,str,sizeof(str)); font=fontname_to_int(str); for(i=0;i<max;i++){ HWND hlistview; if(get_win_hwnds(i,NULL,NULL,&hlistview)){ SendMessage(hlistview,WM_SETFONT,GetStockObject(font),0); InvalidateRect(hlistview,NULL,TRUE); } } font_changed=TRUE; } break; case IDC_TREEVIEW_FONT: if(HIWORD(wparam)==CBN_SELENDOK){ extern HWND ghtreeview; int font; char str[80]={0}; GetDlgItemText(hwnd,IDC_TREEVIEW_FONT,str,sizeof(str)); font=fontname_to_int(str); if(ghtreeview!=0){ SendMessage(ghtreeview,WM_SETFONT,GetStockObject(font),0); InvalidateRect(ghtreeview,NULL,TRUE); } font_changed=TRUE; } break; case IDC_LEFT_JUSTIFY: if(HIWORD(wparam)==BN_CLICKED){ extern int left_justify; int i,max=get_max_table_windows(); if(IsDlgButtonChecked(hwnd,IDC_LEFT_JUSTIFY)==BST_CHECKED) left_justify=1; else left_justify=0; for(i=0;i<max;i++){ HWND hlistview; if(get_win_hwnds(i,NULL,NULL,&hlistview)) InvalidateRect(hlistview,NULL,TRUE); } justify_changed=TRUE; } break; case IDOK: { extern int keep_closed; char key[80],str[80]; int i,val,ctrls[3]={IDC_SQL_FONT,IDC_LISTVIEW_FONT,IDC_TREEVIEW_FONT}; if(IsDlgButtonChecked(hwnd,IDC_KEEP_CONNECTED)==BST_CHECKED) keep_closed=FALSE; else keep_closed=TRUE; write_ini_value(INI_SETTINGS,"KEEP_CLOSED",keep_closed); val=0; if(IsDlgButtonChecked(hwnd,IDC_SINGLE_INSTANCE)==BST_CHECKED) val=1; write_ini_value(INI_SETTINGS,"SINGLE_INSTANCE",val); set_single_instance(val); val=0; if(IsDlgButtonChecked(hwnd,IDC_DEBUG)==BST_CHECKED) val=1; write_ini_value(INI_SETTINGS,"DEBUG",val); if(IsDlgButtonChecked(hwnd,IDC_TRIM_TRAILING)==BST_CHECKED) trim_trailing=1; else trim_trailing=0; write_ini_value(INI_SETTINGS,"TRIM_TRAILING",trim_trailing); if(IsDlgButtonChecked(hwnd,IDC_LEFT_JUSTIFY)==BST_CHECKED) left_justify=1; else left_justify=0; write_ini_value(INI_SETTINGS,"LEFT_JUSTIFY",left_justify); if(IsDlgButtonChecked(hwnd,IDC_SAVE_MDI_WIN_SIZE)==BST_CHECKED) save_mdi_win_size=1; else save_mdi_win_size=0; write_ini_value(INI_SETTINGS,"SAVE_MDI_SIZE",save_mdi_win_size); for(i=0;i<sizeof(ctrls)/sizeof(int);i++){ key[0]=0; get_control_name(ctrls[i],key,sizeof(key)); str[0]=0; GetDlgItemText(hwnd,ctrls[i],str,sizeof(str)); write_ini_str(INI_SETTINGS,key,str); } } case IDCANCEL: if(font_changed){ int i,ctrls[3]={IDC_SQL_FONT,IDC_LISTVIEW_FONT,IDC_TREEVIEW_FONT}; for(i=0;i<sizeof(ctrls)/sizeof(int);i++){ char key[80],str[80]; key[0]=0; get_control_name(ctrls[i],key,sizeof(key)); str[0]=0; GetDlgItemText(hwnd,ctrls[i],str,sizeof(str)); get_ini_str(INI_SETTINGS,key,str,sizeof(str)); if(str[0]!=0){ int max=get_max_table_windows(); int font=fontname_to_int(str); if(ctrls[i]==IDC_SQL_FONT){ int j; for(j=0;j<max;j++){ HWND hedit=0; if(get_win_hwnds(j,NULL,&hedit,NULL)){ SendMessage(hedit,WM_SETFONT,GetStockObject(font),0); InvalidateRect(hedit,NULL,TRUE); } } } else if(ctrls[i]==IDC_LISTVIEW_FONT){ int j; for(j=0;j<max;j++){ HWND hlistview; if(get_win_hwnds(j,NULL,NULL,&hlistview)){ SendMessage(hlistview,WM_SETFONT,GetStockObject(font),0); InvalidateRect(hlistview,NULL,TRUE); } } } else if(ctrls[i]==IDC_TREEVIEW_FONT){ extern HWND ghtreeview; SendMessage(ghtreeview,WM_SETFONT,GetStockObject(font),0); } } } } if(justify_changed){ int i,max=get_max_table_windows(); get_ini_value(INI_SETTINGS,"LEFT_JUSTIFY",&left_justify); for(i=0;i<max;i++){ HWND hlistview; if(get_win_hwnds(i,NULL,NULL,&hlistview)) InvalidateRect(hlistview,NULL,TRUE); } } EndDialog(hwnd,0); break; } break; } return 0; }