Esempio n. 1
0
int populate_options(HWND hwnd)
{
	int i;
	char tmp[80];
	SendDlgItemMessage(hwnd,IDC_SELECT_OPEN,CB_RESETCONTENT,0,0);
	for(i=0;i<max_open_with;i++){
		_snprintf(tmp,sizeof(tmp),"%i",i+1);
		SendDlgItemMessage(hwnd,IDC_SELECT_OPEN,CB_ADDSTRING,0,tmp);
	}
	i=0;
	get_ini_value("OPTIONS","select_open_index",&i);
	SendDlgItemMessage(hwnd,IDC_SELECT_OPEN,CB_SETCURSEL,i,0);
	populate_caption_open(hwnd);

	SendDlgItemMessage(hwnd,IDC_COMBO_FONT,CB_RESETCONTENT,0,0);
	add_fonts(hwnd,IDC_COMBO_FONT);
	get_current_font(hwnd,IDC_COMBO_FONT);

	SendDlgItemMessage(hwnd,IDC_LISTBOX_FONT,CB_RESETCONTENT,0,0);
	add_fonts(hwnd,IDC_LISTBOX_FONT);
	get_current_font(hwnd,IDC_LISTBOX_FONT);

	i=20;
	get_ini_value("OPTIONS","match_prefix_len",&i);
	SetDlgItemInt(hwnd,IDC_MATCH_PREFIX_LEN,i,FALSE);
	i=FALSE;
	get_ini_value("OPTIONS","show_column",&i);
	if(i!=0)
		i=BST_CHECKED;
	else
		i=BST_UNCHECKED;
	CheckDlgButton(hwnd,IDC_SHOW_COLUMN,i);
	return TRUE;
}
Esempio n. 2
0
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;
}