Example #1
0
static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static bool bInitialized = false;
	static MCONTACT hSelectedContact = 0;

	switch (msg) {
	case WM_INITDIALOG:
		bInitialized = false;

		TranslateDialogDefault(hwnd);

		CheckDlgButton(hwnd, IDC_CHK_GROUPS, g_Options.bUseGroups ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwnd, IDC_CHK_GROUPCOLUMS, g_Options.bUseColumns ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwnd, IDC_CHK_SECONDLINE, g_Options.bSecondLine ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwnd, IDC_CHK_AVATARS, g_Options.bAvatars ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwnd, IDC_CHK_AVATARBORDER, g_Options.bAvatarBorder ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwnd, IDC_CHK_NOTRANSPARENTBORDER, g_Options.bNoTransparentBorder ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwnd, IDC_CHK_SYSCOLORS, g_Options.bSysColors ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwnd, IDC_CHK_CENTERHOTKEY, g_Options.bCenterHotkey ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwnd, IDC_CHK_RIGHTAVATARS, g_Options.bRightAvatars ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwnd, IDC_CHK_DIMIDLE, g_Options.bDimIdle ? BST_CHECKED : BST_UNCHECKED);
		SetDlgItemInt(hwnd, IDC_TXT_RADIUS, g_Options.wAvatarRadius, FALSE);
		SetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, g_Options.wMaxRecent, FALSE);

		SetWindowLongPtr(GetDlgItem(hwnd, IDC_CLIST), GWL_STYLE,
							  GetWindowLongPtr(GetDlgItem(hwnd, IDC_CLIST), GWL_STYLE) | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE | CLS_GROUPCHECKBOXES);
		SendMessage(GetDlgItem(hwnd, IDC_CLIST), CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT, 0);
		sttResetListOptions(GetDlgItem(hwnd, IDC_CLIST));

		hSelectedContact = db_find_first();
		{
			for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
				SendDlgItemMessage(hwnd, IDC_CLIST, CLM_SETCHECKMARK,
				SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0),
				db_get_b(hContact, "FavContacts", "IsFavourite", 0));
		}

		bInitialized = true;
		PostMessage(hwnd, WM_APP, 0, 0);
		return TRUE;

	case WM_APP:
		{
			BOOL bGroups = IsDlgButtonChecked(hwnd, IDC_CHK_GROUPS);
			EnableWindow(GetDlgItem(hwnd, IDC_CHK_GROUPCOLUMS), bGroups);

			BOOL bAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARS);
			BOOL bBorders = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARBORDER);
			EnableWindow(GetDlgItem(hwnd, IDC_CHK_AVATARBORDER), bAvatars);
			EnableWindow(GetDlgItem(hwnd, IDC_CHK_RIGHTAVATARS), bAvatars);
			EnableWindow(GetDlgItem(hwnd, IDC_CHK_NOTRANSPARENTBORDER), bAvatars && bBorders);
			EnableWindow(GetDlgItem(hwnd, IDC_TXT_RADIUS), bAvatars && bBorders);
		}
		return TRUE;

	case WM_DRAWITEM:
		{
			LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
			if (lpdis->CtlID == IDC_CANVAS) {
				MEASUREITEMSTRUCT mis = { 0 };
				DRAWITEMSTRUCT dis = *lpdis;

				FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_BTNFACE));
				if (hSelectedContact) {
					Options options;
					options.bSecondLine = IsDlgButtonChecked(hwnd, IDC_CHK_SECONDLINE);
					options.bAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARS);
					options.bAvatarBorder = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARBORDER);
					options.bNoTransparentBorder = IsDlgButtonChecked(hwnd, IDC_CHK_NOTRANSPARENTBORDER);
					options.bSysColors = IsDlgButtonChecked(hwnd, IDC_CHK_SYSCOLORS);
					options.bCenterHotkey = IsDlgButtonChecked(hwnd, IDC_CHK_CENTERHOTKEY);
					options.bRightAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_RIGHTAVATARS);
					options.bDimIdle = IsDlgButtonChecked(hwnd, IDC_CHK_DIMIDLE);
					options.wAvatarRadius = GetDlgItemInt(hwnd, IDC_TXT_RADIUS, NULL, FALSE);
					options.wMaxRecent = GetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, NULL, FALSE);

					mis.CtlID = 0;
					mis.CtlType = ODT_MENU;
					mis.itemData = (DWORD)hSelectedContact;
					MenuMeasureItem(&mis, &options);
					dis.rcItem.bottom = dis.rcItem.top + mis.itemHeight;

					dis.CtlID = 0;
					dis.CtlType = ODT_MENU;
					dis.itemData = (DWORD)hSelectedContact;
					MenuDrawItem(&dis, &options);

					RECT rc = lpdis->rcItem;
					rc.bottom = rc.top + mis.itemHeight;
					FrameRect(lpdis->hDC, &rc, GetSysColorBrush(COLOR_HIGHLIGHT));
				}
				return TRUE;
			}
		}
		return FALSE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_CHK_SECONDLINE:
		case IDC_CHK_AVATARS:
		case IDC_CHK_AVATARBORDER:
		case IDC_CHK_NOTRANSPARENTBORDER:
		case IDC_CHK_SYSCOLORS:
		case IDC_CHK_CENTERHOTKEY:
		case IDC_CHK_GROUPS:
		case IDC_CHK_GROUPCOLUMS:
		case IDC_CHK_RIGHTAVATARS:
			SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
			RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), NULL, NULL, RDW_INVALIDATE);
			PostMessage(hwnd, WM_APP, 0, 0);
			break;

		case IDC_BTN_FONTS:
		{
			OPENOPTIONSDIALOG ood = { sizeof(ood) };
			ood.pszGroup = "Customize";
			ood.pszPage = "Fonts and colors";
			ood.pszTab = NULL;
			Options_Open(&ood);
		}
			break;

		case IDC_TXT_RADIUS:
			if ((HIWORD(wParam) == EN_CHANGE) && bInitialized) {
				RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), NULL, NULL, RDW_INVALIDATE);
				SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
			}
			break;

		case IDC_TXT_MAXRECENT:
			if ((HIWORD(wParam) == EN_CHANGE) && bInitialized)
				SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
			break;
		}
		break;

	case WM_NOTIFY:
		if ((((LPNMHDR)lParam)->idFrom == 0) && (((LPNMHDR)lParam)->code == PSN_APPLY)) {
			g_Options.bSecondLine = IsDlgButtonChecked(hwnd, IDC_CHK_SECONDLINE);
			g_Options.bAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARS);
			g_Options.bAvatarBorder = IsDlgButtonChecked(hwnd, IDC_CHK_AVATARBORDER);
			g_Options.bNoTransparentBorder = IsDlgButtonChecked(hwnd, IDC_CHK_NOTRANSPARENTBORDER);
			g_Options.bSysColors = IsDlgButtonChecked(hwnd, IDC_CHK_SYSCOLORS);
			g_Options.bCenterHotkey = IsDlgButtonChecked(hwnd, IDC_CHK_CENTERHOTKEY);
			g_Options.bUseGroups = IsDlgButtonChecked(hwnd, IDC_CHK_GROUPS);
			g_Options.bUseColumns = IsDlgButtonChecked(hwnd, IDC_CHK_GROUPCOLUMS);
			g_Options.bRightAvatars = IsDlgButtonChecked(hwnd, IDC_CHK_RIGHTAVATARS);
			g_Options.bDimIdle = IsDlgButtonChecked(hwnd, IDC_CHK_DIMIDLE);
			g_Options.wAvatarRadius = GetDlgItemInt(hwnd, IDC_TXT_RADIUS, NULL, FALSE);
			g_Options.wMaxRecent = GetDlgItemInt(hwnd, IDC_TXT_MAXRECENT, NULL, FALSE);

			sttSaveOptions();

			for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
				BYTE fav = SendDlgItemMessage(hwnd, IDC_CLIST, CLM_GETCHECKMARK,
														SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0), 0);
				if (fav != db_get_b(hContact, "FavContacts", "IsFavourite", 0))
					db_set_b(hContact, "FavContacts", "IsFavourite", fav);
				if (fav) CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
			}
		}
		else if (((LPNMHDR)lParam)->idFrom == IDC_CLIST) {
			int iSelection;

			switch (((LPNMHDR)lParam)->code) {
			case CLN_OPTIONSCHANGED:
				sttResetListOptions(GetDlgItem(hwnd, IDC_CLIST));
				break;

			case CLN_NEWCONTACT:
				iSelection = (int)((NMCLISTCONTROL *)lParam)->hItem;
				for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
					if (SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0) == iSelection) {
						SendDlgItemMessage(hwnd, IDC_CLIST, CLM_SETCHECKMARK, iSelection,
												 db_get_b(hContact, "FavContacts", "IsFavourite", 0));
						break;
					}
				}
				break;

			case CLN_CHECKCHANGED:
				iSelection = (int)((NMCLISTCONTROL *)lParam)->hItem;
				for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
					if (SendDlgItemMessage(hwnd, IDC_CLIST, CLM_FINDCONTACT, hContact, 0) == iSelection) {
						hSelectedContact = hContact;
						RedrawWindow(GetDlgItem(hwnd, IDC_CANVAS), NULL, NULL, RDW_INVALIDATE);
					}
				}
				SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
			}
		}
		break;
	}

	return FALSE;
}
void CQuickSetupDlg::doAuthCheckboxChanged() {
	bool isDoAuthChecked = SendDlgItemMessage(IDC_DOAUTHCHECKBOX, BM_GETCHECK) == BST_CHECKED;
	GuiTools::EnableNextN( GetDlgItem( IDC_DOAUTHCHECKBOX) , 4, isDoAuthChecked);
}
Example #3
0
INT_PTR CALLBACK ProgressDlgProc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	static int fontHeight, listWidth;
	static int manualAbort;
	static HFONT hBoldFont = NULL;

	INT_PTR bReturn;
	if (DoMyControlProcessing(hdlg, message, wParam, lParam, &bReturn))
		return bReturn;

	switch (message) {
	case WM_INITDIALOG:
		EnableWindow(GetDlgItem(GetParent(hdlg), IDOK), FALSE);
		hdlgProgress = hdlg;
		hwndStatus = GetDlgItem(hdlg, IDC_STATUS);
		errorCount = 0;
		bShortModeDone = false;
		hwndBar = GetDlgItem(hdlg, IDC_PROGRESS);
		SendMessage(hwndBar, PBM_SETRANGE, 0, MAKELPARAM(0, 1000));
		{
			HDC hdc;
			HFONT hFont, hoFont;
			SIZE s;
			hdc = GetDC(NULL);
			hFont = (HFONT)SendMessage(hdlg, WM_GETFONT, 0, 0);
			hoFont = (HFONT)SelectObject(hdc, hFont);
			GetTextExtentPoint32(hdc, _T("x"), 1, &s);
			SelectObject(hdc, hoFont);
			ReleaseDC(NULL, hdc);
			fontHeight = s.cy;

			RECT rc;
			GetClientRect(GetDlgItem(hdlg, IDC_STATUS), &rc);
			listWidth = rc.right;

			LOGFONT lf;
			GetObject((HFONT)SendDlgItemMessage(hdlg, IDC_STATUS, WM_GETFONT, 0, 0), sizeof(lf), &lf);
			lf.lfWeight = FW_BOLD;
			hBoldFont = CreateFontIndirect(&lf);
		}
		manualAbort = 0;
		hEventRun = CreateEvent(NULL, TRUE, TRUE, NULL);
		hEventAbort = CreateEvent(NULL, TRUE, FALSE, NULL);
		TranslateDialogDefault(hdlg);
		_beginthread(WorkerThread, 0, NULL);
		return TRUE;

	case WM_MEASUREITEM:
		{
			LPMEASUREITEMSTRUCT mis = (LPMEASUREITEMSTRUCT)lParam;
			mis->itemWidth = listWidth;
			mis->itemHeight = fontHeight;
		}
		return TRUE;

	case WM_DRAWITEM:
		TCHAR str[256];
		{
			LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
			int bold = 0;
			HFONT hoFont = NULL;
			if ((int)dis->itemID == -1) break;
			SendMessage(dis->hwndItem, LB_GETTEXT, dis->itemID, (LPARAM)str);
			switch (dis->itemData & STATUS_CLASSMASK) {
			case STATUS_MESSAGE:
				SetTextColor(dis->hDC, RGB(0, 0, 0));
				break;
			case STATUS_WARNING:
				SetTextColor(dis->hDC, RGB(192, 128, 0));
				break;
			case STATUS_ERROR:
				SetTextColor(dis->hDC, RGB(192, 0, 0));
				break;
			case STATUS_FATAL:
				bold = 1;
				SetTextColor(dis->hDC, RGB(192, 0, 0));
				break;
			case STATUS_SUCCESS:
				bold = 1;
				SetTextColor(dis->hDC, RGB(0, 192, 0));
				break;
			}
			if (bold) hoFont = (HFONT)SelectObject(dis->hDC, hBoldFont);
			ExtTextOut(dis->hDC, dis->rcItem.left, dis->rcItem.top, ETO_CLIPPED | ETO_OPAQUE, &dis->rcItem, str, (UINT)mir_tstrlen(str), NULL);
			if (bold) SelectObject(dis->hDC, hoFont);
		}
		return TRUE;

	case WM_PROCESSINGDONE:
		SetProgressBar(1000);
		if (bShortMode) {
			EnableWindow(GetDlgItem(GetParent(hdlg), IDC_BACK), FALSE);
			EnableWindow(GetDlgItem(GetParent(hdlg), IDOK), FALSE);
			SetDlgItemText(GetParent(hdlg), IDCANCEL, TranslateT("&Finish"));
			bShortModeDone = true;
			if (bAutoExit)
				PostMessage(GetParent(hdlg), WM_COMMAND, IDCANCEL, 0);
		}
		else {
			AddToStatus(STATUS_SUCCESS, TranslateT("Click Next to continue"));
			EnableWindow(GetDlgItem(GetParent(hdlg), IDOK), TRUE);
		}

		if (manualAbort == 1)
			EndDialog(GetParent(hdlg), 0);
		else if (manualAbort == 2) {
			if (opts.bCheckOnly)
				PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc);
			else {
				PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_CLEANING, (LPARAM)CleaningDlgProc);
				CloseHandle(opts.hOutFile);
				opts.hOutFile = NULL;
			}
			break;
		}
		break;

	case WZN_CANCELCLICKED:
		if (bShortModeDone) {
			if (!errorCount) {
				if (bLaunchMiranda)
					CallService(MS_DB_SETDEFAULTPROFILE, (WPARAM)opts.filename, 0);
				wizardResult = 1;
			}
			return TRUE;
		}

		ResetEvent(hEventRun);
		if (IsWindowEnabled(GetDlgItem(GetParent(hdlg), IDOK)))
			break;

		if (MessageBox(hdlg, TranslateT("Processing has not yet completed, if you cancel now then the changes that have currently been made will be rolled back and the original database will be restored. Do you still want to cancel?"), TranslateT("Miranda Database Tool"), MB_YESNO) == IDYES) {
			manualAbort = 1;
			SetEvent(hEventAbort);
		}
		SetEvent(hEventRun);
		SetWindowLongPtr(hdlg, DWLP_MSGRESULT, TRUE);
		return TRUE;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDC_BACK:
			ResetEvent(hEventRun);
			if (!IsWindowEnabled(GetDlgItem(GetParent(hdlg), IDOK))) {
				if (MessageBox(hdlg, TranslateT("Processing has not yet completed, if you go back now then the changes that have currently been made will be rolled back and the original database will be restored. Do you still want to go back?"), TranslateT("Miranda Database Tool"), MB_YESNO) == IDYES) {
					manualAbort = 2;
					SetEvent(hEventAbort);
				}
				SetEvent(hEventRun);
				break;
			}
			SetEvent(hEventRun);
			if (opts.bCheckOnly)
				PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc);
			else
				PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_CLEANING, (LPARAM)CleaningDlgProc);
			break;

		case IDOK:
			PostMessage(GetParent(hdlg), WZM_GOTOPAGE, IDD_FINISHED, (LPARAM)FinishedDlgProc);
			break;
		}
		break;

	case WM_DESTROY:
		if (hEventAbort) {
			CloseHandle(hEventAbort);
			hEventAbort = NULL;
		}
		if (hEventRun) {
			CloseHandle(hEventRun);
			hEventRun = NULL;
		}
		if (hBoldFont) {
			DeleteObject(hBoldFont);
			hBoldFont = NULL;
		}
		break;
	}
	return FALSE;
}
Example #4
0
/**
 * Dialog procedure for the contact information propertysheetpage
 *
 * @param	 hDlg	- handle to the dialog window
 * @param	 uMsg	- the message to handle
 * @param	 wParam	- parameter
 * @param	 lParam	- parameter
 *
 * @return	different values
 **/
INT_PTR CALLBACK PSPProcGeneral(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg) {
	case WM_INITDIALOG:
		{
			CCtrlList *pCtrlList = CCtrlList::CreateObj(hDlg);
			if (pCtrlList) {
				LPIDSTRLIST pList;
				UINT nList;
				HFONT hBoldFont;
				
				PSGetBoldFont(hDlg, hBoldFont);
				SendDlgItemMessage(hDlg, IDC_PAGETITLE, WM_SETFONT, (WPARAM)hBoldFont, 0);
				TranslateDialogDefault(hDlg);

				pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_TITLE, SET_CONTACT_TITLE, DBVT_TCHAR));
				pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_FIRSTNAME, SET_CONTACT_FIRSTNAME, DBVT_TCHAR));
				pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_SECONDNAME, SET_CONTACT_SECONDNAME, DBVT_TCHAR));
				pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_LASTNAME, SET_CONTACT_LASTNAME, DBVT_TCHAR));
				pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_NICK, SET_CONTACT_NICK, DBVT_TCHAR));
				pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_DISPLAYNAME, "CList", SET_CONTACT_MYHANDLE, DBVT_TCHAR));
				pCtrlList->insert(CEditCtrl::CreateObj(hDlg, EDIT_PARTNER, SET_CONTACT_PARTNER, DBVT_TCHAR));

				GetNamePrefixList(&nList, &pList);
				pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_PREFIX, SET_CONTACT_PREFIX, DBVT_BYTE, pList, nList));

				// marital groupbox
				GetMaritalList(&nList, &pList);
				pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_MARITAL, SET_CONTACT_MARITAL, DBVT_BYTE, pList, nList));

				GetLanguageList(&nList, &pList);
				pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_LANG1, SET_CONTACT_LANG1, DBVT_TCHAR, pList, nList));
				pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_LANG2, SET_CONTACT_LANG2, DBVT_TCHAR, pList, nList));
				pCtrlList->insert(CCombo::CreateObj(hDlg, EDIT_LANG3, SET_CONTACT_LANG3, DBVT_TCHAR, pList, nList));
			}
		}
		break;

	case WM_NOTIFY:
		{
			switch (((LPNMHDR)lParam)->idFrom) {
			case 0:
				{
					MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
					char* pszProto;

					switch (((LPNMHDR)lParam)->code) {
					case PSN_INFOCHANGED:
						{
							BYTE bEnable;
							DBVARIANT dbv;
							CCtrlFlags Flags;
		
							if (PSGetBaseProto(hDlg, pszProto) && *pszProto) {
								Flags.W = DB::Setting::GetTStringCtrl(hContact, USERINFO, USERINFO, pszProto, SET_CONTACT_GENDER, &dbv);
								if (Flags.B.hasCustom || Flags.B.hasProto || Flags.B.hasMeta) {
									if (dbv.type == DBVT_BYTE) {
										CheckDlgButton(hDlg, RADIO_FEMALE, (dbv.bVal == 'F'));
										CheckDlgButton(hDlg, RADIO_MALE, (dbv.bVal == 'M'));

										bEnable = !hContact || Flags.B.hasCustom || !db_get_b(NULL, MODNAME, SET_PROPSHEET_PCBIREADONLY, 0);
										EnableWindow(GetDlgItem(hDlg, RADIO_FEMALE), bEnable);
										EnableWindow(GetDlgItem(hDlg, RADIO_MALE), bEnable);
									}
									else
										db_free(&dbv);
								}
							}
						}
						break;

					case PSN_APPLY:
						{
							if (!PSGetBaseProto(hDlg, pszProto) || *pszProto == 0)
								break;

							// gender
							{
								BYTE gender
									= SendDlgItemMessage(hDlg, RADIO_FEMALE, BM_GETCHECK, NULL, NULL)
									? 'F'
									: SendDlgItemMessage(hDlg, RADIO_MALE, BM_GETCHECK, NULL, NULL)
									? 'M'
									: 0;

								if (gender)
									db_set_b(hContact, hContact ? USERINFO : pszProto, SET_CONTACT_GENDER, gender);
								else
									db_unset(hContact, hContact ? USERINFO : pszProto, SET_CONTACT_GENDER);
							}
						}
						break;

					case PSN_ICONCHANGED:
						{
							const ICONCTRL idIcon[] = {
								{ ICO_COMMON_FEMALE,  STM_SETIMAGE, ICO_FEMALE },
								{ ICO_COMMON_MALE,    STM_SETIMAGE, ICO_MALE },
								{ ICO_COMMON_MARITAL, STM_SETIMAGE, ICO_MARITAL },
							};
							IcoLib_SetCtrlIcons(hDlg, idIcon, SIZEOF(idIcon));
						}
					}
				}
			}
		}
		break;

	case WM_COMMAND:
		{
			MCONTACT hContact;
			LPCSTR pszProto;

			switch (LOWORD(wParam)) {
			case RADIO_FEMALE:
				{
					if (!PspIsLocked(hDlg) && HIWORD(wParam) == BN_CLICKED) {
						DBVARIANT dbv;

						PSGetContact(hDlg, hContact);
						PSGetBaseProto(hDlg, pszProto);

						if (!DB::Setting::GetAsIsCtrl(hContact, USERINFO, USERINFO, pszProto, SET_CONTACT_GENDER, &dbv)
							|| dbv.type != DBVT_BYTE
							|| (dbv.bVal != 'F' && SendMessage((HWND)lParam, BM_GETCHECK, NULL, NULL)))
							SendMessage(GetParent(hDlg), PSM_CHANGED, NULL, NULL);
					}
				}
				break;

			case RADIO_MALE:
				{
					if (!PspIsLocked(hDlg) && HIWORD(wParam) == BN_CLICKED) {
						DBVARIANT dbv;

						PSGetContact(hDlg, hContact);
						PSGetBaseProto(hDlg, pszProto);

						if (!DB::Setting::GetAsIsCtrl(hContact, USERINFO, USERINFO, pszProto, SET_CONTACT_GENDER, &dbv)
							|| dbv.type != DBVT_BYTE
							|| (dbv.bVal != 'M' && SendMessage((HWND)lParam, BM_GETCHECK, NULL, NULL)))
							SendMessage(GetParent(hDlg), PSM_CHANGED, NULL, NULL);
					}
				}
			}
		}
	}
	return PSPBaseProc(hDlg, uMsg, wParam, lParam);
}
Example #5
0
static LRESULT CALLBACK Scropt1DlgProc(HWND hWnd, UINT msg,
													WPARAM wp, LPARAM lp) {
	TCHAR	work[32];
	UINT16	ret;
	UINT8	b;
	int		renewal;

	switch(msg) {
		case WM_INITDIALOG:
			SetDlgItemCheck(hWnd, IDC_LCD, np2cfg.LCD_MODE & 1);
			EnableWindow(GetDlgItem(hWnd, IDC_LCDX), np2cfg.LCD_MODE & 1);
			SetDlgItemCheck(hWnd, IDC_LCDX, np2cfg.LCD_MODE & 2);

			SetDlgItemCheck(hWnd, IDC_SKIPLINE, np2cfg.skipline);
			SendDlgItemMessage(hWnd, IDC_SKIPLIGHT, TBM_SETRANGE, TRUE,
											MAKELONG(0, 255));
			SendDlgItemMessage(hWnd, IDC_SKIPLIGHT, TBM_SETPOS, TRUE,
											np2cfg.skiplight);
			wsprintf(work, str_d, np2cfg.skiplight);
			SetDlgItemText(hWnd, IDC_LIGHTSTR, work);
			return(TRUE);

		case WM_COMMAND:
			switch(LOWORD(wp)) {
				case IDC_LCD:
					EnableWindow(GetDlgItem(hWnd, IDC_LCDX),
											GetDlgItemCheck(hWnd, IDC_LCD));
					break;
			}
			break;

		case WM_HSCROLL:
			switch(GetDlgCtrlID((HWND)lp)) {
				case IDC_SKIPLIGHT:
					ret = (UINT16)SendDlgItemMessage(hWnd, IDC_SKIPLIGHT,
													TBM_GETPOS, 0, 0);
					wsprintf(work, str_d, ret);
					SetDlgItemText(hWnd, IDC_LIGHTSTR, work);
					break;
			}
			break;

		case WM_NOTIFY:
			if ((((NMHDR *)lp)->code) == (UINT)PSN_APPLY) {
				renewal = 0;
				b = GetDlgItemCheck(hWnd, IDC_SKIPLINE);
				if (np2cfg.skipline != b) {
					np2cfg.skipline = b;
					renewal = 1;
				}
				ret = (UINT16)SendDlgItemMessage(hWnd, IDC_SKIPLIGHT,
															TBM_GETPOS, 0, 0);
				if (ret > 255) {
					ret = 255;
				}
				if (np2cfg.skiplight != ret) {
					np2cfg.skiplight = ret;
					renewal = 1;
				}
				if (renewal) {
					pal_makeskiptable();
				}
				b = GetDlgItemCheck(hWnd, IDC_LCD) |
					(GetDlgItemCheck(hWnd, IDC_LCDX) << 1);
				if (np2cfg.LCD_MODE != b) {
					np2cfg.LCD_MODE = b;
					pal_makelcdpal();
					renewal = 1;
				}
				if (renewal) {
					scrndraw_redraw();
					sysmng_update(SYS_UPDATECFG);
				}
				return(TRUE);
			}
			break;
	}
	return(FALSE);
}
Example #6
0
INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	RECT r;
	RECT r2;
	int dx1, dy1, dx2, dy2;

	switch (msg) {

	case WM_INITDIALOG:
	{
						  // remove the 30000 character limit from the console control
						  SendMessage(GetDlgItem(hDlg, IDC_LUACONSOLE), EM_LIMITTEXT, 0, 0);


						  //GetWindowRect(GetParent(hDlg), &r);
						  GetWindowRect(gApp.hWnd, &r);
						  dx1 = (r.right - r.left) / 2;
						  dy1 = (r.bottom - r.top) / 2;

						  GetWindowRect(hDlg, &r2);
						  dx2 = (r2.right - r2.left) / 2;
						  dy2 = (r2.bottom - r2.top) / 2;

						  int windowIndex = 0;//std::find(LuaScriptHWnds.begin(), LuaScriptHWnds.end(), hDlg) - LuaScriptHWnds.begin();
						  int staggerOffset = windowIndex * 24;
						  r.left += staggerOffset;
						  r.right += staggerOffset;
						  r.top += staggerOffset;
						  r.bottom += staggerOffset;

						  // push it away from the main window if we can
						  const int width = (r.right - r.left);
						  const int width2 = (r2.right - r2.left);
						  if (r.left + width2 + width < GetSystemMetrics(SM_CXSCREEN))
						  {
							  r.right += width;
							  r.left += width;
						  }
						  else if ((int)r.left - (int)width2 > 0)
						  {
							  r.right -= width2;
							  r.left -= width2;
						  }

						  SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);


						  RECT r3;
						  GetClientRect(hDlg, &r3);
						  windowInfo.width = r3.right - r3.left;
						  windowInfo.height = r3.bottom - r3.top;
						  for (int i = 0; i < numControlLayoutInfos; i++) {
							  ControlLayoutState& layoutState = windowInfo.layoutState[i];
							  layoutState.valid = false;
						  }

						  DragAcceptFiles(hDlg, true);
						  SetDlgItemText(hDlg, IDC_EDIT_LUAPATH, PCSX2GetLuaScriptName());

						  SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &LuaConsoleLogFont, 0); // reset with an acceptable font

						  LuaConsoleHWnd = GetDlgItem(hDlg, IDC_LUACONSOLE);
						  consoleputstring.clear();
						  consoleputstring.reserve(250000);
						  return true;
	}       break;

	case WM_SIZE:
	{
					// resize or move controls in the window as necessary when the window is resized

					//LuaPerWindowInfo& windowInfo = LuaWindowInfo[hDlg];
					int prevDlgWidth = windowInfo.width;
					int prevDlgHeight = windowInfo.height;

					int dlgWidth = LOWORD(lParam);
					int dlgHeight = HIWORD(lParam);

					int deltaWidth = dlgWidth - prevDlgWidth;
					int deltaHeight = dlgHeight - prevDlgHeight;

					for (int i = 0; i < numControlLayoutInfos; i++)
					{
						ControlLayoutInfo layoutInfo = controlLayoutInfos[i];
						ControlLayoutState& layoutState = windowInfo.layoutState[i];

						HWND hCtrl = GetDlgItem(hDlg, layoutInfo.controlID);

						int x, y, width, height;
						if (layoutState.valid)
						{
							x = layoutState.x;
							y = layoutState.y;
							width = layoutState.width;
							height = layoutState.height;
						}
						else
						{
							RECT r;
							GetWindowRect(hCtrl, &r);
							POINT p = { r.left, r.top };
							ScreenToClient(hDlg, &p);
							x = p.x;
							y = p.y;
							width = r.right - r.left;
							height = r.bottom - r.top;
						}

						switch (layoutInfo.horizontalLayout)
						{
						case ControlLayoutInfo::RESIZE_END: width += deltaWidth; break;
						case ControlLayoutInfo::MOVE_START: x += deltaWidth; break;
						default: break;
						}
						switch (layoutInfo.verticalLayout)
						{
						case ControlLayoutInfo::RESIZE_END: height += deltaHeight; break;
						case ControlLayoutInfo::MOVE_START: y += deltaHeight; break;
						default: break;
						}

						SetWindowPos(hCtrl, 0, x, y, width, height, 0);

						layoutState.x = x;
						layoutState.y = y;
						layoutState.width = width;
						layoutState.height = height;
						layoutState.valid = true;
					}

					windowInfo.width = dlgWidth;
					windowInfo.height = dlgHeight;

					RedrawWindow(hDlg, NULL, NULL, RDW_INVALIDATE);
	}       break;

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDOK:
		case IDCANCEL: {
						   EndDialog(hDlg, true); // goto case WM_CLOSE;
		}       break;

		case IDC_BUTTON_LUARUN:
		{
								  if (!g_ReturnToGui)
								  {
									  consoleputstring.clear();
									  char filename[MAX_PATH];
									  GetDlgItemText(hDlg, IDC_EDIT_LUAPATH, filename, MAX_PATH);
									  if(PCSX2LoadLuaCode(filename))
										  WinLuaOnStart();
								  }
		}       break;

		case IDC_BUTTON_LUASTOP:
		{
								   PCSX2LuaStop();
								   WinLuaOnStop();
		}       break;

		case IDC_BUTTON_LUAEDIT:
		{
								   char Str_Tmp[1024];
								   SendDlgItemMessage(hDlg, IDC_EDIT_LUAPATH, WM_GETTEXT, (WPARAM)512, (LPARAM)Str_Tmp);
								   // tell the OS to open the file with its associated editor,
								   // without blocking on it or leaving a command window open.
								   if ((int)ShellExecute(NULL, "edit", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC)
								   if ((int)ShellExecute(NULL, "open", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC)
									   ShellExecute(NULL, NULL, "notepad", Str_Tmp, NULL, SW_SHOWNORMAL);
		}       break;

		case IDC_BUTTON_LUABROWSE:
		{

									 //systemSoundClearBuffer();

									 //CString filter = winResLoadFilter(IDS_FILTER_LUA);
									 //CString title = winResLoadString(IDS_SELECT_LUA_NAME);

									 //CString luaName = winGetDestFilename(theApp.gameFilename, IDS_LUA_DIR, ".lua");
									 //CString luaDir = winGetDestDir(IDS_LUA_DIR);

									 //filter.Replace('|', '\000');
									 //                              char *p = filter.GetBuffer(0);
									 //                              while ((p = strchr(p, '|')) != NULL)
									 //                                      *p++ = 0;

									 char filenamebuffer[MAX_PATH];
									 ZeroMemory(filenamebuffer, MAX_PATH);
									 OPENFILENAME  ofn;
									 ZeroMemory((LPVOID)&ofn, sizeof(OPENFILENAME));
									 ofn.lpstrFile = filenamebuffer;
									 ofn.nMaxFile = MAX_PATH;
									 ofn.lStructSize = sizeof(OPENFILENAME);
									 ofn.hwndOwner = hDlg;
									 ofn.lpstrFilter = "Lua Script(*.lua)\0*.lua\0All files(*.*)\0*.*\0\0";
									 ofn.nFilterIndex = 0;
									 //ofn.lpstrInitialDir = "";
									 ofn.lpstrTitle = "choose lua file";
									 ofn.lpstrDefExt = "lua";
									 ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_ENABLESIZING | OFN_EXPLORER; // hide previously-ignored read-only checkbox (the real read-only box is in the open-movie dialog itself)
									 if (GetOpenFileName(&ofn))
									 {
										 SetWindowText(GetDlgItem(hDlg, IDC_EDIT_LUAPATH), filenamebuffer);
									 }

									 return true;
		}       break;

		case IDC_EDIT_LUAPATH:
		{
								 char filename[MAX_PATH];
								 GetDlgItemText(hDlg, IDC_EDIT_LUAPATH, filename, MAX_PATH);
								 FILE* file = fopen(filename, "rb");
								 EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_LUAEDIT), file != NULL);
								 if (file)
									 fclose(file);
		}       break;

		case IDC_LUACONSOLE_CHOOSEFONT:
		{
										  CHOOSEFONT cf;

										  ZeroMemory(&cf, sizeof(cf));
										  cf.lStructSize = sizeof(CHOOSEFONT);
										  cf.hwndOwner = hDlg;
										  cf.lpLogFont = &LuaConsoleLogFont;
										  cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT;
										  if (ChooseFont(&cf)) {
											  if (hFont) {
												  DeleteObject(hFont);
												  hFont = NULL;
											  }
											  hFont = CreateFontIndirect(&LuaConsoleLogFont);
											  if (hFont)
												  SendDlgItemMessage(hDlg, IDC_LUACONSOLE, WM_SETFONT, (WPARAM)hFont, 0);
										  }
		}       break;

		case IDC_LUACONSOLE_CLEAR:
		{
									 SetWindowText(GetDlgItem(hDlg, IDC_LUACONSOLE), "");
		}       break;
		case IDC_LUACONSOLE_UPDATE:
		{
									  /*排他制御してやらないと、出力したい文字列が途切れたりしてしまうのです。。。*/
									  lockLuamutex();
									  if (!LuaConsoleHWnd || consoleputstring.empty()){
										  unlockLuamutex();
										  break;
									  }
									  HWND hConsole = LuaConsoleHWnd;

									  int length = GetWindowTextLength(hConsole);
									  if (length >= 250000)
									  {
										  // discard first half of text if it's getting too long
										  SendMessage(hConsole, EM_SETSEL, 0, length / 2);
										  SendMessage(hConsole, EM_REPLACESEL, false, (LPARAM)"");
										  length = GetWindowTextLength(hConsole);
									  }
									  SendMessage(hConsole, EM_SETSEL, length, length);

									  //LuaPerWindowInfo& info = LuaWindowInfo[hDlg];
									  {
										  consoleputstring = Replace(consoleputstring, "\n", "\r\n");
										  SendMessage(hConsole, EM_REPLACESEL, false, (LPARAM)consoleputstring.c_str());
									  }
									  consoleputstring.clear();
									  unlockLuamutex();
		}		break;

		} // switch (LOWORD(wParam))
		break;

	case WM_CLOSE: {
					   //SendMessage(hDlg, WM_DESTROY, 0, 0);
					   DestroyWindow(hDmyWnd);
	}       break;

	case WM_DESTROY: {
						 PCSX2LuaStop();
						 DragAcceptFiles(hDlg, FALSE);
						 if (hFont) {
							 DeleteObject(hFont);
							 hFont = NULL;
						 }
						 LuaConsoleHWnd = NULL;
						 hLuaDlg = NULL;
						 hDmyWnd = NULL;
	}       break;

	case WM_DROPFILES: {
						   HDROP hDrop;
						   //UINT fileNo;
						   UINT fileCount;
						   char filename[_MAX_PATH];

						   hDrop = (HDROP)wParam;
						   fileCount = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
						   if (fileCount > 0) {
							   DragQueryFile(hDrop, 0, filename, sizeof(filename));
							   SetWindowText(GetDlgItem(hDlg, IDC_EDIT_LUAPATH), filename);
						   }
						   DragFinish(hDrop);
						   return true;
	}       break;

	}

	return false;

}
Example #7
0
HRESULT CALLBACK OpenCell_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
{
   LPOPENCELLDLG_PARAMS lpp;
   if (msg == WM_INITDIALOG)
      SetWindowLongPtr (hDlg, DWLP_USER, lp);

   if ((lpp = (LPOPENCELLDLG_PARAMS)GetWindowLongPtr (hDlg, DWLP_USER)) != NULL)
      {
      if (lpp->hookproc)
         {
         if (CallWindowProc ((WNDPROC)lpp->hookproc, hDlg, msg, wp, lp))
            return TRUE;
         }
      }

   if (lpp != NULL)
      {
      if (AfsAppLib_HandleHelp (lpp->idd, hDlg, msg, wp, lp))
         return TRUE;
      }

   switch (msg)
      {
      case WM_INITDIALOG:
         OpenCell_OnInitDialog (hDlg, lpp);
         break;

      case WM_COMMAND:
         switch (LOWORD(wp))
            {
            case IDCANCEL:
               EndDialog (hDlg, IDCANCEL);
               return TRUE;

            case IDOK:
               if (OpenCell_OnOK (hDlg, lpp))
                  EndDialog (hDlg, IDOK);
               return TRUE;

            case IDC_OPENCELL_CELL:
               switch (HIWORD(wp))
                  {
                  case CBN_SELCHANGE:
                     TCHAR szCell[ cchNAME ];
                     SendDlgItemMessage (hDlg, IDC_OPENCELL_CELL, CB_GETLBTEXT, CB_GetSelected(GetDlgItem (hDlg, IDC_OPENCELL_CELL)), (LPARAM)szCell);
                     SetDlgItemText (hDlg, IDC_OPENCELL_CELL, szCell);
                     OpenCell_OnCell (hDlg);
                     break;

                  case CBN_EDITCHANGE:
                     OpenCell_OnCell (hDlg);
                     break;
                  }
               break;
            }
         break;

      case WM_REFRESHED_CREDENTIALS:
         OpenCell_OnGotCreds (hDlg, lp);
         break;
      }

   return FALSE;
}
Example #8
0
INT_PTR CLAVSplitterSettingsProp::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch (uMsg)
  {
  case WM_COMMAND:
    // Mark the page dirty if the text changed
    if(HIWORD(wParam) == EN_CHANGE
      && (LOWORD(wParam) == IDC_PREF_LANG || LOWORD(wParam) == IDC_PREF_LANG_SUBS)) {

        WCHAR buffer[LANG_BUFFER_SIZE];
        SendDlgItemMessage(m_Dlg, LOWORD(wParam), WM_GETTEXT, LANG_BUFFER_SIZE, (LPARAM)&buffer);

        int dirty = 0;
        WCHAR *source = nullptr;
        if(LOWORD(wParam) == IDC_PREF_LANG) {
          source = m_pszPrefLang;
        } else {
          source = (m_selectedSubMode == LAVSubtitleMode_Advanced) ? m_pszAdvSubConfig : m_pszPrefSubLang;
        }

        if (source) {
          dirty = _wcsicmp(buffer, source);
        } else {
          dirty = (int)wcslen(buffer);
        }

        if(dirty != 0) {
          SetDirty();
        }
    } else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_SUBTITLE_MODE) {
      DWORD dwVal = (DWORD)SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_GETCURSEL, 0, 0);
      UpdateSubtitleMode((LAVSubtitleMode)dwVal);
      if (dwVal != m_subtitleMode) {
        SetDirty();
      }
    } else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BD_SEPARATE_FORCED_SUBS) {
      BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_BD_SEPARATE_FORCED_SUBS, BM_GETCHECK, 0, 0);
      if (bFlag != m_PGSForcedStream) {
        SetDirty();
      }
    } else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BD_ONLY_FORCED_SUBS) {
      BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_BD_ONLY_FORCED_SUBS, BM_GETCHECK, 0, 0);
      if (bFlag != m_PGSOnlyForced) {
        SetDirty();
      }
    } else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_VC1TIMESTAMP) {
      int iFlag = (int)SendDlgItemMessage(m_Dlg, IDC_VC1TIMESTAMP, BM_GETCHECK, 0, 0);
      if (iFlag != m_VC1Mode) {
        SetDirty();
      }
    }  else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_MKV_EXTERNAL) {
      BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_MKV_EXTERNAL, BM_GETCHECK, 0, 0);
      if (bFlag != m_MKVExternal) {
        SetDirty();
      }
    } else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_SUBSTREAMS) {
      BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_SUBSTREAMS, BM_GETCHECK, 0, 0);
      if (bFlag != m_substreams) {
        SetDirty();
      }
    } else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_STREAM_SWITCH_REMOVE_AUDIO) {
      BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_STREAM_SWITCH_REMOVE_AUDIO, BM_GETCHECK, 0, 0);
      if (bFlag != m_StreamSwitchRemoveAudio) {
        SetDirty();
      }
    }  else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_SELECT_AUDIO_QUALITY) {
      BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_SELECT_AUDIO_QUALITY, BM_GETCHECK, 0, 0);
      if (bFlag != m_PreferHighQualityAudio) {
        SetDirty();
      }
    }  else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_IMPAIRED_AUDIO) {
      BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_IMPAIRED_AUDIO, BM_GETCHECK, 0, 0);
      if (bFlag != m_ImpairedAudio) {
        SetDirty();
      }
    } else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_TRAYICON) {
      BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_TRAYICON, BM_GETCHECK, 0, 0);
      if (bFlag != m_TrayIcon) {
        SetDirty();
      }
    } else if (LOWORD(wParam) == IDC_QUEUE_MEM && HIWORD(wParam) == EN_CHANGE) {
      WCHAR buffer[100];
      SendDlgItemMessage(m_Dlg, LOWORD(wParam), WM_GETTEXT, 100, (LPARAM)&buffer);
      int maxMem = _wtoi(buffer);
      size_t len = wcslen(buffer);
      if (maxMem == 0 && (buffer[0] != L'0' || len > 1)) {
        SendDlgItemMessage(m_Dlg, LOWORD(wParam), EM_UNDO, 0, 0);
      } else {
        swprintf_s(buffer, L"%d", maxMem);
        if (wcslen(buffer) != len)
          SendDlgItemMessage(m_Dlg, IDC_QUEUE_MEM, WM_SETTEXT, 0, (LPARAM)buffer);
        if (maxMem != m_QueueMaxMem)
          SetDirty();
      }
    } else if (LOWORD(wParam) == IDC_QUEUE_PACKETS && HIWORD(wParam) == EN_CHANGE) {
      WCHAR buffer[100];
      SendDlgItemMessage(m_Dlg, LOWORD(wParam), WM_GETTEXT, 100, (LPARAM)&buffer);
      int maxMem = _wtoi(buffer);
      size_t len = wcslen(buffer);
      if (maxMem == 0 && (buffer[0] != L'0' || len > 1)) {
        SendDlgItemMessage(m_Dlg, LOWORD(wParam), EM_UNDO, 0, 0);
      } else {
        swprintf_s(buffer, L"%d", maxMem);
        if (wcslen(buffer) != len)
          SendDlgItemMessage(m_Dlg, IDC_QUEUE_PACKETS, WM_SETTEXT, 0, (LPARAM)buffer);
        if (maxMem != m_QueueMaxPackets)
          SetDirty();
      }
    } else if (LOWORD(wParam) == IDC_STREAM_ANADUR && HIWORD(wParam) == EN_CHANGE) {
      WCHAR buffer[100];
      SendDlgItemMessage(m_Dlg, LOWORD(wParam), WM_GETTEXT, 100, (LPARAM)&buffer);
      int duration = _wtoi(buffer);
      size_t len = wcslen(buffer);
      if (duration == 0 && (buffer[0] != L'0' || len > 1)) {
        SendDlgItemMessage(m_Dlg, LOWORD(wParam), EM_UNDO, 0, 0);
      } else {
        swprintf_s(buffer, L"%d", duration);
        if (wcslen(buffer) != len)
          SendDlgItemMessage(m_Dlg, IDC_STREAM_ANADUR, WM_SETTEXT, 0, (LPARAM)buffer);
        if (duration != m_NetworkAnalysisDuration)
          SetDirty();
      }
    }
    break;
  }
  // Let the parent class handle the message.
  return __super::OnReceiveMessage(hwnd, uMsg, wParam, lParam);
}
Example #9
0
HRESULT CLAVSplitterFormatsProp::OnActivate()
{
  HRESULT hr = S_OK;
  INITCOMMONCONTROLSEX icc;
  icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
  icc.dwICC = ICC_BAR_CLASSES | ICC_STANDARD_CLASSES;
  if (InitCommonControlsEx(&icc) == FALSE)
  {
    return E_FAIL;
  }
  ASSERT(m_pLAVF != nullptr);

  memset(stringBuffer, 0, sizeof(stringBuffer));

  const char *pszInput = m_pLAVF->GetInputFormat();
  if (pszInput) {
    _snwprintf_s(stringBuffer, _TRUNCATE, L"%S", pszInput);
  }
  SendDlgItemMessage(m_Dlg, IDC_CUR_INPUT, WM_SETTEXT, 0, (LPARAM)stringBuffer);

  m_Formats = m_pLAVF->GetInputFormats();

  // Setup ListView control for format configuration
  HWND hlv = GetDlgItem(m_Dlg, IDC_FORMATS);
  ListView_SetExtendedListViewStyle(hlv, LVS_EX_CHECKBOXES|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);

  int nCol = 1;
  LVCOLUMN lvc = {LVCF_WIDTH, 0, 20, 0};
  ListView_InsertColumn(hlv, 0, &lvc);
  ListView_AddCol(hlv, nCol,  75, L"Format", false);
  ListView_AddCol(hlv, nCol, 210, L"Description", false);

  ListView_DeleteAllItems(hlv);
  ListView_SetItemCount(hlv, m_Formats.size());

  SAFE_CO_FREE(m_bFormats);
  m_bFormats = (BOOL *)CoTaskMemAlloc(sizeof(BOOL) * m_Formats.size());
  if (!m_bFormats)
    return E_OUTOFMEMORY;
  memset(m_bFormats, 0, sizeof(BOOL) * m_Formats.size());

  // Create entries for the formats
  LVITEM lvi;
  memset(&lvi, 0, sizeof(lvi));
  lvi.mask = LVIF_TEXT|LVIF_PARAM;

  int nItem = 0;
  std::set<FormatInfo>::const_iterator it;
  for (it = m_Formats.begin(); it != m_Formats.end(); ++it) {
    // Create main entry
    lvi.iItem = nItem + 1;
    ListView_InsertItem(hlv, &lvi);

    // Set sub item texts
    _snwprintf_s(stringBuffer, _TRUNCATE, L"%S", it->strName);
    ListView_SetItemText(hlv, nItem, 1, (LPWSTR)stringBuffer);

    _snwprintf_s(stringBuffer, _TRUNCATE, L"%S", it->strDescription);
    ListView_SetItemText(hlv, nItem, 2, (LPWSTR)stringBuffer);

    m_bFormats[nItem] =  m_pLAVF->IsFormatEnabled(it->strName);
    ListView_SetCheckState(hlv, nItem, m_bFormats[nItem]);

    nItem++;
  }

  return hr;
}
Example #10
0
MIR_APP_DLL(void) Button_FreeIcon_IcoLib(HWND hwndDlg, int itemId)
{
	HICON hIcon = (HICON)SendDlgItemMessage(hwndDlg, itemId, BM_SETIMAGE, IMAGE_ICON, 0);
	IcoLib_ReleaseIcon(hIcon);
}
Example #11
0
HRESULT CLAVSplitterSettingsProp::OnActivate()
{
  HRESULT hr = S_OK;
  INITCOMMONCONTROLSEX icc;
  icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
  icc.dwICC = ICC_BAR_CLASSES | ICC_STANDARD_CLASSES;
  if (InitCommonControlsEx(&icc) == FALSE)
  {
    return E_FAIL;
  }
  ASSERT(m_pLAVF != nullptr);

  const WCHAR *version = TEXT(LAV_SPLITTER) L" " TEXT(LAV_VERSION_STR);
  SendDlgItemMessage(m_Dlg, IDC_SPLITTER_FOOTER, WM_SETTEXT, 0, (LPARAM)version);

  hr = LoadData();
  memset(m_subLangBuffer, 0, sizeof(m_advSubBuffer));
  memset(m_advSubBuffer, 0, sizeof(m_advSubBuffer));

  m_selectedSubMode = LAVSubtitleMode_Default;
  if (m_pszAdvSubConfig)
    wcsncpy_s(m_advSubBuffer, m_pszAdvSubConfig, _TRUNCATE);

  // Notify the UI about those settings
  SendDlgItemMessage(m_Dlg, IDC_PREF_LANG, WM_SETTEXT, 0, (LPARAM)m_pszPrefLang);
  SendDlgItemMessage(m_Dlg, IDC_PREF_LANG_SUBS, WM_SETTEXT, 0, (LPARAM)m_pszPrefSubLang);

  // Init the Combo Box
  SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_RESETCONTENT, 0, 0);
  WideStringFromResource(stringBuffer, IDS_SUBMODE_NO_SUBS);
  SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_ADDSTRING, 0, (LPARAM)stringBuffer);
  WideStringFromResource(stringBuffer, IDS_SUBMODE_FORCED_SUBS);
  SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_ADDSTRING, 0, (LPARAM)stringBuffer);
  WideStringFromResource(stringBuffer, IDS_SUBMODE_DEFAULT);
  SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_ADDSTRING, 0, (LPARAM)stringBuffer);
  WideStringFromResource(stringBuffer, IDS_SUBMODE_ADVANCED);
  SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_ADDSTRING, 0, (LPARAM)stringBuffer);

  SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_SETCURSEL, m_subtitleMode, 0);
  addHint(IDC_SUBTITLE_MODE, L"Configure how subtitles are selected.");

  SendDlgItemMessage(m_Dlg, IDC_BD_SEPARATE_FORCED_SUBS, BM_SETCHECK, m_PGSForcedStream, 0);
  addHint(IDC_BD_SEPARATE_FORCED_SUBS, L"Enabling this causes the creation of a new \"Forced Subtitles\" stream, which will try to always display forced subtitles matching your selected audio language.\n\nNOTE: This option may not work on all Blu-ray discs.\nRequires restart to take effect.");

  SendDlgItemMessage(m_Dlg, IDC_BD_ONLY_FORCED_SUBS, BM_SETCHECK, m_PGSOnlyForced, 0);
  addHint(IDC_BD_ONLY_FORCED_SUBS, L"When enabled, all Blu-ray (PGS) subtitles will be filtered, and only forced subtitles will be sent to the renderer.\n\nNOTE: When this option is active, you will not be able to get the \"full\" subtitles.");

  SendDlgItemMessage(m_Dlg, IDC_VC1TIMESTAMP, BM_SETCHECK, m_VC1Mode, 0);
  addHint(IDC_VC1TIMESTAMP, L"Checked - Frame timings will be corrected.\nUnchecked - Frame timings will be sent untouched.\nIndeterminate (Auto) - Only enabled for decoders that rely on the splitter doing the corrections.\n\nNOTE: Only for debugging, if unsure, set to \"Auto\".");

  SendDlgItemMessage(m_Dlg, IDC_MKV_EXTERNAL, BM_SETCHECK, m_MKVExternal, 0);

  SendDlgItemMessage(m_Dlg, IDC_SUBSTREAMS, BM_SETCHECK, m_substreams, 0);
  addHint(IDC_SUBSTREAMS, L"Controls if sub-streams should be exposed as a separate stream.\nSub-streams are typically streams for backwards compatibility, for example the AC3 part of TrueHD streams on Blu-rays.");

  SendDlgItemMessage(m_Dlg, IDC_STREAM_SWITCH_REMOVE_AUDIO, BM_SETCHECK, m_StreamSwitchRemoveAudio, 0);
  addHint(IDC_STREAM_SWITCH_REMOVE_AUDIO, L"Remove the old Audio Decoder from the Playback Chain before switching the audio stream, forcing DirectShow to select a new one.\n\nThis option ensures that the preferred decoder is always used, however it does not work properly with all players.");

  addHint(IDC_SELECT_AUDIO_QUALITY, L"Controls if the stream with the highest quality (matching your language preferences) should always be used.\nIf disabled, the first stream is always used.");
  SendDlgItemMessage(m_Dlg, IDC_SELECT_AUDIO_QUALITY, BM_SETCHECK, m_PreferHighQualityAudio, 0);

  SendDlgItemMessage(m_Dlg, IDC_IMPAIRED_AUDIO, BM_SETCHECK, m_ImpairedAudio, 0);

  SendDlgItemMessage(m_Dlg, IDC_QUEUE_MEM_SPIN, UDM_SETRANGE32, 0, 2048);

  addHint(IDC_QUEUE_MEM, L"Set the maximum memory a frame queue can use for buffering (in megabytes).\nNote that this is the maximum value, only very high bitrate files will usually even reach the default maximum value.");
  addHint(IDC_QUEUE_MEM_SPIN, L"Set the maximum memory a frame queue can use for buffering (in megabytes).\nNote that this is the maximum value, only very high bitrate files will usually even reach the default maximum value.");

  WCHAR stringBuffer[100];
  swprintf_s(stringBuffer, L"%d", m_QueueMaxMem);
  SendDlgItemMessage(m_Dlg, IDC_QUEUE_MEM, WM_SETTEXT, 0, (LPARAM)stringBuffer);

  SendDlgItemMessage(m_Dlg, IDC_QUEUE_PACKETS_SPIN, UDM_SETRANGE32, 100, 100000);

  addHint(IDC_QUEUE_PACKETS, L"Set the maximum numbers of packets to buffer in the frame queue.\nNote that the frame queue will never exceed the memory limited set above.");
  addHint(IDC_QUEUE_PACKETS_SPIN, L"Set the maximum numbers of packets to buffer in the frame queue.\nNote that the frame queue will never exceed the memory limited set above.");

  swprintf_s(stringBuffer, L"%d", m_QueueMaxPackets);
  SendDlgItemMessage(m_Dlg, IDC_QUEUE_PACKETS, WM_SETTEXT, 0, (LPARAM)stringBuffer);

  SendDlgItemMessage(m_Dlg, IDC_STREAM_ANADUR_SPIN, UDM_SETRANGE32, 200, 10000);

  addHint(IDC_STREAM_ANADUR, L"Set the duration (in milliseconds) a network stream is analyzed for before playback starts.\nA longer duration ensures the stream parameters are properly detected, however it will delay playback start.\n\nDefault: 1000 (1 second)");
  addHint(IDC_STREAM_ANADUR_SPIN, L"Set the duration (in milliseconds) a network stream is analyzed for before playback starts.\nA longer duration ensures the stream parameters are properly detected, however it will delay playback start.\n\nDefault: 1000 (1 second)");

  swprintf_s(stringBuffer, L"%d", m_NetworkAnalysisDuration);
  SendDlgItemMessage(m_Dlg, IDC_STREAM_ANADUR, WM_SETTEXT, 0, (LPARAM)stringBuffer);

  UpdateSubtitleMode(m_subtitleMode);

  SendDlgItemMessage(m_Dlg, IDC_TRAYICON, BM_SETCHECK, m_TrayIcon, 0);

  return hr;
}
//------------------------------------------------------------------------------
// Name: OnPlay()
// Desc: Take actions when the Play button is clicked.
//------------------------------------------------------------------------------
BOOL OnPlay()
{
	HRESULT hr = S_OK;

    if( NULL == g_pAudioplay )
    {
        return( E_UNEXPECTED );
    }

	//
	// Check previous status of the player
	//
	switch( g_Status )
	{
	case PAUSE:
		//
		// Player was PAUSEed, now resume it
		//
		hr = g_pAudioplay->Resume();
		if( FAILED( hr ) )
		{
			TCHAR tszErrMesg[ 128 ];
            (void)StringCchPrintf( tszErrMesg, ARRAYSIZE(tszErrMesg), _T( "Unable to resume (hr=%#X)" ), hr );
			MessageBox( g_hwndDialog, tszErrMesg, ERROR_DIALOG_TITLE, MB_OK );
		}
		else
		{
			SetCurrentStatus( PLAY );
		}
		
		break;
	
	case STOP:
        //
        // Player was STOPped, now start it
        //
        hr = g_pAudioplay->Start();
        if( FAILED( hr ) )
        {
            TCHAR tszErrMesg[ 128 ];
            (void)StringCchPrintf( tszErrMesg, ARRAYSIZE(tszErrMesg), _T("Unable to start (hr=%#X)"), hr );
            MessageBox( g_hwndDialog, tszErrMesg, ERROR_DIALOG_TITLE, MB_OK );
        }
        else
        {
            SetCurrentStatus( OPENING );
        }

        break;

    case CLOSED:
        //
        // The play is being called for the current file for the first time.
        // Start playing the file
        //
        SetCurrentStatus( OPENING );
        
        //
        // Get the file name
        //
        GetDlgItemText( g_hwndDialog, IDC_FILENAME, g_ptszFileName, MAX_PATH );

        //
        // Remove leading spaces from the file name        
        //
        TCHAR *ptszTemp = g_ptszFileName;
        while( *ptszTemp == _T(' ') )
        {
            ptszTemp++;
        }

        if( g_ptszFileName != ptszTemp )
        {
            memmove( g_ptszFileName, ptszTemp, sizeof( TCHAR ) * ( _tcslen( ptszTemp ) + 1 ) );
            SendDlgItemMessage( g_hwndDialog, IDC_FILENAME, WM_SETTEXT, 0, ( WPARAM )g_ptszFileName );
        }

        //
        // Open the file. We may need to convert the filename string from multibytes to wide characters
        //
#ifndef UNICODE
		{
			WCHAR pwszFileName[ MAX_PATH ];

			if( 0 == MultiByteToWideChar( CP_ACP, 0, g_ptszFileName, -1, pwszFileName, MAX_PATH ) )
			{
                //
                // Convertion failed
                //
				SetCurrentStatus( CLOSED );
				SetCurrentStatus( READY );
				break;
			}

			hr = g_pAudioplay->Open( pwszFileName );
		}
#else
		hr = g_pAudioplay->Open( g_ptszFileName );
#endif // UNICODE

		if( FAILED( hr ) )
		{
			SetCurrentStatus( CLOSED );
			SetCurrentStatus( READY );
		}
		else
		{
            //
            // Start to play from the beginning
            //
            hr = g_pAudioplay->Start();
            if( FAILED( hr ) )
            {
                TCHAR tszErrMesg[ 128 ];
                (void)StringCchPrintf( tszErrMesg, ARRAYSIZE(tszErrMesg), _T("Unable to start (hr=%#X)"), hr );
                MessageBox( g_hwndDialog, tszErrMesg, ERROR_DIALOG_TITLE, MB_OK );
            }
            else
            {
                //
                // Set the max range of the slider to be the value of the file's duration in milliseconds
                //
			    SendDlgItemMessage( g_hwndDialog, IDC_SLIDER, TBM_SETRANGEMAX, TRUE,
								    ( DWORD )( g_pAudioplay->GetFileDuration() / 10000 ) );
    			
                //
                // Update the window title with the file's name
                //
			    LPTSTR ptszFile = _tcsrchr( g_ptszFileName, _T( '\\' ) );
                if( NULL != ptszFile )
                {
			        SetWindowText( g_hwndDialog, ptszFile + 1 );
                }
                else
                {
			        SetWindowText( g_hwndDialog, g_ptszFileName );
                }
            }
		}

		break;
	}
	
	return TRUE;
}
//------------------------------------------------------------------------------
// Name: DlgProc()
// Desc: Dialog box procedure.
//------------------------------------------------------------------------------
INT_PTR CALLBACK DlgProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	HRESULT	hr		= S_OK;
	HICON	hIcon	= NULL;
	RECT	rect;

	switch( uMsg )
	{
	case WM_INITDIALOG:
		
		g_hwndDialog = hwndDlg;

		//
		// Load the application icon
		//
		hIcon = LoadIcon( g_hInst, MAKEINTRESOURCE( IDI_WMAICON ) );
		if( hIcon )
		{
			SendMessage( hwndDlg, WM_SETICON, ICON_SMALL, ( LPARAM )hIcon );
			SendMessage( hwndDlg, WM_SETICON, ICON_BIG, ( LPARAM )hIcon );
		}

		GetWindowRect( hwndDlg, &rect );

		//
		// Store the Window height in a global variable for future reference
		//
		g_iDlgHeight = rect.bottom - rect.top;

        //
        // Ready to open and play a file
        //
		SetCurrentStatus( READY );
		
        //
        // Create and initialize the audio player
        //
        g_pAudioplay = new CAudioPlay;
        if( NULL == g_pAudioplay )
        {
			//
			// Creation has failed. Close the application.
			//
			SendMessage( hwndDlg, WM_CLOSE, 0,0 );
            return TRUE;
        }

		hr = g_pAudioplay->Init();
		if( FAILED(hr) )
		{
			//
			// Init has failed. Close the application.
			//
			SendMessage( hwndDlg, WM_CLOSE, 0,0 );
		}

		return TRUE;

	case WM_COMMAND:

		switch( LOWORD( wParam ) ) 
		{
		case IDC_FILENAME:

			if( EN_CHANGE == HIWORD( wParam ) )
			{
				//
                // Filename has been changed
				// Use this notification for enabling or disabling the Play button
				//
				TCHAR tszFileName[ MAX_PATH ];

				GetDlgItemText( hwndDlg, IDC_FILENAME, tszFileName, MAX_PATH );

                //
                // If filename is not empty, enable the Play button
                //
				if( _tcslen( tszFileName) > 0 )
				{
					EnableWindow( GetDlgItem( hwndDlg, IDC_PLAY ), TRUE );

					SetCurrentStatus( CLOSED );
				}
				else
				{
					EnableWindow( GetDlgItem( hwndDlg, IDC_PLAY ), FALSE );
				}
				
				SetCurrentStatus( READY );
				
				return TRUE;
			}
			
			return FALSE;

		case IDC_OPEN:

            //
            // Show the OpenFile dialog
            //
			if( ShowOpenFileDialog() )
			{
				//
				// Display the file name
				//
				SetDlgItemText( hwndDlg, IDC_FILENAME, g_ptszFileName );

				SetFocus( GetDlgItem( hwndDlg, IDC_PLAY ) );
			}

			return TRUE;
		
		case IDC_STOP:
			
			SetCurrentStatus( STOPPING );

            //
            // Stop the audio player
            //
            if( NULL != g_pAudioplay )
            {
			    hr = g_pAudioplay->Stop();
			    if( FAILED( hr ) )
			    {
				    SetCurrentStatus( g_Status );

				    TCHAR tszErrMesg[128];
                    (void)StringCchPrintf( tszErrMesg, ARRAYSIZE(tszErrMesg), _T( "Unable to Stop (hr=%#X)" ), hr );
				    MessageBox( hwndDlg, tszErrMesg, ERROR_DIALOG_TITLE, MB_OK );
			    }
            }

			return TRUE;
			
		case IDC_PAUSE:
			
            //
            // Pause the audio player
            //
            if( NULL != g_pAudioplay )
            {
			    hr = g_pAudioplay->Pause();
			    if( FAILED( hr ) )
			    {
				    TCHAR tszErrMesg[128];
                    (void)StringCchPrintf( tszErrMesg, ARRAYSIZE(tszErrMesg), _T("Unable to Pause (hr=%#X)"), hr );
				    MessageBox( hwndDlg, tszErrMesg, ERROR_DIALOG_TITLE, MB_OK );
			    }
			    else
			    {
				    SetCurrentStatus( PAUSE );
			    }
            }

			break;
		
		case IDC_PLAY:
			
			return( OnPlay() );

		case IDCANCEL:
			//
			// Close the player before exiting application
			//
            if( NULL != g_pAudioplay )
            {
			    g_pAudioplay->Exit();
			    g_pAudioplay->Release();
            }

			EndDialog( hwndDlg, wParam );

			return TRUE;
		}
		break;

	case WM_HSCROLL:

        if( NULL == g_pAudioplay )
        {
            break;
        }

		//
		// Seek only when the file is seekable
		//
		if( ( LOWORD( wParam ) == TB_THUMBTRACK || 
			  LOWORD( wParam ) == TB_BOTTOM ||
			  LOWORD( wParam ) == TB_PAGEDOWN ||
			  LOWORD( wParam ) == TB_PAGEUP ||
			  LOWORD( wParam ) == TB_TOP ) &&
            g_pAudioplay->IsSeekable() )
		{
			//
			// Set g_IsSeeking, to be referenced when thumb tracking is over
			//
			g_IsSeeking = TRUE;
		}
		else if( LOWORD( wParam ) == TB_ENDTRACK && g_pAudioplay->IsSeekable() && g_IsSeeking )
		{
			DWORD_PTR dwPos = SendDlgItemMessage( hwndDlg, IDC_SLIDER, TBM_GETPOS, 0, 0 );

			// 
			// Start the file from the new position
			//
			hr = g_pAudioplay->Start( ( QWORD )dwPos * 10000 );
			if( FAILED ( hr ) )
			{
				g_IsSeeking = FALSE;
			}
		}

		break;
	}

    return FALSE;
}
//------------------------------------------------------------------------------
// Name: SetCurrentStatus()
// Desc: Update the controls.
//------------------------------------------------------------------------------
void SetCurrentStatus( AUDIOSTATUS currentStatus )
{
	RECT rect;

	switch( currentStatus )
	{	
	case READY:

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Ready" ) );
		
		GetWindowRect( g_hwndDialog, &rect );
		MoveWindow( g_hwndDialog,
					rect.left,
					rect.top,
					rect.right - rect.left,
					( UINT )( SMALLDLGSIZE *  g_iDlgHeight ),
					TRUE );

		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PAUSE ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_OPEN ), TRUE );

		SendDlgItemMessage( g_hwndDialog, IDC_FILENAME, EM_SETREADONLY, FALSE, 0 );
		return;

	case OPENING:

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Opening..." ) );

		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), TRUE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PLAY ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PAUSE ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_OPEN ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_SLIDER ), FALSE );

		SendDlgItemMessage( g_hwndDialog, IDC_FILENAME, EM_SETREADONLY, TRUE, 0 );
		SetFocus( GetDlgItem( g_hwndDialog, IDC_STOP ) );
		break;

	case PLAY:
		//
		// Reset the global variable which might have been set while seeking
		// or stop operation
		//
		g_IsSeeking = FALSE;

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Playing..." ) );

		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), TRUE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PLAY ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_OPEN ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_SLIDER ), g_pAudioplay->IsSeekable() );
        {
            DWORD_PTR max = SendDlgItemMessage( g_hwndDialog, IDC_SLIDER, TBM_GETRANGEMAX, 0,0 );
        }

		SendDlgItemMessage( g_hwndDialog, IDC_FILENAME, EM_SETREADONLY, ( WPARAM )TRUE, 0 );

		GetWindowRect( g_hwndDialog, &rect );
		MoveWindow( g_hwndDialog,
					rect.left,
					rect.top,
					rect.right - rect.left,
					g_iDlgHeight,
					TRUE );

		if( !g_pAudioplay->IsBroadcast() )
		{
			EnableWindow( GetDlgItem( g_hwndDialog, IDC_PAUSE ), TRUE );
		    SetFocus( GetDlgItem( g_hwndDialog, IDC_PAUSE ) );
		}
        else
        {
			EnableWindow( GetDlgItem( g_hwndDialog, IDC_PAUSE ), FALSE );
		    SetFocus( GetDlgItem( g_hwndDialog, IDC_STOP ) );
        }

		break;

	case PAUSE:

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Paused" ) );
		
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PAUSE ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PLAY ), TRUE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_SLIDER ), FALSE );

		SetFocus( GetDlgItem(g_hwndDialog, IDC_PLAY ) );

		break;

	case CLOSED:

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "" ) );

		EnableWindow( GetDlgItem( g_hwndDialog, IDC_OPEN ), TRUE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_SLIDER ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PLAY ), TRUE );

		SendDlgItemMessage( g_hwndDialog, IDC_FILENAME, EM_SETREADONLY, ( WPARAM )FALSE, 0 );
		SendDlgItemMessage( g_hwndDialog, IDC_SLIDER , TBM_SETPOS, TRUE, 0 );
		SendDlgItemMessageW( g_hwndDialog, IDC_DURATION, WM_SETTEXT, 0, ( WPARAM )L"" );

		GetWindowRect( g_hwndDialog, &rect );
		MoveWindow( g_hwndDialog,
					rect.left,
					rect.top,
					rect.right - rect.left,
					( UINT )( SMALLDLGSIZE * g_iDlgHeight),
					TRUE );
		break;

	case STOP:
		
		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Stopped" ) );
		
		SendDlgItemMessage( g_hwndDialog, IDC_SLIDER , TBM_SETPOS, TRUE, 0 ); 

        EnableWindow( GetDlgItem( g_hwndDialog, IDC_PAUSE ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PLAY ), TRUE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_OPEN ), TRUE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_SLIDER ), FALSE );

		SendDlgItemMessage( g_hwndDialog, IDC_FILENAME, EM_SETREADONLY, ( WPARAM ) FALSE, 0 );

		SetFocus( GetDlgItem( g_hwndDialog, IDC_PLAY ) );

		g_IsSeeking = FALSE;
        SetTime( 0, g_pAudioplay->GetFileDuration() );

		break;

	case BUFFERING:

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Buffering..." ) );
		return;

	case STOPPING:
		//
		// Since we are going to position the trackbar at the beginning,
		// set the global variable
		//
		g_IsSeeking = TRUE;
		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Trying to Stop...Please Wait" ) );
			
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_PAUSE ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_OPEN ), FALSE );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_SLIDER ), FALSE );

		SendDlgItemMessage( g_hwndDialog, IDC_FILENAME, EM_SETREADONLY, ( WPARAM )TRUE, 0 );
		SetFocus( GetDlgItem( g_hwndDialog, IDC_STATUS ) );

		return;

	case ACQUIRINGLICENSE:

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Acquiring License..." ) );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), TRUE );

		{
			LPTSTR ptszFile = _tcsrchr( g_ptszFileName, _T( '\\' ) );
            if( NULL == ptszFile )
            {
			    SetWindowText( g_hwndDialog, g_ptszFileName );
            }
            else
            {
			    SetWindowText( g_hwndDialog, ptszFile + 1 );
            }
		}

		SetFocus( GetDlgItem( g_hwndDialog, IDC_STOP ) );
		break;

	case INDIVIDUALIZING:

		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Individualizing..." ) );
		EnableWindow( GetDlgItem( g_hwndDialog, IDC_STOP ), TRUE );

		{
			LPTSTR ptszFile = _tcsrchr( g_ptszFileName, _T( '\\' ) );
            if( NULL == ptszFile )
            {
			    SetWindowText( g_hwndDialog, g_ptszFileName );
            }
            else
            {
			    SetWindowText( g_hwndDialog, ptszFile + 1 );
            }
		}

		SetFocus( GetDlgItem( g_hwndDialog, IDC_STOP ) );
		break;

	case LICENSEACQUIRED:
		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "License acquired" ) );
		break;

	case INDIVIDUALIZED:
		SetDlgItemText( g_hwndDialog, IDC_STATUS, _T( "Individualization complete" ) );
		break;
	
	default:
		return;
	}

	g_Status = currentStatus;
}
Example #15
0
static INT_PTR CALLBACK DlgProcSetStatusMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		SendDlgItemMessage(hwndDlg, IDC_STATUSMESSAGE, EM_LIMITTEXT, MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE - 1, 0);
		mir_subclassWindow(GetDlgItem(hwndDlg, IDC_STATUSMESSAGE), StatusMsgEditSubclassProc);
		return TRUE;

	case WMU_SETDATA:
	{
		SetStatusMessageData *data = (SetStatusMessageData *)malloc(sizeof(SetStatusMessageData));
		data->status = (int)wParam;
		data->proto_num = (int)lParam;

		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)data);

		if (data->proto_num >= 0) {
			Protocol *proto = protocols->Get(data->proto_num);

			HICON hIcon = (HICON)CallProtoService(proto->name, PS_LOADICON, PLI_PROTOCOL, 0);
			if (hIcon != NULL) {
				SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
				DestroyIcon(hIcon);
			}

			TCHAR title[256];
			mir_sntprintf(title, _countof(title), TranslateT("Set my status message for %s"), proto->description);
			SetWindowText(hwndDlg, title);

			SetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, proto->GetStatusMsg());
		}
		else if (data->status != 0) {
			SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_LoadProtoIcon(NULL, data->status));

			TCHAR title[256];
			mir_sntprintf(title, _countof(title), TranslateT("Set my status message for %s"), pcli->pfnGetStatusModeDescription(data->status, 0));
			SetWindowText(hwndDlg, title);

			SetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, protocols->GetDefaultStatusMsg(data->status));
		}
		else {
			SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_MIRANDA));

			SetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, protocols->GetDefaultStatusMsg());
		}

		return TRUE;
	}
	case WM_COMMAND:
		switch (wParam) {
		case IDOK:
		{
			TCHAR tmp[MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE];
			GetDlgItemText(hwndDlg, IDC_STATUSMESSAGE, tmp, _countof(tmp));

			SetStatusMessageData *data = (SetStatusMessageData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

			if (data->proto_num >= 0)
				protocols->Get(data->proto_num)->SetStatusMsg(tmp);
			else if (data->status == 0)
				protocols->SetStatusMsgs(tmp);
			else
				protocols->SetStatusMsgs(data->status, tmp);

			DestroyWindow(hwndDlg);
		}
		break;

		case IDCANCEL:
			DestroyWindow(hwndDlg);
			break;
		}
		break;

	case WM_CLOSE:
		DestroyWindow(hwndDlg);
		break;

	case WM_DESTROY:
		SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_STATUSMESSAGE), GWLP_WNDPROC,
			GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_STATUSMESSAGE), GWLP_USERDATA));
		free((SetStatusMessageData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA));
		InterlockedExchange(&status_msg_dialog_open, 0);
		break;
	}

	return FALSE;
}
Example #16
0
HRESULT CLAVSplitterSettingsProp::OnApplyChanges()
{
  ASSERT(m_pLAVF != nullptr);
  HRESULT hr = S_OK;
  DWORD dwVal;
  BOOL bFlag;

  WCHAR buffer[LANG_BUFFER_SIZE];
  // Save audio language
  SendDlgItemMessage(m_Dlg, IDC_PREF_LANG, WM_GETTEXT, LANG_BUFFER_SIZE, (LPARAM)&buffer);
  CHECK_HR(hr = m_pLAVF->SetPreferredLanguages(buffer));

  // Save subtitle language
  SendDlgItemMessage(m_Dlg, IDC_PREF_LANG_SUBS, WM_GETTEXT, LANG_BUFFER_SIZE, (LPARAM)&buffer);

  if (m_selectedSubMode == LAVSubtitleMode_Advanced) {
    CHECK_HR(hr = m_pLAVF->SetPreferredSubtitleLanguages(m_subLangBuffer));
    CHECK_HR(hr = m_pLAVF->SetAdvancedSubtitleConfig(buffer));
  } else {
    CHECK_HR(hr = m_pLAVF->SetPreferredSubtitleLanguages(buffer));
    CHECK_HR(hr = m_pLAVF->SetAdvancedSubtitleConfig(m_advSubBuffer));
  }

  // Save subtitle mode
  dwVal = (DWORD)SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_GETCURSEL, 0, 0);
  CHECK_HR(hr = m_pLAVF->SetSubtitleMode((LAVSubtitleMode)dwVal));

  bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_BD_SEPARATE_FORCED_SUBS, BM_GETCHECK, 0, 0);
  CHECK_HR(hr = m_pLAVF->SetPGSForcedStream(bFlag));

  bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_BD_ONLY_FORCED_SUBS, BM_GETCHECK, 0, 0);
  CHECK_HR(hr = m_pLAVF->SetPGSOnlyForced(bFlag));

  int vc1flag = (int)SendDlgItemMessage(m_Dlg, IDC_VC1TIMESTAMP, BM_GETCHECK, 0, 0);
  CHECK_HR(hr = m_pLAVF->SetVC1TimestampMode(vc1flag));

  bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_MKV_EXTERNAL, BM_GETCHECK, 0, 0);
  CHECK_HR(hr = m_pLAVF->SetLoadMatroskaExternalSegments(bFlag));

  bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_SUBSTREAMS, BM_GETCHECK, 0, 0);
  CHECK_HR(hr = m_pLAVF->SetSubstreamsEnabled(bFlag));

  bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_STREAM_SWITCH_REMOVE_AUDIO, BM_GETCHECK, 0, 0);
  CHECK_HR(hr = m_pLAVF->SetStreamSwitchRemoveAudio(bFlag));

  bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_SELECT_AUDIO_QUALITY, BM_GETCHECK, 0, 0);
  CHECK_HR(hr = m_pLAVF->SetPreferHighQualityAudioStreams(bFlag));

  bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_IMPAIRED_AUDIO, BM_GETCHECK, 0, 0);
  CHECK_HR(hr = m_pLAVF->SetUseAudioForHearingVisuallyImpaired(bFlag));

  SendDlgItemMessage(m_Dlg, IDC_QUEUE_MEM, WM_GETTEXT, LANG_BUFFER_SIZE, (LPARAM)&buffer);
  int maxMem = _wtoi(buffer);
  CHECK_HR(hr = m_pLAVF->SetMaxQueueMemSize(maxMem));

  SendDlgItemMessage(m_Dlg, IDC_QUEUE_PACKETS, WM_GETTEXT, LANG_BUFFER_SIZE, (LPARAM)&buffer);
  int maxPackets = _wtoi(buffer);
  CHECK_HR(hr = m_pLAVF->SetMaxQueueSize(maxPackets));

  SendDlgItemMessage(m_Dlg, IDC_STREAM_ANADUR, WM_GETTEXT, LANG_BUFFER_SIZE, (LPARAM)&buffer);
  int duration = _wtoi(buffer);
  CHECK_HR(hr = m_pLAVF->SetNetworkStreamAnalysisDuration(duration));

  bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_TRAYICON, BM_GETCHECK, 0, 0);
  CHECK_HR(hr = m_pLAVF->SetTrayIcon(bFlag));

  LoadData();

done:    
  return hr;
}
Example #17
0
static INT_PTR CALLBACK DlgProcSetNickname(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM)
{
	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		SendDlgItemMessage(hwndDlg, IDC_NICKNAME, EM_LIMITTEXT, MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE - 1, 0);
		return TRUE;

	case WMU_SETDATA:
	{
		int proto_num = (int)wParam;

		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, proto_num);

		if (proto_num == -1) {
			SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_MIRANDA));

			// All protos have the same nick?
			if (protocols->GetSize() > 0) {
				TCHAR *nick = protocols->Get(0)->nickname;

				bool foundDefNick = true;
				for (int i = 1; foundDefNick && i < protocols->GetSize(); i++) {
					if (mir_tstrcmpi(protocols->Get(i)->nickname, nick) != 0) {
						foundDefNick = false;
						break;
					}
				}

				if (foundDefNick)
					if (mir_tstrcmpi(protocols->default_nick, nick) != 0)
						mir_tstrcpy(protocols->default_nick, nick);
			}

			SetDlgItemText(hwndDlg, IDC_NICKNAME, protocols->default_nick);
			SendDlgItemMessage(hwndDlg, IDC_NICKNAME, EM_LIMITTEXT, MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE, 0);
		}
		else {
			Protocol *proto = protocols->Get(proto_num);

			TCHAR tmp[128];
			mir_sntprintf(tmp, _countof(tmp), TranslateT("Set my nickname for %s"), proto->description);

			SetWindowText(hwndDlg, tmp);

			HICON hIcon = (HICON)CallProtoService(proto->name, PS_LOADICON, PLI_PROTOCOL, 0);
			if (hIcon != NULL) {
				SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
				DestroyIcon(hIcon);
			}

			SetDlgItemText(hwndDlg, IDC_NICKNAME, proto->nickname);
			SendDlgItemMessage(hwndDlg, IDC_NICKNAME, EM_LIMITTEXT,
				min(MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE, proto->GetNickMaxLength()), 0);
		}

		return TRUE;
	}

	case WM_COMMAND:
		switch (wParam) {
		case IDOK:
		{
			TCHAR tmp[MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE];
			GetDlgItemText(hwndDlg, IDC_NICKNAME, tmp, _countof(tmp));

			LONG_PTR proto_num = GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
			if (proto_num == -1)
				protocols->SetNicks(tmp);
			else
				protocols->Get(proto_num)->SetNick(tmp);

			DestroyWindow(hwndDlg);
			break;
		}
		case IDCANCEL:
			DestroyWindow(hwndDlg);
			break;
		}
		break;

	case WM_CLOSE:
		DestroyWindow(hwndDlg);
		break;

	case WM_DESTROY:
		InterlockedExchange(&nickname_dialog_open, 0);
		break;
	}

	return FALSE;
}
Example #18
0
BOOL TSetupSheet::SetData()
{
	if (resId == MAIN_SHEET) {
		if (sv) {
			sv->bufSize			= cfg->bufSize;
			sv->estimateMode	= cfg->estimateMode;
			sv->ignoreErr		= cfg->ignoreErr;
			sv->enableVerify	= cfg->enableVerify;
			sv->enableAcl		= cfg->enableAcl;
			sv->enableStream	= cfg->enableStream;
			sv->speedLevel		= cfg->speedLevel;
			sv->isExtendFilter	= cfg->isExtendFilter;
			sv->enableOwdel		= cfg->enableOwdel;
		}
		SetDlgItemInt(BUFSIZE_EDIT, cfg->bufSize);
		CheckDlgButton(ESTIMATE_CHECK, cfg->estimateMode);
		CheckDlgButton(IGNORE_CHECK, cfg->ignoreErr);
		CheckDlgButton(VERIFY_CHECK, cfg->enableVerify);
		CheckDlgButton(ACL_CHECK, cfg->enableAcl);
		CheckDlgButton(STREAM_CHECK, cfg->enableStream);
		SendDlgItemMessage(SPEED_SLIDER, TBM_SETRANGE, 0, MAKELONG(SPEED_SUSPEND, SPEED_FULL));
		SetSpeedLevelLabel(this, cfg->speedLevel);
		CheckDlgButton(EXTENDFILTER_CHECK, cfg->isExtendFilter);
		CheckDlgButton(OWDEL_CHECK, cfg->enableOwdel);
	}
	else if (resId == IO_SHEET) {
		SetDlgItemInt(MAXTRANS_EDIT, cfg->maxTransSize);
		SetDlgItemInt(MAXOVL_EDIT, cfg->maxOvlNum);
		if (cfg->minSectorSize == 0 || cfg->minSectorSize == 4096) {
			CheckDlgButton(SECTOR4096_CHECK, cfg->minSectorSize == 4096);
		} else {
			::EnableWindow(GetDlgItem(SECTOR4096_CHECK), FALSE);
		}
		CheckDlgButton(READOSBUF_CHECK, cfg->isReadOsBuf);
		SetDlgItemInt(NONBUFMINNTFS_EDIT, cfg->nbMinSizeNtfs);
		SetDlgItemInt(NONBUFMINFAT_EDIT, cfg->nbMinSizeFat);
	}
	else if (resId == PHYSDRV_SHEET) {
		SetDlgItemText(DRIVEMAP_EDIT, cfg->driveMap);
		SendDlgItemMessage(NETDRVMODE_COMBO, CB_ADDSTRING, 0, (LPARAM)LoadStr(IDS_NETDRV_UNC));
		SendDlgItemMessage(NETDRVMODE_COMBO, CB_ADDSTRING, 0, (LPARAM)LoadStr(IDS_NETDRV_SVR));
		SendDlgItemMessage(NETDRVMODE_COMBO, CB_ADDSTRING, 0, (LPARAM)LoadStr(IDS_NETDRV_ALL));
		SendDlgItemMessage(NETDRVMODE_COMBO, CB_SETCURSEL, cfg->netDrvMode, 0);
	}
	else if (resId == PARALLEL_SHEET) {
		SetDlgItemInt(MAXRUN_EDIT, cfg->maxRunNum);
		CheckDlgButton(FORCESTART_CHECK, cfg->forceStart);
	}
	else if (resId == COPYOPT_SHEET) {
		CheckDlgButton(SAMEDIR_RENAME_CHECK, cfg->isSameDirRename);
		CheckDlgButton(EMPTYDIR_CHECK, cfg->skipEmptyDir);
		CheckDlgButton(REPARSE_CHECK, cfg->isReparse);
		::EnableWindow(GetDlgItem(REPARSE_CHECK), TRUE);
		CheckDlgButton(MOVEATTR_CHECK, cfg->enableMoveAttr);
		CheckDlgButton(SERIALMOVE_CHECK, cfg->serialMove);
		CheckDlgButton(SERIALVERIFYMOVE_CHECK, cfg->serialVerifyMove);
		SendDlgItemMessage(HASH_COMBO, CB_ADDSTRING, 0, (LPARAM)"MD5");
		SendDlgItemMessage(HASH_COMBO, CB_ADDSTRING, 0, (LPARAM)"SHA-1");
		SendDlgItemMessage(HASH_COMBO, CB_ADDSTRING, 0, (LPARAM)"SHA-256");
		SendDlgItemMessage(HASH_COMBO, CB_SETCURSEL, cfg->hashMode, 0);
		SetDlgItemInt(TIMEGRACE_EDIT, cfg->timeDiffGrace);
	}
	else if (resId == DEL_SHEET) {
		CheckDlgButton(NSA_CHECK, cfg->enableNSA);
		CheckDlgButton(DELDIR_CHECK, cfg->delDirWithFilter);
	}
	else if (resId == LOG_SHEET) {
		SetDlgItemInt(HISTORY_EDIT, cfg->maxHistoryNext);
		CheckDlgButton(ERRLOG_CHECK, cfg->isErrLog);
		CheckDlgButton(UTF8LOG_CHECK, cfg->isUtf8Log);
		::EnableWindow(GetDlgItem(UTF8LOG_CHECK), TRUE);
		CheckDlgButton(FILELOG_CHECK, cfg->fileLogMode);
		CheckDlgButton(TIMESTAMP_CHECK, (cfg->fileLogFlags & FastCopy::FILELOG_TIMESTAMP) ?
			TRUE : FALSE);
		CheckDlgButton(FILESIZE_CHECK,  (cfg->fileLogFlags & FastCopy::FILELOG_FILESIZE)  ?
			TRUE : FALSE);
		CheckDlgButton(ACLERRLOG_CHECK, cfg->aclErrLog);
		::EnableWindow(GetDlgItem(ACLERRLOG_CHECK), TRUE);
		CheckDlgButton(STREAMERRLOG_CHECK, cfg->streamErrLog);
		::EnableWindow(GetDlgItem(STREAMERRLOG_CHECK), TRUE);
	}
	else if (resId == MISC_SHEET) {
		CheckDlgButton(EXECCONFIRM_CHECK, cfg->execConfirm);
		CheckDlgButton(TASKBAR_CHECK, cfg->taskbarMode);
		CheckDlgButton(FINISH_CHECK, (cfg->finishNotify & 1));
		CheckDlgButton(SPAN1_RADIO + cfg->infoSpan, 1);
		CheckDlgButton(PREVENTSLEEP_CHECK, cfg->preventSleep);

		if ((cfg->lcid != -1 || GetSystemDefaultLCID() != 0x409)) { // == 0x411 改成 != 0x409 让所有语言都可以切换到英文
			::ShowWindow(GetDlgItem(LCID_CHECK), SW_SHOW);
			::EnableWindow(GetDlgItem(LCID_CHECK), TRUE);
			CheckDlgButton(LCID_CHECK, cfg->lcid == -1 || cfg->lcid != 0x409 ? FALSE : TRUE);
		}
	}
	return	TRUE;
}
Example #19
0
BOOL CALLBACK decbox(HWND hdwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
	dword dec_id,d_val;
	lptr d_adr;
	switch(message)
	{
	case WM_COMMAND:
		{
			switch(wParam)
			{
			case IDOK:
				if(SendDlgItemMessage(hdwnd,idc_xor,BM_GETCHECK,(WPARAM)0,(LPARAM)0))
					lastdec=decxor;
				else if(SendDlgItemMessage(hdwnd,idc_mul,BM_GETCHECK,(WPARAM)0,(LPARAM)0))
					lastdec=decmul;
				else if(SendDlgItemMessage(hdwnd,idc_add,BM_GETCHECK,(WPARAM)0,(LPARAM)0))
					lastdec=decadd;
				else if(SendDlgItemMessage(hdwnd,idc_sub,BM_GETCHECK,(WPARAM)0,(LPARAM)0))
					lastdec=decsub;
				else if(SendDlgItemMessage(hdwnd,idc_rot,BM_GETCHECK,(WPARAM)0,(LPARAM)0))
					lastdec=decrot;
				else if(SendDlgItemMessage(hdwnd,idc_xadd,BM_GETCHECK,(WPARAM)0,(LPARAM)0))
					lastdec=decxadd;
				else
					lastdec=decnull;
				if(SendDlgItemMessage(hdwnd,idc_byte,BM_GETCHECK,(WPARAM)0,(LPARAM)0))
					lastditem=decbyte;
				else if(SendDlgItemMessage(hdwnd,idc_word,BM_GETCHECK,(WPARAM)0,(LPARAM)0))
					lastditem=decword;
				else if(SendDlgItemMessage(hdwnd,idc_dword,BM_GETCHECK,(WPARAM)0,(LPARAM)0))
					lastditem=decdword;
				else if(SendDlgItemMessage(hdwnd,idc_array,BM_GETCHECK,(WPARAM)0,(LPARAM)0))
					lastditem=decarray;
				else
					lastditem=decbyte;
				SendDlgItemMessage(hdwnd,idc_value,WM_GETTEXT,(WPARAM)18,(LPARAM)lastvalue);
				SendDlgItemMessage(hdwnd,idc_arrayseg,WM_GETTEXT,(WPARAM)18,(LPARAM)last_seg);
				SendDlgItemMessage(hdwnd,idc_arrayoffset,WM_GETTEXT,(WPARAM)18,(LPARAM)lastoffset);
				if(IsDlgButtonChecked(hdwnd,idc_applytoexe))
					patchexe=true;
				else
					patchexe=false;
				sscanf(lastvalue,"%lx",&d_val);
				sscanf(last_seg,"%lx",&d_adr.segm);
				sscanf(lastoffset,"%lx",&d_adr.offs);
				if((g_options.readonly)&&(patchexe))
				{
					patchexe=false;
					MessageBox(g_hMainWnd,"File opened readonly - unable to patch","Borg Message",MB_OK);
				}
				dec_id=decrypter.add_decrypted(blk.top,blk.bottom,lastdec,lastditem,d_val,d_adr,patchexe);
				decrypter.process_dec(dec_id);
				if(patchexe)
					decrypter.exepatch(dec_id);
				EndDialog(hdwnd,NULL);
				return true;
			case IDCANCEL:
				EndDialog(hdwnd,NULL);
				return true;
			default:
				break;
			}
		}
		break;
	case WM_INITDIALOG:
		CenterWindow(hdwnd);
		switch(lastdec)
		{
		case decxor:
			SendDlgItemMessage(hdwnd,idc_xor,BM_SETCHECK,(WPARAM)1,(LPARAM)0);
			break;
		case decmul:
			SendDlgItemMessage(hdwnd,idc_mul,BM_SETCHECK,(WPARAM)1,(LPARAM)0);
			break;
		case decadd:
			SendDlgItemMessage(hdwnd,idc_add,BM_SETCHECK,(WPARAM)1,(LPARAM)0);
			break;
		case decsub:
			SendDlgItemMessage(hdwnd,idc_sub,BM_SETCHECK,(WPARAM)1,(LPARAM)0);
			break;
		case decrot:
			SendDlgItemMessage(hdwnd,idc_rot,BM_SETCHECK,(WPARAM)1,(LPARAM)0);
			break;
		case decxadd:
			SendDlgItemMessage(hdwnd,idc_xadd,BM_SETCHECK,(WPARAM)1,(LPARAM)0);
			break;
		default:
			SendDlgItemMessage(hdwnd,idc_xor,BM_SETCHECK,(WPARAM)1,(LPARAM)0);
			break;
		}
		switch(lastditem)
		{
		case decbyte:
			SendDlgItemMessage(hdwnd,idc_byte,BM_SETCHECK,(WPARAM)1,(LPARAM)0);
			break;
		case decword:
			SendDlgItemMessage(hdwnd,idc_word,BM_SETCHECK,(WPARAM)1,(LPARAM)0);
			break;
		case decdword:
			SendDlgItemMessage(hdwnd,idc_dword,BM_SETCHECK,(WPARAM)1,(LPARAM)0);
			break;
		case decarray:
			SendDlgItemMessage(hdwnd,idc_array,BM_SETCHECK,(WPARAM)1,(LPARAM)0);
			break;
		default:
			SendDlgItemMessage(hdwnd,idc_byte,BM_SETCHECK,(WPARAM)1,(LPARAM)0);
			break;
		}
		SendDlgItemMessage(hdwnd,idc_value,WM_SETTEXT,(WPARAM)0,(LPARAM)lastvalue);
		SendDlgItemMessage(hdwnd,idc_arrayseg,WM_SETTEXT,(WPARAM)0,(LPARAM)last_seg);
		SendDlgItemMessage(hdwnd,idc_arrayoffset,WM_SETTEXT,(WPARAM)0,(LPARAM)lastoffset);
		CheckDlgButton(hdwnd,idc_applytoexe,patchexe);
		SetFocus(GetDlgItem(hdwnd,idc_value));
		return false;
	default:
		break;
	}
	return false;
}
Example #20
0
BOOL TSetupSheet::GetData()
{
	if (resId == MAIN_SHEET) {
		cfg->bufSize        = GetDlgItemInt(BUFSIZE_EDIT);
		cfg->estimateMode   = IsDlgButtonChecked(ESTIMATE_CHECK);
		cfg->ignoreErr      = IsDlgButtonChecked(IGNORE_CHECK);
		cfg->enableVerify   = IsDlgButtonChecked(VERIFY_CHECK);
		cfg->enableAcl      = IsDlgButtonChecked(ACL_CHECK);
		cfg->enableStream   = IsDlgButtonChecked(STREAM_CHECK);
		cfg->speedLevel     = (int)SendDlgItemMessage(SPEED_SLIDER, TBM_GETPOS, 0, 0);
		cfg->isExtendFilter = IsDlgButtonChecked(EXTENDFILTER_CHECK);
		cfg->enableOwdel    = IsDlgButtonChecked(OWDEL_CHECK);

		ReflectToMainWindow();
	}
	else if (resId == IO_SHEET) {
		cfg->maxTransSize  = GetDlgItemInt(MAXTRANS_EDIT);
		cfg->maxOvlNum     = GetDlgItemInt(MAXOVL_EDIT);
		if (cfg->minSectorSize == 0 || cfg->minSectorSize == 4096) {
			cfg->minSectorSize = IsDlgButtonChecked(SECTOR4096_CHECK) ? 4096 : 0;
		}
		cfg->isReadOsBuf   = IsDlgButtonChecked(READOSBUF_CHECK);
		cfg->nbMinSizeNtfs = GetDlgItemInt(NONBUFMINNTFS_EDIT);
		cfg->nbMinSizeFat  = GetDlgItemInt(NONBUFMINFAT_EDIT);

		char	buf[sizeof(cfg->driveMap)];
		GetDlgItemText(DRIVEMAP_EDIT, buf, sizeof(buf));
		strcpy(cfg->driveMap, buf);
	}
	else if (resId == PHYSDRV_SHEET) {
		GetDlgItemText(DRIVEMAP_EDIT, cfg->driveMap, sizeof(cfg->driveMap));
		cfg->netDrvMode = (int)SendDlgItemMessage(NETDRVMODE_COMBO, CB_GETCURSEL, 0, 0);
	}
	else if (resId == PARALLEL_SHEET) {
		cfg->maxRunNum  = GetDlgItemInt(MAXRUN_EDIT);
		cfg->forceStart = IsDlgButtonChecked(FORCESTART_CHECK);
	}
	else if (resId == COPYOPT_SHEET) {
		cfg->isSameDirRename  = IsDlgButtonChecked(SAMEDIR_RENAME_CHECK);
		cfg->skipEmptyDir     = IsDlgButtonChecked(EMPTYDIR_CHECK);
		cfg->isReparse        = IsDlgButtonChecked(REPARSE_CHECK);
		cfg->enableMoveAttr   = IsDlgButtonChecked(MOVEATTR_CHECK);
		cfg->serialMove       = IsDlgButtonChecked(SERIALMOVE_CHECK);
		cfg->serialVerifyMove = IsDlgButtonChecked(SERIALVERIFYMOVE_CHECK);
		cfg->hashMode         = (int)SendDlgItemMessage(HASH_COMBO, CB_GETCURSEL, 0, 0);
		cfg->timeDiffGrace    = GetDlgItemInt(TIMEGRACE_EDIT);
	}
	else if (resId == DEL_SHEET) {
		cfg->enableNSA        = IsDlgButtonChecked(NSA_CHECK);
		cfg->delDirWithFilter = IsDlgButtonChecked(DELDIR_CHECK);
	}
	else if (resId == LOG_SHEET) {
		cfg->maxHistoryNext = GetDlgItemInt(HISTORY_EDIT);
		cfg->isErrLog       = IsDlgButtonChecked(ERRLOG_CHECK);
		cfg->isUtf8Log      = IsDlgButtonChecked(UTF8LOG_CHECK);
		cfg->fileLogMode    = IsDlgButtonChecked(FILELOG_CHECK);
		cfg->fileLogFlags   = (IsDlgButtonChecked(TIMESTAMP_CHECK) ? FastCopy::FILELOG_TIMESTAMP
			: 0) | (IsDlgButtonChecked(FILESIZE_CHECK)  ? FastCopy::FILELOG_FILESIZE : 0);
		cfg->aclErrLog      = IsDlgButtonChecked(ACLERRLOG_CHECK);
		cfg->streamErrLog   = IsDlgButtonChecked(STREAMERRLOG_CHECK);
	}
	else if (resId == MISC_SHEET) {
		cfg->execConfirm = IsDlgButtonChecked(EXECCONFIRM_CHECK);
		cfg->taskbarMode = IsDlgButtonChecked(TASKBAR_CHECK);
		if (IsDlgButtonChecked(FINISH_CHECK)) {
			cfg->finishNotify |= 1;
		}
		else {
			cfg->finishNotify &= ~1;
		}
		cfg->infoSpan    =	IsDlgButtonChecked(SPAN1_RADIO) ? 0 :
							IsDlgButtonChecked(SPAN2_RADIO) ? 1 : 2;

		cfg->preventSleep = IsDlgButtonChecked(PREVENTSLEEP_CHECK);

		if (::IsWindowEnabled(GetDlgItem(LCID_CHECK))) {
			cfg->lcid = IsDlgButtonChecked(LCID_CHECK) ? 0x409 : -1;
		}
	}
	return	TRUE;
}
void TpictPropPage::init(void)
{
 SendDlgItemMessage(m_hwnd,IDC_TBR_LUMGAIN,TBM_SETRANGE,TRUE,MAKELPARAM(0,256));
 SendDlgItemMessage(m_hwnd,IDC_TBR_LUMGAIN,TBM_SETLINESIZE,0,1);
 SendDlgItemMessage(m_hwnd,IDC_TBR_LUMGAIN,TBM_SETPAGESIZE,0,32); 
 SendDlgItemMessage(m_hwnd,IDC_TBR_LUMOFFSET,TBM_SETRANGE,TRUE,MAKELPARAM(0,512));
 SendDlgItemMessage(m_hwnd,IDC_TBR_LUMOFFSET,TBM_SETLINESIZE,0,1);
 SendDlgItemMessage(m_hwnd,IDC_TBR_LUMOFFSET,TBM_SETPAGESIZE,0,64); 
 SendDlgItemMessage(m_hwnd,IDC_TBR_GAMMA,TBM_SETRANGE,TRUE,MAKELPARAM(1,400));
 SendDlgItemMessage(m_hwnd,IDC_TBR_GAMMA,TBM_SETLINESIZE,0,1);
 SendDlgItemMessage(m_hwnd,IDC_TBR_GAMMA,TBM_SETPAGESIZE,0,40); 
 SendDlgItemMessage(m_hwnd,IDC_TBR_HUE,TBM_SETRANGE,TRUE,MAKELPARAM(-180,180));
 SendDlgItemMessage(m_hwnd,IDC_TBR_HUE,TBM_SETLINESIZE,0,1);
 SendDlgItemMessage(m_hwnd,IDC_TBR_HUE,TBM_SETPAGESIZE,0,20); 
 SendDlgItemMessage(m_hwnd,IDC_TBR_SATURATION,TBM_SETRANGE,TRUE,MAKELPARAM(0,128));
 SendDlgItemMessage(m_hwnd,IDC_TBR_SATURATION,TBM_SETLINESIZE,0,1);
 SendDlgItemMessage(m_hwnd,IDC_TBR_SATURATION,TBM_SETPAGESIZE,0,8); 
 cfg2dlg();
}
BOOL CALLBACK DialogFloppyDump(
						  HWND  hwndDlg,	// handle of dialog box
						  UINT  message,	// message
						  WPARAM  wParam,	// first message parameter
						  LPARAM  lParam 	// second message parameter
						  )
{
	static char nbinstance=0;
	char tempstr[128];
	int wmId, wmEvent;
	DWORD sit;

	wmId    = LOWORD(wParam); 
	wmEvent = HIWORD(wParam); 
	
	switch (message) 
	{
		
	case WM_COMMAND:
		
		switch (wmEvent)
		{
			case BN_CLICKED:
			
			
			break;	
		}

		switch (wmId)
		{

			case IDOK:
				if(!fdparams.status)
				{
					//KillTimer(hwndDlg,34);
					nbinstance=0;
					DestroyWindow(hwndDlg);
				}
			break;

			
			case IDLOAD_READDISK:
				if(!fdparams.status)
				{
					fdparams.floppydisk=(FLOPPY*)malloc(sizeof(FLOPPY));
					memset(fdparams.floppydisk,0,sizeof(FLOPPY));

					fdparams.windowshwd=hwndDlg;
					fdparams.flopemu=flopemu;
					fdparams.double_step=1;
					fdparams.number_of_side=1;
					fdparams.number_of_track=GetDlgItemInt(hwndDlg,IDC_NUMBEROFTRACK_DUMP,NULL,0);
					fdparams.status=1;

					if(SendDlgItemMessage(hwndDlg,IDC_RADIO1,BM_GETCHECK,0,0))
						fdparams.drive=0;
					if(SendDlgItemMessage(hwndDlg,IDC_RADIO2,BM_GETCHECK,0,0))
						fdparams.drive=1;

					if(SendDlgItemMessage(hwndDlg,IDC_DOUBLESIDE_DUMP,BM_GETCHECK,0,0))
					{
						fdparams.number_of_side=2;
					}

					if(SendDlgItemMessage(hwndDlg,IDC_DOUBLESTEP_DUMP,BM_GETCHECK,0,0))
					{
						fdparams.double_step=2;
					}

					sprintf(tempstr,"%d Sector(s) Read, %d bytes, %d Bad sector(s)",0,0,0);
					SetDlgItemText(hwndDlg,IDC_EDIT2,tempstr);

					CreateThread(NULL,0,&DumpThreadProc,&fdparams,0,&sit);

				}
			break;

			
			default:;
			break;

		}
		
		
		break;
		
		
		case WM_INITDIALOG:
			if(nbinstance!=0)
			{
				DestroyWindow(hwndDlg);
			}
			else
			{

				SendDlgItemMessage(hwndDlg,IDC_DOUBLESIDE_DUMP,BM_SETCHECK,BST_CHECKED,0);
				SendDlgItemMessage(hwndDlg,IDC_RADIO1,BM_SETCHECK,BST_CHECKED,0);
				SetDlgItemInt(hwndDlg,IDC_NUMBEROFTRACK_DUMP,80,0);
				memset(&fdparams,0,sizeof(fdparams));
				sprintf(tempstr,"%d Sector(s) Read, %d bytes, %d Bad sector(s)",0,0,0);
				SetDlgItemText(hwndDlg,IDC_EDIT2,tempstr);
			}
			//SetTimer(hwndDlg,34,500,NULL);
			break;
			
		case WM_CLOSE:
			if(!fdparams.status)
			{
				//KillTimer(hwndDlg,34);
				nbinstance=0;
				DestroyWindow(hwndDlg);
			}
			break;
			
			
		case WM_TIMER:
			break;
			
		default:
			return FALSE;
			
	}
	
	return TRUE;
}
Example #23
0
static LRESULT CALLBACK Scropt3DlgProc(HWND hWnd, UINT msg,
													WPARAM wp, LPARAM lp) {

	TCHAR	work[32];
	UINT8	value[6];
	UINT8	b;
	UINT	update;

	switch(msg) {
		case WM_INITDIALOG:
			SendDlgItemMessage(hWnd, IDC_TRAMWAIT, TBM_SETRANGE, TRUE,
											MAKELONG(0, 32));
			SendDlgItemMessage(hWnd, IDC_TRAMWAIT, TBM_SETPOS, TRUE,
											np2cfg.wait[0]);
			wsprintf(work, str_u, np2cfg.wait[0]);
			SetDlgItemText(hWnd, IDC_TRAMSTR, work);
			SendDlgItemMessage(hWnd, IDC_VRAMWAIT, TBM_SETRANGE, TRUE,
											MAKELONG(0, 32));
			SendDlgItemMessage(hWnd, IDC_VRAMWAIT, TBM_SETPOS, TRUE,
											np2cfg.wait[2]);
			wsprintf(work, str_u, np2cfg.wait[2]);
			SetDlgItemText(hWnd, IDC_VRAMSTR, work);
			SendDlgItemMessage(hWnd, IDC_GRCGWAIT, TBM_SETRANGE, TRUE,
											MAKELONG(0, 32));
			SendDlgItemMessage(hWnd, IDC_GRCGWAIT, TBM_SETPOS, TRUE,
											np2cfg.wait[4]);
			wsprintf(work, str_u, np2cfg.wait[4]);
			SetDlgItemText(hWnd, IDC_GRCGSTR, work);

			SendDlgItemMessage(hWnd, IDC_REALPAL, TBM_SETRANGE, TRUE,
											MAKELONG(0, 64));
			SendDlgItemMessage(hWnd, IDC_REALPAL, TBM_SETPOS, TRUE,
											np2cfg.realpal);
			wsprintf(work, str_d, (int)np2cfg.realpal - 32);
			SetDlgItemText(hWnd, IDC_REALPALSTR, work);

			return(TRUE);

		case WM_HSCROLL:
			switch(GetDlgCtrlID((HWND)lp)) {
				case IDC_TRAMWAIT:
					b = (UINT8)SendDlgItemMessage(hWnd, IDC_TRAMWAIT,
													TBM_GETPOS, 0, 0);
					wsprintf(work, str_u, b);
					SetDlgItemText(hWnd, IDC_TRAMSTR, work);
					break;
				case IDC_VRAMWAIT:
					b = (UINT8)SendDlgItemMessage(hWnd, IDC_VRAMWAIT,
													TBM_GETPOS, 0, 0);
					wsprintf(work, str_u, b);
					SetDlgItemText(hWnd, IDC_VRAMSTR, work);
					break;
				case IDC_GRCGWAIT:
					b = (UINT8)SendDlgItemMessage(hWnd, IDC_GRCGWAIT,
													TBM_GETPOS, 0, 0);
					wsprintf(work, str_u, b);
					SetDlgItemText(hWnd, IDC_GRCGSTR, work);
					break;
				case IDC_REALPAL:
					b = (UINT8)SendDlgItemMessage(hWnd, IDC_REALPAL,
													TBM_GETPOS, 0, 0);
					wsprintf(work, str_d, (int)b - 32);
					SetDlgItemText(hWnd, IDC_REALPALSTR, work);
			}
			break;

		case WM_NOTIFY:
			if ((((NMHDR *)lp)->code) == (UINT)PSN_APPLY) {
				update = 0;
				ZeroMemory(value, sizeof(value));
				value[0] = (BYTE)SendDlgItemMessage(hWnd, IDC_TRAMWAIT,
													TBM_GETPOS, 0, 0);
				if (value[0]) {
					value[1] = 1;
				}
				value[2] = (BYTE)SendDlgItemMessage(hWnd, IDC_VRAMWAIT,
													TBM_GETPOS, 0, 0);
				if (value[2]) {
					value[3] = 1;
				}
				value[4] = (BYTE)SendDlgItemMessage(hWnd, IDC_GRCGWAIT,
													TBM_GETPOS, 0, 0);
				if (value[4]) {
					value[5] = 1;
				}
				for (b=0; b<6; b++) {
					if (np2cfg.wait[b] != value[b]) {
						np2cfg.wait[b] = value[b];
						update |= SYS_UPDATECFG;
					}
				}
				b = (BYTE)SendDlgItemMessage(hWnd, IDC_REALPAL,
														TBM_GETPOS, 0, 0);
				if (np2cfg.realpal != b) {
					np2cfg.realpal = b;
					update |= SYS_UPDATECFG;
				}
				sysmng_update(update);
				return(TRUE);
			}
			break;
	}
	return(FALSE);
}
Example #24
0
void LogMessage(HWND hwnd,const char *str) {
    SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_SETSEL, g_sdata.logLength, g_sdata.logLength);
    g_sdata.logLength += lstrlen(str);
    SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_REPLACESEL, 0, (WPARAM)str);
    SendDlgItemMessage(hwnd, IDC_LOGWIN, EM_SCROLLCARET, 0, 0);
}
Example #25
0
// Mesage handler for chaninfo box
LRESULT CALLBACK ChanInfoProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
    case WM_INITDIALOG:
    {
        char str[1024];
        //strcpy(str,chanInfo.track.artist.cstr());
        strcpy(str,chanInfo.track.artist); //JP-Patch
        strcat(str," - ");
        //strcat(str,chanInfo.track.title.cstr());
        strcat(str,chanInfo.track.title);
        String name,track,comment,desc,genre; //JP-Patch
        name = chanInfo.name; //JP-Patch
        track = str; //JP-Patch
        comment = chanInfo.comment; //JP-Patch
        desc = chanInfo.desc; //JP-Patc
        genre = chanInfo.genre; //JP-Patch
        name.convertTo(String::T_SJIS); //JP-Patc
        track.convertTo(String::T_SJIS); //JP-Patch
        comment.convertTo(String::T_SJIS); //JP-Patch
        desc.convertTo(String::T_SJIS); //JP-Patch
        genre.convertTo(String::T_SJIS); //JP-Patch

        //SendDlgItemMessage(hDlg,IDC_EDIT_NAME,WM_SETTEXT,0,(LONG)chanInfo.name.cstr());
        SendDlgItemMessage(hDlg,IDC_EDIT_NAME,WM_SETTEXT,0,(LONG)name.cstr()); //JP-Patch
        //SendDlgItemMessage(hDlg,IDC_EDIT_PLAYING,WM_SETTEXT,0,(LONG)str);
        SendDlgItemMessage(hDlg,IDC_EDIT_PLAYING,WM_SETTEXT,0,(LONG)track.cstr()); //JP-Patch
        //SendDlgItemMessage(hDlg,IDC_EDIT_MESSAGE,WM_SETTEXT,0,(LONG)chanInfo.comment.cstr());
        SendDlgItemMessage(hDlg,IDC_EDIT_MESSAGE,WM_SETTEXT,0,(LONG)comment.cstr()); //JP-Patch
        //SendDlgItemMessage(hDlg,IDC_EDIT_DESC,WM_SETTEXT,0,(LONG)chanInfo.desc.cstr());
        SendDlgItemMessage(hDlg,IDC_EDIT_DESC,WM_SETTEXT,0,(LONG)desc.cstr()); //JP-Patch
        //SendDlgItemMessage(hDlg,IDC_EDIT_GENRE,WM_SETTEXT,0,(LONG)chanInfo.genre.cstr());
        SendDlgItemMessage(hDlg,IDC_EDIT_GENRE,WM_SETTEXT,0,(LONG)genre.cstr()); //JP-Patch

        sprintf(str,"%d kb/s %s",chanInfo.bitrate,ChanInfo::getTypeStr(chanInfo.contentType));
        SendDlgItemMessage(hDlg,IDC_FORMAT,WM_SETTEXT,0,(LONG)str);


        if (!chanInfo.url.isValidURL())
            EnableWindow(GetDlgItem(hDlg,IDC_CONTACT),false);

        Channel *ch = chanMgr->findChannelByID(chanInfo.id);
        if (ch)
        {
            SendDlgItemMessage(hDlg,IDC_EDIT_STATUS,WM_SETTEXT,0,(LONG)ch->getStatusStr());
            SendDlgItemMessage(hDlg, IDC_KEEP,BM_SETCHECK, ch->stayConnected, 0);
        } else
        {
            SendDlgItemMessage(hDlg,IDC_EDIT_STATUS,WM_SETTEXT,0,(LONG)"OK");
            EnableWindow(GetDlgItem(hDlg,IDC_KEEP),false);
        }



        POINT point;
        RECT rect,drect;
        HWND hDsk = GetDesktopWindow();
        GetWindowRect(hDsk,&drect);
        GetWindowRect(hDlg,&rect);
        GetCursorPos(&point);

        POINT pos,size;
        size.x = rect.right-rect.left;
        size.y = rect.bottom-rect.top;

        if (point.x-drect.left < size.x)
            pos.x = point.x;
        else
            pos.x = point.x-size.x;

        if (point.y-drect.top < size.y)
            pos.y = point.y;
        else
            pos.y = point.y-size.y;

        SetWindowPos(hDlg,HWND_TOPMOST,pos.x,pos.y,size.x,size.y,0);
        chWnd = hDlg;
    }
    return TRUE;

    case WM_COMMAND:
    {
        char str[1024],idstr[64];
        chanInfo.id.toStr(idstr);

        switch (LOWORD(wParam))
        {
        case IDC_CONTACT:
        {
            sys->getURL(chanInfo.url);
            return TRUE;
        }
        case IDC_DETAILS:
        {
            sprintf(str,"admin?page=chaninfo&id=%s&relay=%d",idstr,chanInfoIsRelayed);
            sys->callLocalURL(str,servMgr->serverHost.port);
            return TRUE;
        }
        case IDC_KEEP:
        {
            Channel *ch = chanMgr->findChannelByID(chanInfo.id);
            if (ch)
                ch->stayConnected = SendDlgItemMessage(hDlg, IDC_KEEP,BM_GETCHECK, 0, 0) == BST_CHECKED;;
            return TRUE;
        }


        case IDC_PLAY:
        {
            chanMgr->findAndPlayChannel(chanInfo,false);
            return TRUE;
        }

        }
    }
    break;

    case WM_CLOSE:
        if (winDistinctionNT)
            EndDialog(hDlg, 0);
        else
            DestroyWindow(hDlg); //JP-Patch
        break;

    case WM_ACTIVATE:
        if (LOWORD(wParam) == WA_INACTIVE)
            if (winDistinctionNT)
                EndDialog(hDlg, 0);
            else
                DestroyWindow(hDlg); //JP-Patch
        break;
    case WM_DESTROY:
        chWnd = NULL;
        break;


    }
    return FALSE;
}
Example #26
0
INT_PTR CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	static DWORD dwOldIcon = 0;
	HICON hIcon = 0;

	switch(uMsg){
	case WM_INITDIALOG:
		g_hDlgPass = hDlg;
		hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_DLGPASSWD));
		dwOldIcon = SetClassLongPtr(hDlg, GCLP_HICON, (LONG)hIcon); // set alt+tab icon
		SendDlgItemMessage(hDlg,IDC_EDIT1,EM_LIMITTEXT,MAXPASSLEN,0);

		if (IsAeroMode())
		{
			SetWindowLongPtr(hDlg, GWL_STYLE, GetWindowLongPtr(hDlg, GWL_STYLE) | WS_DLGFRAME | WS_SYSMENU);
			SetWindowLongPtr(hDlg, GWL_EXSTYLE, GetWindowLongPtr(hDlg, GWL_EXSTYLE) | WS_EX_TOOLWINDOW);
			RECT rect;
			GetClientRect(hDlg, &rect);
			SetWindowPos(hDlg, 0, 0, 0, rect.right, rect.bottom + GetSystemMetrics(SM_CYCAPTION), SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER);
		}
		SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)hIcon);
		SetDlgItemText(hDlg, IDC_HEADERBAR, TranslateT("Miranda NG is locked.\nEnter password to unlock it."));

		TranslateDialogDefault(hDlg);
		oldLangID = 0;
		SetTimer(hDlg,1,200,NULL);

		oldLayout = GetKeyboardLayout(0);
		if (MAKELCID((WORD)oldLayout & 0xffffffff,  SORT_DEFAULT) != (LCID)0x00000409)
			ActivateKeyboardLayout((HKL)0x00000409, 0);
		LanguageChanged(hDlg);
		return TRUE;

	case WM_CTLCOLORSTATIC:
		if (GetWindowLongPtr((HWND)lParam, GWLP_ID) != IDC_LANG)
			break;

		SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
		SetBkMode((HDC)wParam, TRANSPARENT);
		return (INT_PTR)GetSysColorBrush(COLOR_HIGHLIGHT);

	case WM_COMMAND:
		{
			UINT uid = LOWORD(wParam);
			if (uid == IDOK){
				char password[MAXPASSLEN + 1] = {0};
				int passlen = GetDlgItemTextA(hDlg,IDC_EDIT1,password,MAXPASSLEN+1);

				if (passlen == 0)
				{
					SetDlgItemText(hDlg, IDC_HEADERBAR, TranslateT("Miranda NG is locked.\nEnter password to unlock it."));
					SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_NCPAINT, 0, 0);
					break;
				}
				else if (lstrcmpA(password, g_password))
				{
					SetDlgItemText(hDlg, IDC_HEADERBAR, TranslateT("Password is not correct!\nPlease, enter correct password."));
					SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_NCPAINT, 0, 0);
					SetDlgItemText(hDlg, IDC_EDIT1, _T(""));
					break;
				}
				else EndDialog(hDlg, IDOK);
			}
			else if (uid == IDCANCEL)
				EndDialog(hDlg, IDCANCEL);
		}

	case WM_TIMER:
		LanguageChanged(hDlg);
		break;

	case WM_DESTROY:
		KillTimer(hDlg, 1);
		if (GetKeyboardLayout(0) != oldLayout)
			ActivateKeyboardLayout(oldLayout, 0);
		SetClassLongPtr(hDlg, GCLP_HICON, (long)dwOldIcon);
		DestroyIcon(hIcon);
		break;
	}
	return FALSE;
}
LRESULT CQuickSetupDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled){
	TRC(IDC_FTPSETTINGSBUTTON, "Настройки FTP");
	TRC(IDOK, "Продолжить");
	TRC(IDCANCEL, "Отмена");
	TRC(IDC_LOGINLABEL, "Логин:");
	TRC(IDC_PASSWORDLABEL, "Пароль:");
	TRC(IDC_SERVERLABEL, "На какой сервер будем загружать картинки?");
	TRC(IDC_AUTOSTARTUPCHECKBOX, "Запуск программы при старте Windows");
	TRC(IDC_CAPTUREPRINTSCREENCHECKBOX, "Перехватывать нажатия PrintScreen и Alt+PrintScreen");
	TRC(IDC_EXPLORERINTEGRATION, "Добавить пункт в контекстное меню проводника Windows");
	SetWindowText( APPNAME );
	CString titleText;
	titleText.Format(TR("%s - быстрая настройка"), APPNAME );
	SetDlgItemText(IDC_TITLE, titleText );

	CenterWindow();
	hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), 
		IMAGE_ICON, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR);
	SetIcon(hIcon, TRUE);
	hIconSmall = GuiTools::LoadSmallIcon(IDR_MAINFRAME);
	SetIcon(hIconSmall, FALSE);
	serverComboBox_.Attach( GetDlgItem( IDC_SERVERCOMBOBOX ) );

	if ( !Settings.IsPortable ) {
		SendDlgItemMessage( IDC_AUTOSTARTUPCHECKBOX, BM_SETCHECK, BST_CHECKED, 0);
		SendDlgItemMessage( IDC_CAPTUREPRINTSCREENCHECKBOX, BM_SETCHECK, BST_CHECKED, 0);
		SendDlgItemMessage( IDC_EXPLORERINTEGRATION, BM_SETCHECK, BST_CHECKED, 0);
	}
	LogoImage.SubclassWindow(GetDlgItem( IDC_STATICLOGO ) );
	LogoImage.SetWindowPos(0, 0,0, 48, 48, SWP_NOMOVE );
	LogoImage.LoadImage(0, 0, Settings.UseNewIcon ? IDR_ICONMAINNEW : IDR_PNG1, false, GetSysColor(COLOR_BTNFACE));

	HFONT font = GetFont();
	LOGFONT alf;

	bool ok = ::GetObject(font, sizeof(LOGFONT), &alf) == sizeof(LOGFONT);

	if(ok)
	{
		alf.lfWeight = FW_BOLD;

		NewFont=CreateFontIndirect(&alf);

		HDC dc = ::GetDC(0);
		alf.lfHeight  =  - MulDiv(11, GetDeviceCaps(dc, LOGPIXELSY), 72);
		ReleaseDC(dc);
		NewFont = CreateFontIndirect(&alf);
		SendDlgItemMessage(IDC_TITLE,WM_SETFONT,(WPARAM)(HFONT)NewFont,MAKELPARAM(false, 0));
	}
	
	comboBoxImageList_.Create(16,16,ILC_COLOR32 | ILC_MASK,0,6);

	//serverComboBox_.AddItem( _T("<") + CString(TR("Случайный сервер")) + _T(">"), -1, -1, 0, static_cast<LPARAM>( -1 ) );

	HICON hImageIcon = NULL, hFileIcon = NULL;
	int selectedIndex = 0;

	//CUploadEngineData *uploadEngine = _EngineList->byIndex( Settings.getServerID() );
	std::string selectedServerName = "directupload.net" ;
	for( int i = 0; i < _EngineList->count(); i++) {	
		CUploadEngineData * ue = _EngineList->byIndex( i ); 
		if ( ue->Type !=  CUploadEngineData::TypeImageServer && ue->Type !=  CUploadEngineData::TypeFileServer ) {
			continue;
		}
		HICON hImageIcon = _EngineList->getIconForServer(ue->Name);
		int nImageIndex = -1;
		if ( hImageIcon) {
			nImageIndex = comboBoxImageList_.AddIcon( hImageIcon);
		}
		char *serverName = new char[ue->Name.length() + 1];
		lstrcpyA( serverName, ue->Name.c_str() );
		int itemIndex = serverComboBox_.AddItem( Utf8ToWCstring( ue->Name ), nImageIndex, nImageIndex, 1, reinterpret_cast<LPARAM>( serverName ) );
		if ( ue->Name == selectedServerName ){
			selectedIndex = itemIndex;
		}
	}
	serverComboBox_.SetImageList( comboBoxImageList_ );
	serverComboBox_.SetCurSel( selectedIndex );

	doAuthCheckboxChanged();
	
	serverChanged();

	return 1;  
}
Example #28
0
static int CALLBACK LogProc(HWND hwnd, UINT msg,
			    WPARAM wParam, LPARAM lParam)
{
    int i;

    switch (msg) {
      case WM_INITDIALOG:
	{
	    char *str = dupprintf("%s Event Log", appname);
	    SetWindowText(hwnd, str);
	    sfree(str);
	}
	{
	    static int tabs[4] = { 78, 108 };
	    SendDlgItemMessage(hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
			       (LPARAM) tabs);
	}
	for (i = 0; i < nevents; i++)
	    SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
			       0, (LPARAM) events[i]);
	return 1;
      case WM_COMMAND:
	switch (LOWORD(wParam)) {
	  case IDOK:
	  case IDCANCEL:
	    logbox = NULL;
	    SetActiveWindow(GetParent(hwnd));
	    DestroyWindow(hwnd);
	    return 0;
	  case IDN_COPY:
	    if (HIWORD(wParam) == BN_CLICKED ||
		HIWORD(wParam) == BN_DOUBLECLICKED) {
		int selcount;
		int *selitems;
		selcount = SendDlgItemMessage(hwnd, IDN_LIST,
					      LB_GETSELCOUNT, 0, 0);
		if (selcount == 0) {   /* don't even try to copy zero items */
		    MessageBeep(0);
		    break;
		}

		selitems = snewn(selcount, int);
		if (selitems) {
		    int count = SendDlgItemMessage(hwnd, IDN_LIST,
						   LB_GETSELITEMS,
						   selcount,
						   (LPARAM) selitems);
		    int i;
		    int size;
		    char *clipdata;
		    static unsigned char sel_nl[] = SEL_NL;

		    if (count == 0) {  /* can't copy zero stuff */
			MessageBeep(0);
			break;
		    }

		    size = 0;
		    for (i = 0; i < count; i++)
			size +=
			    strlen(events[selitems[i]]) + sizeof(sel_nl);

		    clipdata = snewn(size, char);
		    if (clipdata) {
			char *p = clipdata;
			for (i = 0; i < count; i++) {
			    char *q = events[selitems[i]];
			    int qlen = strlen(q);
			    memcpy(p, q, qlen);
			    p += qlen;
			    memcpy(p, sel_nl, sizeof(sel_nl));
			    p += sizeof(sel_nl);
			}
			write_aclip(NULL, clipdata, size, TRUE);
			sfree(clipdata);
		    }
		    sfree(selitems);

		    for (i = 0; i < nevents; i++)
			SendDlgItemMessage(hwnd, IDN_LIST, LB_SETSEL,
					   FALSE, i);
		}
	    }
	    return 0;
	}
	return 0;
      case WM_CLOSE:
	logbox = NULL;
	SetActiveWindow(GetParent(hwnd));
	DestroyWindow(hwnd);
	return 0;
    }
Example #29
0
LRESULT CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) //Gets info for a RAM Watch, and then inserts it into the Watch List
{
	RECT r;
	RECT r2;
	int dx1, dy1, dx2, dy2;
	static int index;
	static char s,t = s = 0;

	switch(uMsg)
	{
		case WM_INITDIALOG:
			GetWindowRect(MainWindow->getHWnd(), &r);
			dx1 = (r.right - r.left) / 2;
			dy1 = (r.bottom - r.top) / 2;

			GetWindowRect(hDlg, &r2);
			dx2 = (r2.right - r2.left) / 2;
			dy2 = (r2.bottom - r2.top) / 2;

			SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
			index = (int)lParam;
			sprintf(Str_Tmp,"%08X",rswatches[index].Address);
			SetDlgItemText(hDlg,IDC_EDIT_COMPAREADDRESS,Str_Tmp);
			if (rswatches[index].comment != NULL)
				SetDlgItemText(hDlg,IDC_PROMPT_EDIT,rswatches[index].comment);
			s = rswatches[index].Size;
			t = rswatches[index].Type;
			switch (s)
			{
				case 'b':
					SendDlgItemMessage(hDlg, IDC_1_BYTE, BM_SETCHECK, BST_CHECKED, 0);
					break;
				case 'w':
					SendDlgItemMessage(hDlg, IDC_2_BYTES, BM_SETCHECK, BST_CHECKED, 0);
					break;
				case 'd':
					SendDlgItemMessage(hDlg, IDC_4_BYTES, BM_SETCHECK, BST_CHECKED, 0);
					break;
				default:
					s = 0;
					break;
			}
			switch (t)
			{
				case 's':
					SendDlgItemMessage(hDlg, IDC_SIGNED, BM_SETCHECK, BST_CHECKED, 0);
					break;
				case 'u':
					SendDlgItemMessage(hDlg, IDC_UNSIGNED, BM_SETCHECK, BST_CHECKED, 0);
					break;
				case 'h':
					SendDlgItemMessage(hDlg, IDC_HEX, BM_SETCHECK, BST_CHECKED, 0);
					break;
				case 'f':
					SendDlgItemMessage(hDlg, IDC_2012, BM_SETCHECK, BST_CHECKED, 0);
					break;
				default:
					t = 0;
					break;
			}

			return true;
			break;
		
		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case IDC_SIGNED:
					t='s';
					return true;
				case IDC_UNSIGNED:
					t='u';
					return true;
				case IDC_HEX:
					t='h';
					return true;
				case IDC_2012:
					t='f';
					return true;
				case IDC_1_BYTE:
					s = 'b';
					return true;
				case IDC_2_BYTES:
					s = 'w';
					return true;
				case IDC_4_BYTES:
					s = 'd';
					return true;
				case IDOK:
				{
					if (s && t)
					{
						AddressWatcher Temp;
						Temp.Size = s;
						Temp.Type = t;
						Temp.WrongEndian = false; //replace this when I get little endian working properly
						GetDlgItemText(hDlg,IDC_EDIT_COMPAREADDRESS,Str_Tmp,1024);
						char *addrstr = Str_Tmp;
						if (strlen(Str_Tmp) > 8) addrstr = &(Str_Tmp[strlen(Str_Tmp) - 9]);
						for(int i = 0; addrstr[i]; i++) {if(toupper(addrstr[i]) == 'O') addrstr[i] = '0';}
						sscanf(addrstr,"%08X",&(Temp.Address));

						if((Temp.Address & ~0xFFFFFF) == ~0xFFFFFF)
							Temp.Address &= 0xFFFFFF;

						if(IsHardwareRAMAddressValid(Temp.Address))
						{
							GetDlgItemText(hDlg,IDC_PROMPT_EDIT,Str_Tmp,80);
							if (index < WatchCount) RemoveWatch(index);
							InsertWatch(Temp,Str_Tmp,index);
							if(RamWatchHWnd)
							{
								ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount);
							}
							EndDialog(hDlg, true);
						}
						else
						{
							MessageBox(hDlg,"Invalid Address","ERROR",MB_OK);
						}
					}
					else
					{
						strcpy(Str_Tmp,"Error:");
						if (!s)
							strcat(Str_Tmp," Size must be specified.");
						if (!t)
							strcat(Str_Tmp," Type must be specified.");
						MessageBox(hDlg,Str_Tmp,"ERROR",MB_OK);
					}
					RWfileChanged=true;
					return true;
					break;
				}
				case IDCANCEL:
					EndDialog(hDlg, false);
					return false;
					break;
			}
			break;

		case WM_CLOSE:
			EndDialog(hDlg, false);
			return false;
			break;
	}

	return false;
}
static void JabberSearchAddUrlToRecentCombo(HWND hwndDlg, TCHAR * szAddr)
{
	int lResult = SendMessage( GetDlgItem(hwndDlg,IDC_SERVER), (UINT) CB_FINDSTRING, 0, (LPARAM)szAddr );
	if ( lResult == -1 )
		SendDlgItemMessage( hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, ( LPARAM )szAddr );
}