Example #1
0
bool CPackets::WriteMessage(UINT Message, WPARAM wParam, LPARAM lParam)
{
	FRAP_MESSAGE	pkt;
	InitHdr(pkt, Message, sizeof(pkt));
	pkt.wParam = INT64TO32(wParam);
	pkt.lParam = INT64TO32(lParam);
	return(Write(pkt, sizeof(pkt)));
}
void CFileBrowserListCtrl::OnOdfinditem(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NMLVFINDITEM* pFindItem = (NMLVFINDITEM*)pNMHDR;
	int	retc = -1;
	int	flags = pFindItem->lvfi.flags;
	if (flags & LVFI_STRING) {
		int	len = INT64TO32(_tcslen(pFindItem->lvfi.psz));
		// according to MSDN, we should test the LVFI_PARTIAL flag and only do
		// a partial match if it's set, but in practice, we're ALWAYS passed a
		// partial string, and LVFI_PARTIAL is NEVER set; strange but it works
		int	count = m_DirList.GetCount();
		int	pos = pFindItem->iStart;
		LPCTSTR	target = pFindItem->lvfi.psz;
		for (int i = 0; i < count; i++) {
			if (pos >= count) {
				if (flags & LVFI_WRAP)
					pos = 0;	// continue search at the beginning
				else
					break;
			}
			const CDirItem& item = m_DirList.GetItem(pos);
			if (!item.GetName().Left(len).CompareNoCase(target)) {
				retc = pos;
				break;
			}
			pos++;
		}
	}
	*pResult = retc;
}
Example #3
0
bool CChordEaseApp::HandleDlgKeyMsg(MSG* pMsg)
{
	static const LPCSTR	EditBoxCtrlKeys = "ACHVX";	// Z reserved for app undo
	CMainFrame	*Main = theApp.GetMain();
	ASSERT(Main != NULL);	// main frame must exist
	switch (pMsg->message) {
	case WM_KEYDOWN:
		{
			int	VKey = INT64TO32(pMsg->wParam);
			bool	bTryMainAccels = FALSE;	// assume failure
			if ((VKey >= VK_F1 && VKey <= VK_F24) || VKey == VK_ESCAPE) {
				bTryMainAccels = TRUE;	// function key or escape
			} else {
				bool	IsAlpha = VKey >= 'A' && VKey <= 'Z';
				CEdit	*pEdit = CFocusEdit::GetEdit();
				if (pEdit != NULL) {	// if an edit control has focus
					if ((IsAlpha									// if (alpha key
					&& strchr(EditBoxCtrlKeys, VKey) == NULL		// and unused by edit
					&& (GetKeyState(VK_CONTROL) & GKS_DOWN))		// and Ctrl is down)
					|| ((VKey == VK_SPACE							// or (space key,
					|| VKey == VK_RETURN || VKey == VK_BACK)		// Enter or Backspace
					&& (GetKeyState(VK_CONTROL) & GKS_DOWN))		// and Ctrl is down)
					|| (VKey == VK_SPACE							// or (space key
					&& (GetKeyState(VK_SHIFT) & GKS_DOWN))			// and Shift is down)
					|| (IsAlpha										// or (alpha key
					&& pEdit->IsKindOf(RUNTIME_CLASS(CNumEdit))		// and numeric edit
					&& (VKey > 'G'									// and (key above G
					|| !pEdit->IsKindOf(RUNTIME_CLASS(CNoteEdit)))	// or not note edit)
					&& (GetKeyState(VK_SHIFT) & GKS_DOWN)))			// and Shift is down)
						bTryMainAccels = TRUE;	// give main accelerators a try
				} else {	// non-edit control has focus
					if (IsAlpha										// if alpha key
					|| VKey == VK_SPACE								// or space key
					|| (GetKeyState(VK_CONTROL) & GKS_DOWN)			// or Ctrl is down
					|| (GetKeyState(VK_SHIFT) & GKS_DOWN))			// or Shift is down
						bTryMainAccels = TRUE;	// give main accelerators a try
				}
			}
			if (bTryMainAccels) {
				HACCEL	hAccel = Main->GetAccelTable();
				if (hAccel != NULL
				&& TranslateAccelerator(Main->m_hWnd, hAccel, pMsg))
					return(TRUE);	// message was translated, stop dispatching
			}
		}
		break;
	case WM_SYSKEYDOWN:
		// if focused window isn't descendant of main frame (e.g. floating bar's controls
		// are descendants of miniframe) main frame must steal focus else main menus fail
		if (!IsChild(Main->m_hWnd, GetFocus())) {	// avoid stealing focus needlessly
			if (GetKeyState(VK_SHIFT) & GKS_DOWN)	// if context menu
				return(FALSE);	// keep dispatching (false alarm)
			Main->SetFocus();	// main frame must have focus to display menus
			Main->SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam);	// enter menu mode
			return(TRUE);	// message was translated, stop dispatching
		}
		break;
	}
	return(FALSE);	// continue dispatching
}
Example #4
0
BOOL CMainFrame::VerifyDockState(const CDockState& state, CFrameWnd *Frm)
{
	// thanks to Cristi Posea at codeproject.com
	for (int i = 0; i < state.m_arrBarInfo.GetSize(); i++) {
		CControlBarInfo* pInfo = (CControlBarInfo*)state.m_arrBarInfo[i];
		ASSERT(pInfo != NULL);
		int nDockedCount = INT64TO32(pInfo->m_arrBarID.GetSize());
		if (nDockedCount > 0) {
			// dockbar
			for (int j = 0; j < nDockedCount; j++)
			{
				UINT	nID = (UINT) pInfo->m_arrBarID[j];
				if (nID == 0)
					continue; // row separator
				if (nID > 0xFFFF)
					nID &= 0xFFFF; // placeholder - get the ID
				if (Frm->GetControlBar(nID) == NULL)
					return FALSE;
			}
		}
		if (!pInfo->m_bFloating) // floating dockbars can be created later
			if (Frm->GetControlBar(pInfo->m_nBarID) == NULL)
				return FALSE; // invalid bar ID
	}
    return TRUE;
}
Example #5
0
bool CSongState::InsertSection(CSong::CSection& Section, CString Name)
{
	CIntRange	BeatRange(Section.m_Start, Section.End());
	if (BeatRange.Start < 0 || BeatRange.End >= CSong::CountBeats(m_Chord))
		return(FALSE);	// section not within song
	int	iSection = INT64TO32(m_Section.Add(Section));
	m_SectionName.Add(Name);
	AssignToSection(BeatRange, iSection);
	return(TRUE);
}
Example #6
0
bool	CReportCtrl::RemoveRow(int SortKey)
{
	int	row = FindRow(SortKey);
	if (row < 0)
		return(FALSE);
	DeleteItem(row);
	int	items = GetItemCount();
	// items with sort keys >= the deleted item's need updating
	for (int i = 0; i < items; i++) { // for each item
		int	sk = INT64TO32(GetItemData(i));	// get item's sort key
		if (sk >= SortKey)	// if sort key is invalid
			SetItemData(i, sk - 1);	// update it
	}
	return(TRUE);
}
Example #7
0
void CLevelsCtrl::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	CRect	rc;
	GetClientRect(rc);
	dc.FillSolidRect(rc, GetSysColor(COLOR_3DFACE));
	int	samps = INT64TO32(m_Sample.GetSize());
	if (samps > 0) {
		dc.IntersectClipRect(rc);	// exclude border from clipping region
		int	w = rc.Width();
		int	h = rc.Height();
		if (m_ShowAxis) {
			static const int	MIN_SPACING = 32;
			int	step = CalcAxisStep(samps, w, MIN_SPACING);
			dc.SetBkMode(TRANSPARENT);
			COLORREF	color = GetSysColor(COLOR_3DDKSHADOW);
			dc.SetTextColor(color);
			dc.SelectObject(GetStockObject(DEFAULT_GUI_FONT));
			for (int i = step; i < samps; i += step) {
				int	x = round(i / double(samps) * w);
				dc.FillSolidRect(x, 0, 1, h, color);
				CString	s;
				s.Format(_T("%d"), i);
				dc.TextOut(x + 2, 0, s);
			}
		}
		double	BarWidth = double(w) / samps;
		double	MaxSamp = m_MaxSamp;
		if (m_ScalingType == ST_LOG10)
			MaxSamp = log10(MaxSamp + 1);
		for (int i = 0; i < samps; i++) {
			if (m_Sample[i]) {
				double	samp = m_Sample[i];
				if (m_ScalingType == ST_LOG10)
					samp = log10(samp + 1);	// offset so single count shows
				int	y = round(samp / MaxSamp * h);
				double	x = i * BarWidth;
				CRect	r(round(x), h - y, round(x + BarWidth), h);
				if (r.right == r.left)
					r.right = r.left + 1;	// at least one pixel wide
				r.left = max(r.left, 0);	// clip bar sides to window
				r.right = min(r.right, w);
				dc.FillSolidRect(r, RGB(0, 0, 0));
			}
		}
	}
}
Example #8
0
void CSaveAsDlg::BuildExtList()
{
	LPCTSTR	p = m_ofn.lpstrFilter;
	if (p != NULL) {
		bool	pattern = FALSE;
		while (*p) {	// for each filter description/pattern pair
			if (pattern)	// if filter pattern
				m_Ext.Add(p + 1);	// add to list; remove leading asterik
			p += _tcslen(p) + 1;	// advance to next string
			pattern ^= 1;	// ignore filter descriptions
		}
		if (m_Ext.GetSize()) {	// if at least one extension
			int	idx = m_ofn.nFilterIndex - 1;	// get extension index
			int	exts = INT64TO32(m_Ext.GetSize());
			idx = CLAMP(idx, 0, exts - 1);
			m_ofn.lpstrDefExt = m_Ext[idx];	// set initial default extension
		}
	}
}
Example #9
0
int CALLBACK CReportCtrl::TextSort(LPARAM p1, LPARAM p2, LPARAM This)
{
	return(((CReportCtrl *)This)->TextSort(INT64TO32(p1), INT64TO32(p2)));
}