CWnd *CMidiTargetDlg::CTargetGridCtrl::CreateEditCtrl(LPCTSTR Text, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
	switch (m_EditCol) {
	case COL_CHAN:
	case COL_EVENT:
		{
			int	DropHeight = 100;
			const CMidiTarget&	targ = m_pParent->GetTarget(m_EditRow);
			CPopupCombo	*pCombo = CPopupCombo::Factory(0, rect, pParentWnd, nID, DropHeight);
			if (pCombo != NULL) {
				switch (m_EditCol) {
				case COL_CHAN:
					CChordEaseApp::InitNumericCombo(*pCombo, 
						CIntRange(1, MIDI_CHANNELS), targ.m_Inst.Chan + 1);
					break;
				case COL_EVENT:
					InitEventTypeCombo(*pCombo, targ.m_Event);
					break;
				default:
					NODEFAULTCASE;
				}
				pCombo->ShowDropDown();
			}
			return pCombo;
		}
	case COL_VALUE:
		return NULL;
	}
	return CGridCtrl::CreateEditCtrl(Text, dwStyle, rect, pParentWnd, nID);
}
BOOL CMidiAssignPropsDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	m_PortSpin.SetRange32(0, INT_MAX);
	if (m_Inst.Port < 0)	// if port is indeterminate
		m_PortEdit.SetWindowText(_T(""));	// override spin control's init
	UpdateDeviceName();
	CChordEaseApp::InitNumericCombo(m_ChanCombo, CIntRange(1, MIDI_CHANNELS), m_Inst.Chan + 1);
	CMidiTargetDlg::InitEventTypeCombo(m_EventCombo, m_Event);
	for (int iCtl = 0; iCtl < MIDI_NOTES; iCtl++)
		m_ControlCombo.AddString(CMidiTarget::GetControllerName(iCtl));
	m_ControlCombo.SetCurSel(m_Control);
	if (m_Items > 1) {	// if multiple items
		CString	s;
		s.Format(IDS_MIDI_ASS_PROPS_ITEM_COUNT, m_Items);
		m_ItemCountStat.SetWindowText(s);
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Exemple #3
0
bool CSongState::ChangeLength(CIntRange& BeatRange, double Scale)
{
	CIntRange	ChordRange, Offset;
	ChordRange = FindChordRange(BeatRange, Offset);
	bool	RoundingError = FALSE;
	int	NewSelDur = 0;
	for (int iChord = ChordRange.Start; iChord <= ChordRange.End; iChord++) {
		CSong::CChord&	ch = m_Chord[iChord];
		double	fDur = ch.m_Duration * Scale;	// scale chord duration
		int	iDur = round(fDur);	// chord durations are stored as integers
		if (fabs(iDur - fDur) > .01)	// if rounding error exceeds +/- 1%
			RoundingError = TRUE;	// set flag
		iDur = max(iDur, 1);	// enforce minimum duration
		ch.m_Duration = iDur;	// update chord duration
		NewSelDur += iDur;	// add duration to selection length
	}
	MakeSections();	// rebuild sections from section map
	// return scaled beat range to caller by overwriting beat range argument
	int	iStartBeat = GetStartBeat(ChordRange.Start);
	BeatRange = CIntRange(iStartBeat, iStartBeat + NewSelDur - 1);
	return(!RoundingError);	// return false if rounding errors occurred
}