void CArrayGrid::OnLButtonDown(UINT nFlags, CPoint point)
{
	CBCGPGridCtrl::OnLButtonDown(nFlags, point);
	CDlgParamEditArray::DataType type = ((CDlgParamEditArray*)GetParent())->m_dataType;
	if (type!=CDlgParamEditArray::TypeBool)
		return;

	if (IsColumnSelected(0))
		return;

	CBCGPGridItem * pItem = GetCurSelItem();
	if (pItem==NULL)
		return;

	CString str;
	ConvertBSTR2CString( str, pItem->GetValue().bstrVal );
	if ( str.CompareNoCase("true") == 0 )
		str = "false";
	else
		str = "true";

	pItem->SetValue( (LPCTSTR)(str) );
	int iRow = pItem->GetGridItemID().m_nRow;
	((CDlgParamEditArray*)GetParent())->m_vArray[iRow] = str;
}
//右键弹出处理
void CComputerListView::OnContextMenu(CWnd*, CPoint point)
{
	m_SelectRows.RemoveAll();

	CMenu menu;

	CBCGPGridRow* pRow = GetGridCtrl()->GetCurSel();

	if (pRow != NULL)//存在选中的子行
	{
		CList<CBCGPGridItem*, CBCGPGridItem*> lstSelected;
		GetGridCtrl()->GetSelectedItems(lstSelected);//多重选择队列

		POSITION pos = lstSelected.GetHeadPosition();//第一个

		while (pos != NULL)
		{
			CBCGPGridItem* pItem = lstSelected.GetNext(pos);//下一个			
			m_SelectRows.Add((UINT)pItem->GetParentRow()->GetData());//保存选中的序号			
		}

		SendMessage(WM_LBUTTONUP);//弹起

		VERIFY(menu.LoadMenu(IDR_COMPUTER_MENU));//载入
		CMenu* pPopup = menu.GetSubMenu(0);//第一个子菜单
		ASSERT(pPopup != NULL);

#ifndef __USING_INTER_RESOURCE
		HMENU hTmp = pPopup->GetSubMenu(6)->GetSafeHmenu();
		pPopup->ModifyMenu((UINT_PTR)hTmp,MF_POPUP,(UINT_PTR)hTmp,LOAD_STRING(IDS_REMOTE_OPERATION));
#endif

		//弹出菜单
		theApp.GetContextMenuManager()->ShowPopupMenu(pPopup->Detach(), point.x, point.y, this, TRUE);
	}
	else
	{
		//扫描鼠标位置,点击在列栏上,才弹出此菜单
		CRect rect;
		m_pWndGridCtrl->GetClientRect(rect);
		rect.bottom = 21; //栏高度大概为21个像素
		ClientToScreen(rect);

		if (rect.PtInRect(point))//点击在栏上
		{
			VERIFY(menu.LoadMenu(IDR_MENU_COLUMN));//载入列菜单

			CMenu* pPopup = menu.GetSubMenu(0);
			ASSERT(pPopup != NULL);

			for (INT i = 0; i < GetGridCtrl()->GetColumnCount(); i++)//列枚举
			{//动态插入与列项有关的菜单
				pPopup->InsertMenu(i, MF_BYPOSITION, IDM_MINCOLUMNCMD + i, GetGridCtrl()->GetColumnName(i));
				pPopup->CheckMenuItem(i, MF_BYPOSITION | (GetGridCtrl()->GetColumnVisible(i) ? MF_CHECKED : MF_UNCHECKED));
			}

			theApp.GetContextMenuManager()->ShowPopupMenu(pPopup->Detach(), point.x, point.y, this, TRUE);
		}
	}
}
BOOL CDlgStudentsSetting::OnInitDialog(void)
{
	CBCGPDialog::OnInitDialog();

	// TODO:  在此添加额外的初始化
	CRect rectGrid;	
	m_ctrlGridLocation.GetWindowRect (&rectGrid);
	ScreenToClient (&rectGrid);
	m_wndListGrid.CreateGrid(rectGrid,this);

	m_wndListGrid.InsertColumn (0, _T(" 姓名 "), 100);			//此处的nWidth为比例,并不是真实尺寸,会随着控件宽度的变化而变化
	m_wndListGrid.InsertColumn (1, _T(" 年龄 "), 100);			//设定的列表宽度为控件宽度width*(100/(100+100+100+150+100+150+100))
	m_wndListGrid.InsertColumn (2, _T(" 籍贯 "), 100);
	m_wndListGrid.InsertColumn (3, _T(" 出生地 "), 150);
	m_wndListGrid.InsertColumn (4, _T(" 政治面貌 "), 100);
	m_wndListGrid.InsertColumn (5, _T(" 婚姻状况 "), 150);
	m_wndListGrid.InsertColumn (6, _T(" 联系电话 "), 100);

	m_ctrlEditGridLocation.GetWindowRect (&rectGrid);
	ScreenToClient (&rectGrid);
	m_wndEditGrid.CreateGrid(rectGrid,this);

	m_wndEditGrid.InsertColumn (0, _T(" 姓名 "), 100);
	m_wndEditGrid.InsertColumn (1, _T(" 年龄 "), 100);
	m_wndEditGrid.InsertColumn (2, _T(" 籍贯 "), 100);
	m_wndEditGrid.InsertColumn (3, _T(" 出生地 "), 150);
	m_wndEditGrid.InsertColumn (4, _T(" 政治面貌 "), 100);
	m_wndEditGrid.InsertColumn (4, _T(" 婚姻状况 "), 150);
	m_wndEditGrid.InsertColumn (4, _T(" 联系电话 "), 100);


	CBCGPGridRow* pRow = m_wndEditGrid.CreateRow (m_wndEditGrid.GetColumnCount ());
	CBCGPGridItem* pItem = new CBCGPGridItem (_T("中共党员"));
	pItem->AddOption (_T("中共党员"), TRUE);
	pItem->AddOption (_T("群众"), TRUE);
	// pItem->AllowEdit(FALSE);

	CImageList Cil1,Cil2; //定义大小图标像列表
	Cil1.Create(32, 32, ILC_COLOR4, 0, 4); //建立32位图像控制
	Cil1.Add(AfxGetApp()->LoadIcon(IDI_ICON1));//增加选中状态图像

	//	Cil2.Create(16,16,TRUE,0,0); //建立16位图像控制

	//	Cil2.Add(AfxGetApp()->LoadIcon(IDI_ICON1));//增加选中状态图像
	m_wndListGrid.SetImageList(&Cil1);
	pRow->GetItem(0)->SetImage(0);


	pRow->ReplaceItem (4, pItem);
	pRow->ReplaceItem (5, new CBCGPGridCheckItem (FALSE));


	m_wndEditGrid.AddRow(pRow);
	m_wndEditGrid.AdjustLayout();

	Load(members);
	return TRUE; 
}
void CToolGridListDlg::OnBnClickedButtonEditSel()
{
    // TODO: 在此添加控件通知处理程序代码
    CBCGPGridRow *pSelRow = m_wndGridTools.GetCurSel();
    if (pSelRow==NULL) return;

    CBCGPGridItem * pItemId = pSelRow->GetItem(0);
    if (pItemId==NULL) return;

    CString strId = pItemId->GetValue();
    if (m_ToolMap.find(strId)== m_ToolMap.end()) return;

    ToolObject & tool = m_ToolMap[strId];
    if (CToolsProUnity::ConfigTool(&tool))
    {
        CToolsProUnity::WriteToolConfigXml(tool);
    }
}
BOOL CDlgStudentsSetting::OnInitDialog(void)
{
	CBCGPDialog::OnInitDialog();

	// TODO:  在此添加额外的初始化
	CRect rectGrid;	
	m_ctrlGridLocation.GetWindowRect (&rectGrid);
	ScreenToClient (&rectGrid);
	m_wndListGrid.CreateGrid(rectGrid,this);

	m_wndListGrid.InsertColumn (0, _T(" 姓名 "), 100);			//此处的nWidth为比例,并不是真实尺寸,会随着控件宽度的变化而变化
	m_wndListGrid.InsertColumn (1, _T(" 年龄 "), 100);			//设定的列表宽度为控件宽度width*(100/(100+100+100+150+100+150+100))
	m_wndListGrid.InsertColumn (2, _T(" 籍贯 "), 100);
	m_wndListGrid.InsertColumn (3, _T(" 出生地 "), 150);
	m_wndListGrid.InsertColumn (4, _T(" 政治面貌 "), 100);
	m_wndListGrid.InsertColumn (5, _T(" 婚姻状况 "), 150);
	m_wndListGrid.InsertColumn (6, _T(" 联系电话 "), 100);

	m_ctrlEditGridLocation.GetWindowRect (&rectGrid);
	ScreenToClient (&rectGrid);
	m_wndEditGrid.CreateGrid(rectGrid,this);

	m_wndEditGrid.InsertColumn (0, _T(" 姓名 "), 100);
	m_wndEditGrid.InsertColumn (1, _T(" 年龄 "), 100);
	m_wndEditGrid.InsertColumn (2, _T(" 籍贯 "), 100);
	m_wndEditGrid.InsertColumn (3, _T(" 出生地 "), 150);
	m_wndEditGrid.InsertColumn (4, _T(" 政治面貌 "), 100);
	m_wndEditGrid.InsertColumn (4, _T(" 婚姻状况 "), 150);
	m_wndEditGrid.InsertColumn (4, _T(" 联系电话 "), 100);


	CBCGPGridRow* pRow = m_wndEditGrid.CreateRow (m_wndEditGrid.GetColumnCount ());
	CBCGPGridItem* pItem = new CBCGPGridItem (_T("中共党员"));
	pItem->AddOption (_T("中共党员"), TRUE);
	pItem->AddOption (_T("群众"), TRUE);
	// pItem->AllowEdit(FALSE);
	pRow->ReplaceItem (4, pItem);
	pRow->ReplaceItem (5, new CBCGPGridCheckItem (FALSE));
	m_wndEditGrid.AddRow(pRow);
	m_wndEditGrid.AdjustLayout();

	Load(members);
	return TRUE; 
}
HRESULT CToolGridListDlg::OnMsgGridDoubleClick(WPARAM wp,LPARAM lp)
{
    int iRow = wp;
    CBCGPGridRow *pDbClicRow = m_wndGridTools.GetRow(iRow);
    if (pDbClicRow==NULL) return S_OK;

    CBCGPGridItem * pItemId = pDbClicRow->GetItem(0);
    if (pItemId==NULL) return S_OK;

    CString strId = pItemId->GetValue();
    if (m_ToolMap.find(strId)== m_ToolMap.end()) return S_OK;

    ToolObject & tool = m_ToolMap[strId];
    if (CToolsProUnity::ConfigTool(&tool))
    {
        CToolsProUnity::WriteToolConfigXml(tool);
    }

    return S_OK;
}
void CToolGridListDlg::OnBnClickedButtonDelSel()
{
    // TODO: 在此添加控件通知处理程序代码
    CBCGPGridRow *pSelRow = m_wndGridTools.GetCurSel();
    if (pSelRow==NULL) return;

    CBCGPGridItem * pItemId = pSelRow->GetItem(0);
    if (pItemId==NULL) return;

    CString strId = pItemId->GetValue();
    map<CString,ToolObject>::iterator iterFind = m_ToolMap.find(strId);
    if (iterFind== m_ToolMap.end()) return;

    if (MessageBox("确定要删除选中的配置?","提示",MB_YESNO|MB_ICONQUESTION)==IDNO)
        return;

    m_ToolMap.erase(iterFind);
    CToolsProUnity::DeleteToolConfigFromXml(strId);
    m_wndGridTools.RemoveRow(pSelRow->GetRowId());
    m_wndGridTools.AdjustLayout ();
}
//**********************************************************************
LRESULT CBCGPRibbonCustomizeRibbonPage::OnChangeRibbonTree(WPARAM /*wp*/, LPARAM lp)
{
#ifndef BCGP_EXCLUDE_GRID_CTRL
	BCGPGRID_ITEM_INFO* pInfo = (BCGPGRID_ITEM_INFO*)lp;
	if (pInfo == NULL)
	{
		return 0;
	}

	CBCGPGridRow* pRow = m_wndRibbonTreeDest.GetCurSel();
	if (pRow != NULL)
	{
		ASSERT_VALID(pRow);

		CBCGPGridItem* pItem = pRow->GetItem(0);
		ASSERT_VALID(pItem);

		m_CustomizationData.ShowTab((CBCGPRibbonCategory*)pRow->GetData(), (bool)pItem->GetValue());
	}
#endif
	return 0;
}
BOOL OperationParameterDialog::FillParameterGrid()
{
	if(NULL == userInputParameters)
		return FALSE;

	vector<OperationParameterPtr>::const_iterator curIterator = userInputParameters->begin();
	vector<OperationParameterPtr>::const_iterator endPos = userInputParameters->end();
	for(; curIterator != endPos; curIterator++)
	{
		OperationParameterPtr curParameterPtr = *curIterator;
		CBCGPGridRow* parameterRow = parameterInputCtrl.CreateRow(parameterInputCtrl.GetColumnCount());

		CBCGPGridItem* nameGridItem = parameterRow->GetItem(PARAMETER_NAME_COLUMN_INDEX);
		nameGridItem->SetValue((LPCSTR)curParameterPtr->GetDisplayName(), FALSE);
		nameGridItem->AllowEdit(FALSE);

		CBCGPGridItem* valueGridItem = parameterRow->GetItem(PARAMETER_VALUE_COLUMN_INDEX);
		valueGridItem->SetValue((LPCSTR)curParameterPtr->GetValue(), FALSE);

		CBCGPGridItem* rangeGridItem = parameterRow->GetItem(PARAMETER_RANGE_COLUMN_INDEX);
		rangeGridItem->SetValue((LPCSTR)curParameterPtr->GetValueRange(), FALSE);
		rangeGridItem->AllowEdit(FALSE);

		CBCGPGridItem* unitGridItem = parameterRow->GetItem(PARAMETER_UNIT_COLUNM_INDEX);
		unitGridItem->SetValue((LPCSTR)curParameterPtr->GetValueUnit(), FALSE);
		unitGridItem->AllowEdit(FALSE);

		parameterInputCtrl.AddRow(parameterRow, FALSE);

		parameterRow->SetData((DWORD_PTR)curParameterPtr.get());
	}

	parameterInputCtrl.AdjustLayout();

	return TRUE;
}