Пример #1
0
BOOL CALLBACK FirmConfig_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam)
{
	int i,j;
	char tempstring[256];
	switch(komunikat)
	{
		case WM_INITDIALOG:
                ReadConfig();
				for(i=0;i<6;i++) SendDlgItemMessage(dialog,IDC_COMBO4,CB_ADDSTRING,0,(LPARAM)&firmLang[i]);
				for(i=0;i<12;i++) SendDlgItemMessage(dialog,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)&firmMonth[i]);
				for(i=0;i<16;i++) SendDlgItemMessage(dialog,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)&firmColor[i]);
				for(i=0;i<31;i++) SendDlgItemMessage(dialog,IDC_COMBO3,CB_ADDSTRING,0,(LPARAM)&firmDay[i]);
				SendDlgItemMessage(dialog,IDC_COMBO1,CB_SETCURSEL,firmware.favColor,0);
				SendDlgItemMessage(dialog,IDC_COMBO2,CB_SETCURSEL,firmware.bMonth-1,0);
				SendDlgItemMessage(dialog,IDC_COMBO3,CB_SETCURSEL,firmware.bDay-1,0);
				SendDlgItemMessage(dialog,IDC_COMBO4,CB_SETCURSEL,firmware.language,0);
				SendDlgItemMessage(dialog,IDC_EDIT1,EM_SETLIMITTEXT,10,0);
				SendDlgItemMessage(dialog,IDC_EDIT2,EM_SETLIMITTEXT,26,0);
				SendDlgItemMessage(dialog,IDC_EDIT1,EM_SETSEL,0,10);
				SendDlgItemMessage(dialog,IDC_EDIT2,EM_SETSEL,0,26);
				SendDlgItemMessage(dialog,IDC_EDIT1,EM_REPLACESEL,0,(LPARAM)&firmware.nickName);
				SendDlgItemMessage(dialog,IDC_EDIT2,EM_REPLACESEL,0,(LPARAM)&firmware.message);
				break;
	
		case WM_COMMAND:
				if((HIWORD(wparam)==BN_CLICKED)&&(((int)LOWORD(wparam))==IDOK))
				{
				firmware.favColor=SendDlgItemMessage(dialog,IDC_COMBO1,CB_GETCURSEL,0,0);
				firmware.bMonth=1+SendDlgItemMessage(dialog,IDC_COMBO2,CB_GETCURSEL,0,0);
				firmware.bDay=1+SendDlgItemMessage(dialog,IDC_COMBO3,CB_GETCURSEL,0,0);
				firmware.language=SendDlgItemMessage(dialog,IDC_COMBO4,CB_GETCURSEL,0,0);
				SendDlgItemMessage(dialog,IDC_EDIT1,EM_GETLINE,0,(LPARAM)&firmware.nickName);
				SendDlgItemMessage(dialog,IDC_EDIT2,EM_GETLINE,0,(LPARAM)&firmware.message);
				WriteFirmConfig();
				EndDialog(dialog,0);
				return 1;
				}
				else
				if((HIWORD(wparam)==BN_CLICKED)&&(((int)LOWORD(wparam))==IDCANCEL))
				{
                EndDialog(dialog, 0);
                return 0;
                }
		        break;
	}
	return 0;
}
Пример #2
0
BOOL CALLBACK FirmConfig_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam)
{
	FirmwareConfig &fwConfig = CommonSettings.fwConfig;
	int i;
	char temp_str[27];

	switch(komunikat)
	{
		case WM_INITDIALOG:
				for(i=0;i<6;i++) SendDlgItemMessage(dialog,IDC_COMBO4,CB_ADDSTRING,0,(LPARAM)&firmLang[i]);
				for(i=0;i<12;i++) SendDlgItemMessage(dialog,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)&firmMonth[i]);
				for(i=0;i<16;i++) SendDlgItemMessage(dialog,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)&firmColor[i]);
				for(i=0;i<31;i++) SendDlgItemMessage(dialog,IDC_COMBO3,CB_ADDSTRING,0,(LPARAM)&firmDay[i]);
				SendDlgItemMessage(dialog,IDC_COMBO1,CB_SETCURSEL,fwConfig.favoriteColor,0);
				SendDlgItemMessage(dialog,IDC_COMBO2,CB_SETCURSEL,fwConfig.birthdayMonth-1,0);
				SendDlgItemMessage(dialog,IDC_COMBO3,CB_SETCURSEL,fwConfig.birthdayDay-1,0);
				SendDlgItemMessage(dialog,IDC_COMBO4,CB_SETCURSEL,fwConfig.language,0);
				SendDlgItemMessage(dialog,IDC_EDIT1,EM_SETLIMITTEXT,10,0);
				SendDlgItemMessage(dialog,IDC_EDIT2,EM_SETLIMITTEXT,26,0);
				SendDlgItemMessage(dialog,IDC_EDIT1,EM_SETSEL,0,10);
				SendDlgItemMessage(dialog,IDC_EDIT2,EM_SETSEL,0,26);

				for ( i = 0; i < fwConfig.nicknameLength; i++) {
					nickname_buffer[i] = fwConfig.nickname[i];
				}
				nickname_buffer[i] = '\0';
				SendDlgItemMessage(dialog,IDC_EDIT1,WM_SETTEXT,0,(LPARAM)nickname_buffer);

				for ( i = 0; i < fwConfig.messageLength; i++) {
					message_buffer[i] = fwConfig.message[i];
				}
				message_buffer[i] = '\0';
				SendDlgItemMessage(dialog,IDC_EDIT2,WM_SETTEXT,0,(LPARAM)message_buffer);
				break;
	
		case WM_COMMAND:
				if((HIWORD(wparam)==BN_CLICKED)&&(((int)LOWORD(wparam))==IDOK))
				{
					int char_index;
					LRESULT res;
				fwConfig.favoriteColor = SendDlgItemMessage(dialog,IDC_COMBO1,CB_GETCURSEL,0,0);
				fwConfig.birthdayMonth = 1 + SendDlgItemMessage(dialog,IDC_COMBO2,CB_GETCURSEL,0,0);
				fwConfig.birthdayDay = 1 + SendDlgItemMessage(dialog,IDC_COMBO3,CB_GETCURSEL,0,0);
				fwConfig.language = SendDlgItemMessage(dialog,IDC_COMBO4,CB_GETCURSEL,0,0);

				*(WORD *)temp_str = 10;
				res = SendDlgItemMessage(dialog,IDC_EDIT1,EM_GETLINE,0,(LPARAM)temp_str);

				if ( res > 0) {
					temp_str[res] = '\0';
					fwConfig.nicknameLength = strlen( temp_str);
				}
				else {
					strcpy( temp_str, "yopyop");
					fwConfig.nicknameLength = strlen( temp_str);
				}
				for ( char_index = 0; char_index < fwConfig.nicknameLength; char_index++) {
					fwConfig.nickname[char_index] = temp_str[char_index];
				}

				*(WORD *)temp_str = 26;
				res = SendDlgItemMessage(dialog,IDC_EDIT2,EM_GETLINE,0,(LPARAM)temp_str);
				if ( res > 0) {
					temp_str[res] = '\0';
					fwConfig.messageLength = strlen( temp_str);
				}
				else {
					fwConfig.messageLength = 0;
				}
				for ( char_index = 0; char_index < fwConfig.messageLength; char_index++) {
					fwConfig.message[char_index] = temp_str[char_index];
				}

				WriteFirmConfig(fwConfig);
				EndDialog(dialog,0);
				return 1;
				}
				else
				if((HIWORD(wparam)==BN_CLICKED)&&(((int)LOWORD(wparam))==IDCANCEL))
				{
                EndDialog(dialog, 0);
                return 0;
                }
		        break;
	}
	return 0;
}