コード例 #1
0
ファイル: aup3dlg.cpp プロジェクト: 2asoft/xray
// Handle WM_COMMAND messages separately
void AudioP3Dlg::WMCommand(int id, int notify, HWND hCtrl)
{
	int mmerr;
	AudioP3Control* af = (AudioP3Control *)GetWindowLongPtr(hWnd, DWLP_USER);

	switch (id) {
		case IDC_AUDAMP_ABSOLUTE:
			cont->absolute = IsDlgButtonChecked(hWnd,id);
			Change();
			break;
		case IDC_QUICKDRAW:
			cont->quickdraw = IsDlgButtonChecked(hWnd,id);
			Change();
			break;
		case IDC_AUDAMP_RECDEVICE:
			if (notify == CBN_SELCHANGE) {
				int devIdx = SendMessage(GetDlgItem(hWnd, IDC_AUDAMP_RECDEVICE), CB_GETCURSEL, 0, 0);
				cont->rtwave->SetDevice(devIdx);
				Change();
			}
			break;
		case IDC_AUDAMP_RECENABLE:
			cont->enableRuntime = IsDlgButtonChecked(hWnd,id);
			// Startup or terminate runtime recording
			if (cont->enableRuntime) {
				if ((mmerr = cont->rtwave->StartRecording()) == 0) {
					EnableWindow(GetDlgItem(hWnd, IDC_AUDAMP_RECDEVICE), 0);
				}
				else {
					CheckDlgButton(hWnd, id, 0);
					MessageBox(hWnd, GetString(IDS_CJ_DEVICE_BUSY), GetString(IDS_CJ_PROGNAME), MB_OK);
				}
			} 
			else {
				cont->rtwave->StopRecording();
				EnableWindow(GetDlgItem(hWnd, IDC_AUDAMP_RECDEVICE), 1);
			}

			// Here we are just telling trackview to repaint its hierarchy.
			// We haven't actually changed anything, but the switch from file to record
			// will cause a change in TrackView line height - and we need to tell that
			// to TrackView
			cont->NotifyDependents(FOREVER,PART_ALL,REFMSG_SUBANIM_STRUCTURE_CHANGED);

			Change();
			break;
		case IDC_BTN_BROWSE: {
				// Changed to open in the directory of the file. //CJ
				TSTR dir = cont->szFilename;
				if (dir.Length() == 0) {
					// Use sound dir if no file.
					dir = TSTR(ip->GetDir(APP_SOUND_DIR));
				}
				else {
					int lc = dir.last((int)'\\');
					if (lc == -1) {
						lc = dir.last((int)'/');
					}
					if (lc != -1) {
						dir[lc] = '\0';
					}
				}
				// Brings up file dialog box with sound "preview".
				GetSoundFileName(hCtrl, cont->szFilename, dir);

				if (!cont->szFilename.isNull()) {
					cont->wave->InitOpen(cont->szFilename);
					SendMessage(GetDlgItem(hWnd, IDC_AUDAMP_FILENAME), WM_SETTEXT, 0, (LPARAM)((char *)cont->szFilename));
					EnableChannelUI(cont->wave->GetNumChannels() == 2);
				}
				Change();
			}
			break;
		case IDC_BTN_REMOVESOUND:
			cont->wave->FreeSample();
			cont->szFilename = "";
			SendMessage(GetDlgItem(hWnd, IDC_AUDAMP_FILENAME), WM_SETTEXT, 0, (LPARAM)"");
			EnableChannelUI(FALSE);
			Change();
			break;
		case IDC_AUDAMP_LEFT:
			cont->channel = 0;
			Change();
			break;
		case IDC_AUDAMP_RIGHT:
			cont->channel = 1;
			Change();
			break;
		case IDC_AUDAMP_MIX:
			cont->channel = 2;
			Change();
			break;
		case IDC_ABOUT:
			ShowAbout(hWnd);
			break;
		case IDC_CLOSE:
			DestroyWindow(hWnd);
			break;
	}
}