Example #1
0
void CComboListCtrl::OnLButtonDown(UINT iFlags, CPoint obPoint) 
{
	// TODO: Add your message handler code here and/or call default

	int iColumnIndex = -1;
	int iRowIndex = -1;

	// Get the current column and row
	if (!HitTestEx(obPoint, &iRowIndex, &iColumnIndex))
	{
		return;
	}

	CListCtrl::OnLButtonDown(iFlags, obPoint);
	
	// If column is not read only then
	// If the SHIFT or CTRL key is down call the base class
	// Check the high bit of GetKeyState to determine whether SHIFT or CTRL key is down
	if ((GetKeyState(VK_SHIFT) & 0x80) || (GetKeyState(VK_CONTROL) & 0x80))
	{
		return;
	}

	// Get the current selection before creating the in place combo box
	CString strCurSelection = GetItemText(iRowIndex, iColumnIndex);
	
	if (-1 != iRowIndex)
	{
		UINT flag = LVIS_FOCUSED;
		
		if ((GetItemState(iRowIndex, flag ) & flag) == flag)
		{
			// Add check for LVS_EDITLABELS
			if (GetWindowLong(m_hWnd, GWL_STYLE) & LVS_EDITLABELS)
			{
				// If combo box is supported
				// Create and show the in place combo box
				if (IsCombo(iColumnIndex))
				{
					CStringList obComboItemsList;
										
					GetParent()->SendMessage(WM_SET_ITEMS, (WPARAM)iColumnIndex, (LPARAM)&obComboItemsList);  
					
					CInPlaceCombo* pInPlaceComboBox = ShowInPlaceList(iRowIndex, iColumnIndex, obComboItemsList, strCurSelection);
					ASSERT(pInPlaceComboBox); 
					
					// Set the selection to previous selection
					pInPlaceComboBox->SelectString(-1, strCurSelection);
				}
				// If combo box is not read only
				// Create and show the in place edit control
				else if (!IsReadOnly(iColumnIndex))
				{
					CInPlaceEditCombo* pInPlaceEdit = ShowInPlaceEdit(iRowIndex, iColumnIndex, strCurSelection);
				}
			}
		}
	}  
}
Example #2
0
void CClickList::ShowEditControl(int Row, int Col, CDataType DataType)
{
	switch (DataType) {
		case DT_INTEGER:        // fall through
		case DT_STRING:
			ShowInPlaceString(Row, Col);
			break;

		case DT_TIME:
			{
				CRect rc;
				GetWindowRect(&rc);

				WINDOWPOS wp = {
					m_hWnd,			// hwnd
					NULL,			// hwndInsertAfter
					0,				// x
					0,				// y
					rc.Width(),		// cx
					rc.Height(),	// cy
					SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER
									// flags
				};
				SendMessage(WM_WINDOWPOSCHANGED, 0, LPARAM(&wp));
			}
			ShowInPlaceTime(Row, Col);
			break;

		case DT_MEMORY:
			ShowInPlaceMemory(Row, Col);
			break;

		case DT_LIST:
			ShowInPlaceList(Row, Col);
			break;

		case DT_BOOLEAN:
		case DT_CSTRING:
		case DT_HOST:
			// Stefan Mihaila: TODO.
			// Temporary, use 'ShowInPlaceString()'
			ShowInPlaceString(Row, Col);
			break;

		default:
			ASSERT(false);
			//TypeStr.Format("Please define it (valtype = %d)", it->valtype);
	}
}