BOOL CSelectBox::SetBitmap(UINT nResourceID, int nIndex, CString strType) { if(nIndex >= 0 && nIndex < (int)m_vecpImage.size()) { Image *&pImage = m_vecpImage[nIndex]; if(pImage != NULL) { delete pImage; pImage = NULL; } if(ImageFromIDResource(nResourceID, strType, pImage)) { m_vecsizeImage[nIndex].SetSize(pImage->GetWidth(), pImage->GetHeight()); UpdateControl(true); return true; } } else if(nIndex == -1 && (int)m_vecpImage.size() < m_nXCount * m_nYCount) { Image *pImage = NULL; if(ImageFromIDResource(nResourceID, strType, pImage)) { CSize sizeImage(pImage->GetWidth(), pImage->GetHeight()); m_vecpImage.push_back(pImage); m_vecsizeImage.push_back(sizeImage); UpdateControl(true); return true; } } return false; }
BOOL CSelectBox::SetBitmap(CString strImage, int nIndex) { if(nIndex >= 0 && nIndex < (int)m_vecpImage.size()) { Image *&pImage = m_vecpImage[nIndex]; if(pImage != NULL) { delete pImage; pImage = NULL; } if(DuiSystem::Instance()->LoadImageFile(strImage, m_bImageUseECM, pImage)) { m_vecsizeImage[nIndex].SetSize(pImage->GetWidth(), pImage->GetHeight()); UpdateControl(true); return true; } } else if(nIndex == -1 && (int)m_vecpImage.size() < m_nXCount * m_nYCount) { Image *pImage = NULL; if(DuiSystem::Instance()->LoadImageFile(strImage, m_bImageUseECM, pImage)) { CSize sizeImage(pImage->GetWidth(), pImage->GetHeight()); m_vecpImage.push_back(pImage); m_vecsizeImage.push_back(sizeImage); UpdateControl(true); return true; } } return false; }
void wxSFControlShape::SetControl(wxWindow *ctrl, bool fit) { if( m_pControl ) m_pControl->Reparent( m_pPrevParent ); m_pControl = ctrl; if( m_pControl ) { m_pPrevParent = ctrl->GetParent(); if( m_pParentManager ) { wxSFShapeCanvas *pCanvas = ((wxSFDiagramManager*)m_pParentManager)->GetShapeCanvas(); // reparent GUI control if necessary if( pCanvas && ( (wxWindow*)pCanvas != m_pPrevParent ) ) m_pControl->Reparent( (wxWindow*)pCanvas ); // redirect mouse events to the event sink for their delayed processing m_pControl->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(EventSink::_OnMouseButton), NULL, m_pEventSink); m_pControl->Connect(wxEVT_RIGHT_DOWN, wxMouseEventHandler(EventSink::_OnMouseButton), NULL, m_pEventSink); m_pControl->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(EventSink::_OnMouseButton), NULL, m_pEventSink); m_pControl->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(EventSink::_OnMouseButton), NULL, m_pEventSink); m_pControl->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(EventSink::_OnMouseButton), NULL, m_pEventSink); m_pControl->Connect(wxEVT_RIGHT_DCLICK, wxMouseEventHandler(EventSink::_OnMouseButton), NULL, m_pEventSink); m_pControl->Connect(wxEVT_MOTION, wxMouseEventHandler(EventSink::_OnMouseMove), NULL, m_pEventSink); m_pControl->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(EventSink::_OnKeyDown), NULL, m_pEventSink); m_pControl->Connect(wxEVT_SIZE, wxSizeEventHandler(EventSink::_OnSize), NULL, m_pEventSink); } if( fit ) UpdateShape(); UpdateControl(); } }
void wxSFControlShape::OnHandle(wxSFShapeHandle& handle) { // call default handler wxSFRectShape::OnHandle(handle); UpdateControl(); }
BOOL CHideButton::OnControlLButtonUp(UINT nFlags, CPoint point) { enumButtonState buttonState = m_enButtonState; if (!m_bIsDisable) { if(m_rcText.PtInRect(point)) { if(m_enButtonState == enBSDown) { SendMessage(BUTTOM_UP, 0, 0); } m_enButtonState = enBSHover; } else { m_enButtonState = enBSNormal; if(!m_rc.PtInRect(point)) { m_bShowButton = false; } } } if(buttonState != m_enButtonState) { UpdateControl(); return true; } else { return false; } }
BOOL CHideButton::OnControlMouseMove(UINT nFlags, CPoint point) { enumButtonState buttonState = m_enButtonState; BOOL bOldShowBitton = m_bShowButton; if (!m_bIsDisable && m_enButtonState != enBSDown) { if(m_rc.PtInRect(point)) { m_bShowButton = true; if(m_rcText.PtInRect(point)) { m_enButtonState = enBSHover; } else { m_enButtonState = enBSNormal; } } else { m_bShowButton = false; m_enButtonState = enBSNormal; } } if(buttonState != m_enButtonState || bOldShowBitton != m_bShowButton) { UpdateControl(); return true; } else { return false; } }
BOOL CuDlgDBEventPane01::OnInitDialog() { CDialog::OnInitDialog(); VERIFY (m_cListDBEvent.SubclassDlgItem (IDC_MFC_LIST1, this)); CView* pView = (CView*)GetParent(); ASSERT (pView); CDbeventDoc* pDoc = (CDbeventDoc*)pView->GetDocument(); ASSERT (pDoc); pDoc->SetRegisteredDBEventList (&m_cListDBEvent); try { // // If the Document is load, then we update the control. UpdateControl(); } catch (CMemoryException* e) { VDBA_OutOfMemoryMessage(); e->Delete(); } catch (...) { throw; } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL CScrollV::OnControlLButtonUp(UINT nFlags, CPoint point) { if(!m_bShowScroll) { return FALSE; } enumButtonState buttonState = m_enButtonState; if (!m_bIsDisable) { m_nDownTop = -1; if(m_rcBlock.PtInRect(point)) { m_enButtonState = enBSHover; } else { m_enButtonState = enBSNormal; } } if(buttonState != m_enButtonState) { UpdateControl(); return true; } return false; }
BOOL CScrollV::OnControlLButtonDown(UINT nFlags, CPoint point) { if(!m_bShowScroll) { return FALSE; } enumButtonState buttonState = m_enButtonState; if (!m_bIsDisable) { if(m_rcBlock.PtInRect(point)) { m_enButtonState = enBSDown; m_nDownTop = point.y; } else { int nRangeHeight = m_rc.Height() - 40; int nMove = m_nPageRange * nRangeHeight / m_nMaxRange; return MoveRange(point.y < m_rcBlock.top ? -nMove : nMove); } } if(buttonState != m_enButtonState) { UpdateControl(); return true; } return false; }
// 设置Combo选择项的值 void CDuiComboBox::SetComboValue(CString strComboValue) { m_strComboValue = strComboValue; // 设置下拉列表的选择项 if(m_pPopupList) { m_pPopupList->SetCurItem(strComboValue); } // 先设置一下编辑框内容为空,避免下拉列表为空时候未设置 SetTitle(_T("")); // 设置编辑框内容 for (size_t i = 0; i < m_vecItem.size(); i++) { ComboListItem* pItem = &(m_vecItem.at(i)); if(pItem->strValue == strComboValue) { SetTitle(pItem->strName); break; } } UpdateControl(); }
// 消息响应 LRESULT CDuiListCtrl::OnMessage(UINT uID, UINT Msg, WPARAM wParam, LPARAM lParam) { if((uID == SCROLL_V) && (Msg == MSG_SCROLL_CHANGE)) { // 如果是滚动条的位置变更事件,则刷新显示 UpdateControl(true); }else if((uID == GetID()) && (Msg == MSG_BUTTON_DOWN) && (lParam != -1)) { // 点击了行的某个链接 ListRowInfo* pRowInfo = GetItemInfo(wParam); if(pRowInfo) { // 转换为MSG_BUTTON_UP消息,因为DuiSystem任务处理时候只处理MSG_BUTTON_UP消息 if((lParam == 0) && (!pRowInfo->strLinkAction1.IsEmpty())) { DuiSystem::AddDuiActionTask(uID, MSG_BUTTON_UP, wParam, lParam, GetName(), pRowInfo->strLinkAction1, GetParent()); }else if((lParam == 1) && (!pRowInfo->strLinkAction2.IsEmpty())) { DuiSystem::AddDuiActionTask(uID, MSG_BUTTON_UP, wParam, lParam, GetName(), pRowInfo->strLinkAction2, GetParent()); } } } return __super::OnMessage(uID, Msg, wParam, lParam); }
BOOL CDuiText::OnControlLButtonUp(UINT nFlags, CPoint point) { enumButtonState buttonState = m_enButtonState; if (!m_bIsDisable) { if(m_rc.PtInRect(point)) { if(m_enButtonState == enBSDown) { //ShellExecute(NULL, TEXT("open"), m_strLink, NULL,NULL,SW_NORMAL); } m_enButtonState = enBSHover; } else { m_enButtonState = enBSNormal; } } if(buttonState != m_enButtonState) { UpdateControl(); return true; } return false; }
BOOL CMenuItem::SetCheck(BOOL bCheck) { if(!m_bSelect) return false; if (m_bIsDisable) { return m_bDown; } BOOL bDown = m_bDown; m_bDown = bCheck; if(m_bDown) { m_enButtonState = enBSDown; } else { m_enButtonState = enBSNormal; } if(m_bDown != bDown) { // 如果组名非空,说明是radiobutton组,则刷新同一个组下面其他radiobtn if(!m_strGroupName.IsEmpty()) { ResetGroupCheck(); } UpdateControl(); } return m_bDown; }
//选择改变 void CChessManual::OnLbnSelchangeManualList() { int nSelItem=m_ManualList.GetCurSel(); if ((nSelItem!=LB_ERR)&&((nSelItem+1)!=m_wChessStep)) { //前进判断 if (nSelItem>=m_wChessStep) { tagChessManual * pChessManual=NULL; for (WORD i=m_wChessStep;i<(nSelItem+1);i++) { pChessManual=&m_ChessManualInfo[i]; m_GameLogic.MoveChess(pChessManual->cbXSourceChessPos,pChessManual->cbYSourceChessPos,pChessManual->cbXTargetChessPos,pChessManual->cbYTargetChessPos); } } else m_GameLogic.RegretChess(m_wChessStep-nSelItem-1); //设置棋盘 m_wChessStep=(nSelItem+1); m_ChessBorad.SetChessBorad(m_GameLogic.m_ChessBorad); //设置选择 tagChessManual * pChessManual=&m_ChessManualInfo[m_wChessStep-1]; m_ChessBorad.SetChessFrame(pChessManual->cbXSourceChessPos,pChessManual->cbYSourceChessPos,pChessManual->cbXTargetChessPos,pChessManual->cbYTargetChessPos); //更新控制 UpdateControl(); } return; }
// 鼠标左键按下 BOOL CDuiLayout::OnControlLButtonDown(UINT nFlags, CPoint point) { enumButtonState buttonState = m_enButtonState; if (!m_bIsDisable) { for(size_t i = 0; i < m_vecItemInfo.size(); i++) { LayoutItemInfo &itemInfo = m_vecItemInfo.at(i); if(itemInfo.rcThumb.PtInRect(point)) { // 如果在滚动块内,则记录鼠标位置 m_enButtonState = enBSDown; m_nHoverSplit = i; MoveSplitPos(i, point); break; }else if(itemInfo.rcSplit.PtInRect(point)) { // 如果在分隔线内,则记录鼠标位置 m_enButtonState = enBSDown; m_nHoverSplit = i; MoveSplitPos(i, point); break; } } } if(buttonState != m_enButtonState) { UpdateControl(); return true; } return false; }
// 鼠标左键按下 BOOL CDuiSlider::OnControlLButtonDown(UINT nFlags, CPoint point) { enumButtonState buttonState = m_enButtonState; if (!m_bIsDisable) { if(m_rcThumb.PtInRect(point)) { // 如果在滚动块内,则记录鼠标位置 m_enButtonState = enBSDown; MoveThumbPos(point); } else { // 不在滚动块内,则移动滚动块 MoveThumbPos(point); } } if(buttonState != m_enButtonState) { UpdateControl(); return true; } return false; }
// 将指定的行滚动到可见范围 BOOL CDuiGridCtrl::EnsureVisible(int nRow, BOOL bPartialOK) { // 如果指定的行已经处于可见范围则直接返回 if((nRow >= m_nFirstViewRow) && (nRow <= m_nLastViewRow)) { return TRUE; } CDuiScrollVertical* pScrollV = (CDuiScrollVertical*)m_pControScrollV; if(nRow < m_nFirstViewRow) { pScrollV->SetScrollCurrentPos(nRow * m_nRowHeight); }else { int nFirstRow = nRow - ((m_rc.Height() - m_nHeaderHeight) / m_nRowHeight) + 2; if(nFirstRow < 0) { nFirstRow = 0; } pScrollV->SetScrollCurrentPos(nFirstRow * m_nRowHeight); } UpdateControl(true); return TRUE; }
BOOL CMenuItem::SetCheck(BOOL bCheck) { if(!m_bSelect) return false; if (m_bIsDisable) { return m_bDown; } BOOL bDown = m_bDown; m_bDown = bCheck; if(m_bDown) { m_enButtonState = enBSDown; } else { m_enButtonState = enBSNormal; } if(m_bDown != bDown) { UpdateControl(); } return m_bDown; }
// 给表格项添加子控件 BOOL CDuiGridCtrl::AddSubItemControl(int nRow, int nItem, CControlBase* pControl) { if((nRow < 0) || (nRow >= (int)m_vecRowInfo.size())) { return FALSE; } if((nItem < 0) || (nItem >= (int)m_vecColumnInfo.size())) { return FALSE; } GridItemInfo* pItemInfo = GetItemInfo(nRow, nItem); if(pItemInfo == NULL) { SetSubItem(nRow, nItem, _T("")); pItemInfo = GetItemInfo(nRow, nItem); } if(pItemInfo == NULL) { return FALSE; } if(pControl) { pControl->SetParent(this); pControl->SetVisible(FALSE); // 将控件指针添加到gridctrl控件的子控件列表中 m_vecControl.push_back(pControl); // 将控件指针添加到单元格的控件列表中(仅用于按照单元格查找子控件) pItemInfo->vecControl.push_back(pControl); UpdateControl(true); } return TRUE; }
BOOL CCheckButton::OnControlLButtonDown(UINT nFlags, CPoint point) { enumButtonState buttonState = m_enButtonState; if (!m_bIsDisable) { if(m_rc.PtInRect(point)) { m_bMouseDown = true; if(m_bDown) { m_enButtonState = enBSHoverDown; // 设置为当前处于激活状态 m_bIsFocus = TRUE; } else { m_enButtonState = enBSHover; } } } if(buttonState != m_enButtonState) { UpdateControl(); return true; } return false; }
// 删除列表行 BOOL CDuiListCtrl::DeleteItem(int nItem) { if((nItem < 0) || (nItem >= (int)m_vecRowInfo.size())) { return FALSE; } int nIndex = 0; vector<ListRowInfo>::iterator it; for(it=m_vecRowInfo.begin();it!=m_vecRowInfo.end();++it) { if(nIndex == nItem) { m_vecRowInfo.erase(it); break; } nIndex++; } // 计算所有列表行的位置 CalcItemsPos(); UpdateControl(true); return true; }
//刷新按钮 void CChessManual::OnReLoad() { //更新棋谱 INT_PTR nManualCount=m_pDlgGameLogic->m_ChessManualInfo.GetCount(); m_ChessManualInfo.SetSize(m_pDlgGameLogic->m_ChessManualInfo.GetCount()); CopyMemory(m_ChessManualInfo.GetData(),m_pDlgGameLogic->m_ChessManualInfo.GetData(),sizeof(tagChessManual)*nManualCount); //棋盘控制 m_wChessStep=0; m_GameLogic.ResetChessBorad(); //更新列表 UpdateManualList(); //走到最后 if (nManualCount==0) { //设置界面 m_ChessBorad.SetChessFrame(255,255,255,255); m_ChessBorad.SetChessBorad(m_GameLogic.m_ChessBorad); //更新控制 UpdateControl(); } else OnLast(); return; }
// 设置选择状态 BOOL CDuiRadioButton::SetCheck(BOOL bCheck) { if (m_bIsDisable) { return m_bDown; } BOOL bDown = m_bDown; m_bDown = bCheck; if(m_bDown) { m_enButtonState = enBSDown; } else { m_enButtonState = enBSNormal; } if(m_bDown != bDown) { // 刷新同一个组下面其他radiobtn ResetGroupCheck(); UpdateControl(); } return m_bDown; }
BOOL CDuiTabCtrl::InsertItem(int nItem, TabItemInfo &itemInfo) { if(m_vecItemInfo.size() > 0) { CRect rc; m_vecRcSeperator.push_back(rc); } if(nItem <= -1 || nItem >= (int)m_vecItemInfo.size()) { m_vecItemInfo.push_back(itemInfo); } else { m_vecItemInfo.insert(m_vecItemInfo.begin() + nItem, itemInfo); } int nXPos = m_rc.left; int nYPos = m_rc.top; for(size_t i = 0; i < (int)m_vecItemInfo.size(); i++) { TabItemInfo &itemInfoTemp = m_vecItemInfo.at(i); int nItemWidth = itemInfoTemp.rc.Width(); int nItemHeight = itemInfoTemp.sizeImage.cy; if(m_nTabItemWidth == 0) { // 如果tabctrl没有设置每个tab页的宽度,则以第一个tab页的图片宽度为准 m_nTabItemWidth = nItemWidth; } if(m_nTabCtrlHeight == 0) { // 如果tabctrl没有设置高度,则以第一个tab页的图片高度为准 m_nTabCtrlHeight = nItemHeight; } itemInfoTemp.rc.SetRect(nXPos, nYPos, nXPos + m_nTabItemWidth, nYPos + m_nTabCtrlHeight); nXPos += m_nTabItemWidth; if(i < m_vecItemInfo.size() - 1 && m_pImageSeperator != NULL) { CRect &rc = m_vecRcSeperator.at(i); rc.SetRect(nXPos, nYPos, nXPos + m_sizeSeperator.cx, nYPos + m_sizeSeperator.cy); nXPos += m_sizeSeperator.cx; } /* if(itemInfoTemp.pControl != NULL) { CRect rc = itemInfoTemp.pControl->GetRect(); rc.top += itemInfoTemp.sizeImage.cy; itemInfoTemp.pControl->SetRect(rc); //itemInfoTemp.pControl->UpdateControl(); }*/ } UpdateControl(true); return true; }
void CDuiText::SetMarkText(CString strMark) { if(m_strMark != strMark) { m_strMark = strMark; UpdateControl(true); } }
BOOL CSelectBox::SetColor(Color clr, int nIndex/* = -1*/) { if(nIndex >= 0 && nIndex < (int)m_vecclr.size()) { m_vecclr[nIndex] = clr; UpdateControl(true); return true; } else if(nIndex == -1 && (int)m_vecclr.size() < m_nXCount * m_nYCount) { m_vecclr.push_back(clr); UpdateControl(true); return true; } return false; }
/// <summary> /// Reset the setting dialog and the camera parameters /// </summary> void CameraSettingsViewer::ResetSettings() { ResetSensorParameters(); UpdateControl(); UpdateControlEnableStatus(); }
void CControlBase::SetDisable(BOOL bIsDisable) { if(m_bIsDisable != bIsDisable) { SetControlDisable(bIsDisable); UpdateControl(true); } }
// 设置垂直对齐方式 void CControlBaseFont::SetVAlignment(UINT uVAlignment) { if(uVAlignment != m_uVAlignment) { m_uVAlignment = uVAlignment; UpdateControl(true); } }
// 设置title void CControlBaseFont::SetTitle(CString strTitle) { //if(strTitle != m_strTitle) { SetControlTitle(strTitle); UpdateControl(true); } }