コード例 #1
0
int save_options(HWND hwnd)
{
	char str[MAX_PATH*2];
	char key[80];
	int index,val;

	index=SendDlgItemMessage(hwnd,IDC_SELECT_OPEN,CB_GETCURSEL,0,0);
	if(index<0 || index>10)
		index=0;
	index++;
	str[0]=0;
	GetDlgItemText(hwnd,IDC_OPEN1,str,sizeof(str));
	quote_to_pipe_char(str);
	_snprintf(key,sizeof(key),"open%i",index);
	write_ini_str("OPTIONS",key,str);
	str[0]=0;
	GetDlgItemText(hwnd,IDC_CAPTION,str,sizeof(str));
	_snprintf(key,sizeof(key),"caption%i",index);
	write_ini_str("OPTIONS",key,str);

	save_select_open(hwnd);

	str[0]=0;
	GetDlgItemText(hwnd,IDC_MATCH_PREFIX_LEN,str,sizeof(str));
	val=atoi(str);
	if(val<0)val=0;
	if(val>512)val=512;
	write_ini_value("OPTIONS","match_prefix_len",val);

	if(IsDlgButtonChecked(hwnd,IDC_SHOW_COLUMN)==BST_CHECKED)
		val=1;
	else
		val=0;
	write_ini_value("OPTIONS","show_column",val);

	key[0]=0;
	get_dropdown_name(IDC_COMBO_FONT,key,sizeof(key));
	str[0]=0;
	GetDlgItemText(hwnd,IDC_COMBO_FONT,str,sizeof(str));
	write_ini_str("OPTIONS",key,str);

	key[0]=0;
	get_dropdown_name(IDC_LISTBOX_FONT,key,sizeof(key));
	str[0]=0;
	GetDlgItemText(hwnd,IDC_LISTBOX_FONT,str,sizeof(str));
	write_ini_str("OPTIONS",key,str);

	return TRUE;
}
コード例 #2
0
int set_ini_entry(char *section,int num,char *str)
{
	char key[20];
	_snprintf(key,sizeof(key),"ENTRY%02i",num);
	if(str==NULL)
		return delete_ini_key(section,key);
	return write_ini_str(section,key,str);
}
コード例 #3
0
ファイル: settings.c プロジェクト: pinchyCZN/DB_UTIL
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;
}