void CCellListCtrl::OnPaint() { CPaintDC dc(this); // device context for painting int dcStateID = dc.SaveDC(); if (m_hFont != NULL) { dc.SelectObject(CFont::FromHandle(m_hFont)); } CRect rcClient(0,0,0,0); GetClientRect(&rcClient); int eachHeight = GetItemHeightInPixel(&dc); dc.SetTextColor(m_textColor); dc.SetBkColor(m_backColor); int itemCount = GetItemCount(); int columnCount = GetColumnCount(); for (int iItem = 0; iItem < itemCount; ++iItem) { int currentCellLeft = 0; CRect rcLine(0, iItem * eachHeight, rcClient.right, (iItem + 1) * eachHeight); dc.FillSolidRect(&rcLine, dc.GetBkColor()); for (int iColumn = 0; iColumn < columnCount; ++iColumn) { int eachWidth = GetColumnWidth(iColumn); CRect rcCell(currentCellLeft, rcLine.top, currentCellLeft + eachWidth, rcLine.bottom); dc.DrawText(GetItemText(iItem, iColumn), -1, &rcCell, DT_LEFT | DT_NOPREFIX); currentCellLeft += eachWidth; } } dc.RestoreDC(dcStateID); }
/** * Displays a tool-tip according to the current location of the mouse * pointer. * @param pt The mouse pointer coordinates */ void ListToolTip::maybeTip(const QPoint& pt) { QString str; QListView* pList; QListViewItem* pItem; // Get the item at the given point pList = m_pList->getList(); pItem = pList->itemAt(pt); if (pItem == NULL) return; // Get the tip string for this item if (!m_pList->getTip(pItem, str)) return; // Get the bounding rectangle of the item const QRect rcItem = pList->itemRect(pItem); if (!rcItem.isValid()) return; // Get the header coordinates const QRect rcHead = pList->header()->rect(); if (!rcHead.isValid()) return; // Calculate the tool-tip rectangle QRect rcCell(rcHead.left(), rcItem.top(), rcItem.width(), rcItem.height()); // Display the tool-tip tip(rcCell, str); }
CRect CScanDlg::CalcGridCellRect(int iRow, int iCol ) { CRect rect; m_flexGrid.GetWindowRect(rect); //获取表格控件的窗口矩形 ScreenToClient(rect); //转换为客户区矩形 CDC* pDC = GetDC(); int nTwipsPerDotX = 1440 / pDC->GetDeviceCaps(LOGPIXELSX) ; int nTwipsPerDotY = 1440 / pDC->GetDeviceCaps(LOGPIXELSY) ; //计算选中格的左上角的坐标(象素为单位) long y = m_flexGrid.get_RowPos(iRow)/nTwipsPerDotY; long x = m_flexGrid.get_ColPos(iCol)/nTwipsPerDotX; //计算选中格的尺寸(象素为单位)。加1是实际调试中,发现加1后效果更好 long width = m_flexGrid.get_ColWidth(iCol)/nTwipsPerDotX+1; long height = m_flexGrid.get_RowHeight(iRow)/nTwipsPerDotY+1; //形成选中个所在的矩形区域 CRect rcCell(x,y,x+width,y+height); //转换成相对对话框的坐标 rcCell.OffsetRect(rect.left+2,rect.top+2); rcCell.InflateRect(-1,-1,-1,-1); //CString strValue = m_flexGrid.get_TextMatrix(iRow,iCol); //pDC->Draw3dRect(rcCell, RGB(255,0,0), RGB(192,192,192)); //pDC->DrawText(_T("Fix"), &rcCell, DT_CENTER); return rcCell; ReleaseDC(pDC); }
void ApplyGraphicLabelsDlg::ClickAddbuildingMsflexgrid() { long lRow,lCol; lRow = m_FlexGrid.get_RowSel();//获取点击的行号 lCol = m_FlexGrid.get_ColSel(); //获取点击的列号 m_nCurRow=lRow; m_nCurCol=lCol; /* m_strBuilding_Name2=m_AddBuiding_FlexGrid.get_TextMatrix(lRow,AB_NAME); m_strBuildingName=m_AddBuiding_FlexGrid.get_TextMatrix(lRow,AB_NAME); m_strConnetion=m_AddBuiding_FlexGrid.get_TextMatrix(lRow,AB_CONNECTION); m_strProtocol=m_AddBuiding_FlexGrid.get_TextMatrix(lRow,AB_PROTOCOL); m_strIpAddress=m_AddBuiding_FlexGrid.get_TextMatrix(lRow,AB_IPADDRESS); m_strIpPort=m_AddBuiding_FlexGrid.get_TextMatrix(lRow,AB_IPPORT); m_strComPort=m_AddBuiding_FlexGrid.get_TextMatrix(lRow,AB_COMPORT); m_strBaudrat=m_AddBuiding_FlexGrid.get_TextMatrix(lRow,AB_BAUDRAT); */ CRect rect; m_FlexGrid.GetWindowRect(rect); //获取表格控件的窗口矩形 ScreenToClient(rect); //转换为客户区矩形 CDC* pDC =GetDC(); int nTwipsPerDotX = 1440 / pDC->GetDeviceCaps(LOGPIXELSX) ; int nTwipsPerDotY = 1440 / pDC->GetDeviceCaps(LOGPIXELSY) ; //计算选中格的左上角的坐标(象素为单位) long y = m_FlexGrid.get_RowPos(lRow)/nTwipsPerDotY; long x = m_FlexGrid.get_ColPos(lCol)/nTwipsPerDotX; //计算选中格的尺寸(象素为单位)。加1是实际调试中,发现加1后效果更好 long width = m_FlexGrid.get_ColWidth(lCol)/nTwipsPerDotX+1; long height = m_FlexGrid.get_RowHeight(lRow)/nTwipsPerDotY+1; //形成选中个所在的矩形区域 CRect rcCell(x,y,x+width,y+height); //转换成相对对话框的坐标 rcCell.OffsetRect(rect.left+1,rect.top+1); ReleaseDC(pDC); CString strValue = m_FlexGrid.get_TextMatrix(lRow,lCol); if(0==lRow) return; if(0==lCol) { //ID_BUILDINGSEL_SELECT CMenu menu; menu.LoadMenu(IDR_APPLYGRAPHICLABELS); CMenu *pmenu=menu.GetSubMenu(0); CPoint point; GetCursorPos(&point); pmenu->TrackPopupMenu(TPM_LEFTBUTTON | TPM_LEFTALIGN ,point.x,point.y,this); } }
void CUserAcessSetDlg::ClickAddbuildingMsflexgrid() { long lRow,lCol; lRow = m_FlexGrid.get_RowSel();//获取点击的行号 lCol = m_FlexGrid.get_ColSel(); //获取点击的列号 m_nCurRow=lRow; m_nCurCol=lCol; m_FlexGrid.put_Row(m_nCurRow);m_FlexGrid.put_Col(m_nCurCol); if(RGB(215,215,215)==m_FlexGrid.get_CellBackColor()) return; CRect rect; m_FlexGrid.GetWindowRect(rect); //获取表格控件的窗口矩形 ScreenToClient(rect); //转换为客户区矩形 CDC* pDC =GetDC(); int nTwipsPerDotX = 1440 / pDC->GetDeviceCaps(LOGPIXELSX) ; int nTwipsPerDotY = 1440 / pDC->GetDeviceCaps(LOGPIXELSY) ; //计算选中格的左上角的坐标(象素为单位) long y = m_FlexGrid.get_RowPos(lRow)/nTwipsPerDotY; long x = m_FlexGrid.get_ColPos(lCol)/nTwipsPerDotX; //计算选中格的尺寸(象素为单位)。加1是实际调试中,发现加1后效果更好 long width = m_FlexGrid.get_ColWidth(lCol)/nTwipsPerDotX+1; long height = m_FlexGrid.get_RowHeight(lRow)/nTwipsPerDotY+1; //形成选中个所在的矩形区域 CRect rcCell(x,y,x+width,y+height); //转换成相对对话框的坐标 rcCell.OffsetRect(rect.left+1,rect.top+1); ReleaseDC(pDC); CString strValue = m_FlexGrid.get_TextMatrix(lRow,lCol); if(lCol==6||lCol==7||lCol==8) { m_userLeveSetBox.ResetContent(); m_userLeveSetBox.AddString(_T("Read & write")); m_userLeveSetBox.AddString(_T("Read only")); m_userLeveSetBox.MoveWindow(&rcCell,1); m_userLeveSetBox.ShowWindow(SW_SHOW); m_userLeveSetBox.BringWindowToTop(); m_userLeveSetBox.SetFocus(); } if(lCol==9||lCol==11||lCol==12||lCol==10) { m_userLeveSetBox.ResetContent(); m_userLeveSetBox.AddString(_T("Enable")); m_userLeveSetBox.AddString(_T("Unenable")); m_userLeveSetBox.MoveWindow(&rcCell,1); m_userLeveSetBox.ShowWindow(SW_SHOW); m_userLeveSetBox.BringWindowToTop(); m_userLeveSetBox.SetFocus(); } }
int CMyListCtrl::OnToolHitTest(CPoint point, TOOLINFO *pTI) const { int nRow = -1, nCol = 1; CRect rcCell(1, 1, 1, 1); nRow = GetRowFromPoint(point, &rcCell, &nCol); if(nRow == -1) return -1; pTI->hwnd = m_hWnd; pTI->uId = (UINT)((nRow << 10) + (nCol & 0x3ff) + 1); pTI->lpszText = LPSTR_TEXTCALLBACK; pTI->rect = rcCell; return pTI->uId; }
void CUploadTipCtrl::DrawProgressBar(CDC* pDC, CPoint* pPoint, CUploadFile* pFile) { CRect rcCell( pPoint->x, pPoint->y, m_sz.cx, pPoint->y + TIP_TEXTHEIGHT ); pPoint->y += TIP_TEXTHEIGHT; pDC->Draw3dRect( &rcCell, CoolInterface.m_crTipBorder, CoolInterface.m_crTipBorder ); rcCell.DeflateRect( 1, 1 ); CFragmentBar::DrawUpload( pDC, &rcCell, pFile, CoolInterface.m_crTipBack ); rcCell.InflateRect( 1, 1 ); pDC->ExcludeClipRect( &rcCell ); }
void CDownloadMonitorDlg::DrawProgressBar(CDC* pDC, CRect* pRect) { CRect rcCell( pRect ); pDC->Draw3dRect( &rcCell, 0, 0 ); rcCell.DeflateRect( 1, 1 ); if ( Transfers.m_pSection.Lock( 50 ) ) { if ( Downloads.Check( m_pDownload ) ) CFragmentBar::DrawDownload( pDC, &rcCell, m_pDownload, Skin.m_crDialog ); Transfers.m_pSection.Unlock(); } }
void T38AI8AO::ClickMsflexgridOutput() { bPauseMultiRead=TRUE; m_isinput=FALSE; long lRow,lCol; lRow = m_msflexgrid_output.get_RowSel();//获取点击的行号 lCol = m_msflexgrid_output.get_ColSel(); //获取点击的列号 TRACE(_T("Click input grid!\n")); CRect rect; m_msflexgrid_output.GetWindowRect(rect); //获取表格控件的窗口矩形 ScreenToClient(rect); //转换为客户区矩形 CDC* pDC =GetDC(); int nTwipsPerDotX = 1440 / pDC->GetDeviceCaps(LOGPIXELSX) ; int nTwipsPerDotY = 1440 / pDC->GetDeviceCaps(LOGPIXELSY) ; //计算选中格的左上角的坐标(象素为单位) long y = m_msflexgrid_output.get_RowPos(lRow)/nTwipsPerDotY; long x = m_msflexgrid_output.get_ColPos(lCol)/nTwipsPerDotX; //计算选中格的尺寸(象素为单位)。加1是实际调试中,发现加1后效果更好 long width = m_msflexgrid_output.get_ColWidth(lCol)/nTwipsPerDotX+1; long height = m_msflexgrid_output.get_RowHeight(lRow)/nTwipsPerDotY+1; //形成选中个所在的矩形区域 CRect rcCell(x,y,x+width,y+height); //转换成相对对话框的坐标 rcCell.OffsetRect(rect.left+1,rect.top+1); ReleaseDC(pDC); CString strValue = m_msflexgrid_output.get_TextMatrix(lRow,lCol); m_curcol=lCol; m_currow=lRow; if(lCol==1&&lRow!=0) { //return; // 2012.2.7老毛说不允许修改 m_inNameEdt.MoveWindow(&rcCell,1); m_inNameEdt.ShowWindow(SW_SHOW); m_inNameEdt.SetWindowText(strValue); m_inNameEdt.SetFocus(); m_inNameEdt.SetCapture();//LSC int nLenth=strValue.GetLength(); m_inNameEdt.SetSel(nLenth,nLenth); //全选// } bPauseMultiRead=FALSE; }
void CManageAccountDlg::ClickMsflexgrid1() { long lRow,lCol; m_FlexGrid.put_TextMatrix(m_nCurRow,0,_T("")); lRow = m_FlexGrid.get_RowSel();//获取点击的行号 lCol = m_FlexGrid.get_ColSel(); //获取点击的列号 m_nCurRow=lRow; m_nCurCol=lCol; m_strUserName=m_FlexGrid.get_TextMatrix(m_nCurRow,1); m_strPassword=m_FlexGrid.get_TextMatrix(m_nCurRow,2); CRect rect; m_FlexGrid.GetWindowRect(rect); //获取表格控件的窗口矩形 ScreenToClient(rect); //转换为客户区矩形 CDC* pDC =GetDC(); int nTwipsPerDotX = 1440 / pDC->GetDeviceCaps(LOGPIXELSX) ; int nTwipsPerDotY = 1440 / pDC->GetDeviceCaps(LOGPIXELSY) ; //计算选中格的左上角的坐标(象素为单位) long y = m_FlexGrid.get_RowPos(lRow)/nTwipsPerDotY; long x = m_FlexGrid.get_ColPos(lCol)/nTwipsPerDotX; //计算选中格的尺寸(象素为单位)。加1是实际调试中,发现加1后效果更好 long width = m_FlexGrid.get_ColWidth(lCol)/nTwipsPerDotX+1; long height = m_FlexGrid.get_RowHeight(lRow)/nTwipsPerDotY+1; //形成选中个所在的矩形区域 CRect rcCell(x,y,x+width,y+height); //转换成相对对话框的坐标 rcCell.OffsetRect(rect.left+1,rect.top+1); ReleaseDC(pDC); CString strValue = m_FlexGrid.get_TextMatrix(lRow,lCol); if(m_nCurRow>0) m_FlexGrid.put_TextMatrix(m_nCurRow,0,_T("Select")); if(2==lCol||1==lCol) { //m_AddBuiding_FlexGrid.get_RowPos(lRow); m_valueEdit.MoveWindow(&rcCell,1); m_valueEdit.ShowWindow(SW_SHOW); m_valueEdit.SetWindowText(strValue); m_valueEdit.SetFocus(); int nLenth=strValue.GetLength(); m_valueEdit.SetSel(nLenth,nLenth); //全选// } }
void T38AI8AO::ClickMsflexgridInput() { bPauseMultiRead=TRUE; m_isinput=TRUE; m_comboxRange.ShowWindow(FALSE); UpdateData(FALSE); long lRow,lCol; lRow = m_msflexgrid_input.get_RowSel();//获取点击的行号 lCol = m_msflexgrid_input.get_ColSel(); //获取点击的列号 TRACE(_T("Click input grid!\n")); CRect rect; m_msflexgrid_input.GetWindowRect(rect); //获取表格控件的窗口矩形 ScreenToClient(rect); //转换为客户区矩形 CDC* pDC =GetDC(); int nTwipsPerDotX = 1440 / pDC->GetDeviceCaps(LOGPIXELSX) ; int nTwipsPerDotY = 1440 / pDC->GetDeviceCaps(LOGPIXELSY) ; //计算选中格的左上角的坐标(象素为单位) long y = m_msflexgrid_input.get_RowPos(lRow)/nTwipsPerDotY; long x = m_msflexgrid_input.get_ColPos(lCol)/nTwipsPerDotX; //计算选中格的尺寸(象素为单位)。加1是实际调试中,发现加1后效果更好 long width = m_msflexgrid_input.get_ColWidth(lCol)/nTwipsPerDotX+1; long height = m_msflexgrid_input.get_RowHeight(lRow)/nTwipsPerDotY+1; //形成选中个所在的矩形区域 CRect rcCell(x,y,x+width,y+height); //转换成相对对话框的坐标 rcCell.OffsetRect(rect.left+1,rect.top+1); ReleaseDC(pDC); CString strValue = m_msflexgrid_input.get_TextMatrix(lRow,lCol); m_curcol=lCol; m_currow=lRow; if(((3==lCol)||(1==lCol)) && lRow != 0) { m_inNameEdt.MoveWindow(&rcCell,1); m_inNameEdt.ShowWindow(SW_SHOW); m_inNameEdt.SetWindowText(strValue); m_inNameEdt.SetFocus(); m_inNameEdt.SetCapture();//LSC int nLenth=strValue.GetLength(); m_inNameEdt.SetSel(nLenth,nLenth); //全选// } if((2==lCol)&&lRow!=0) { m_comboxRange.MoveWindow(&rcCell,1); m_comboxRange.ResetContent(); m_comboxRange.AddString(_T("RAW DATA")); m_comboxRange.AddString(_T("10K C")); m_comboxRange.AddString(_T("10K F")); m_comboxRange.AddString(_T("0-100%")); m_comboxRange.AddString(_T("ON/OFF")); m_comboxRange.AddString(_T("OFF/ON")); m_comboxRange.AddString(_T("Pulse Input")); m_comboxRange.AddString(_T("Lighting Control")); m_comboxRange.AddString(_T("TYPE3 10K C")); m_comboxRange.AddString(_T("TYPE3 10K F")); m_comboxRange.AddString(_T("NO USE")); m_comboxRange.AddString(_T("0-5V")); m_comboxRange.AddString(_T("0-10V")); m_comboxRange.AddString(_T("0-20I")); m_comboxRange.ShowWindow(SW_SHOW); m_comboxRange.BringWindowToTop(); m_comboxRange.SetFocus(); //获取焦点 m_comboxRange.SetWindowText(strValue); } bPauseMultiRead=FALSE; }
void CAddBuilding::ClickAddbuildingMsflexgrid() { #if 1 long lRow,lCol; lRow = m_AddBuiding_FlexGrid.get_RowSel();//获取点击的行号 lCol = m_AddBuiding_FlexGrid.get_ColSel(); //获取点击的列号 if(lRow<=0) return; m_nCurRow=lRow; m_nCurCol=lCol; m_strBuilding_Name2=m_AddBuiding_FlexGrid.get_TextMatrix(m_nCurRow,AB_NAME); m_strBuildingName=m_AddBuiding_FlexGrid.get_TextMatrix(m_nCurRow,AB_NAME); //m_BuildNameLst.at(m_BuildNameLst.size()-1).strMainBuildName if(m_nCurRow<m_AddBuiding_FlexGrid.get_Rows()-1) { m_strMainBuildingName2=m_BuildNameLst.at(m_nCurRow-1).strMainBuildName; //if(m_strMainBuildingName2.IsEmpty()) //{ // m_strMainBuildingName2=m_BuildNameLst.at(m_nCurRow-1).strMainBuildName; //} m_strMainBuildingName=m_strMainBuildingName2; } m_strProtocol=m_AddBuiding_FlexGrid.get_TextMatrix(m_nCurRow,AB_PROTOCOL); m_strIpAddress=m_AddBuiding_FlexGrid.get_TextMatrix(m_nCurRow,AB_IPADDRESS); m_strIpPort=m_AddBuiding_FlexGrid.get_TextMatrix(m_nCurRow,AB_IPPORT); m_strComPort=m_AddBuiding_FlexGrid.get_TextMatrix(m_nCurRow,AB_COMPORT); m_strBaudrat=m_AddBuiding_FlexGrid.get_TextMatrix(m_nCurRow,AB_BAUDRAT); CRect rect; m_AddBuiding_FlexGrid.GetWindowRect(rect); //获取表格控件的窗口矩形 ScreenToClient(rect); //转换为客户区矩形 CDC* pDC =GetDC(); int nTwipsPerDotX = 1440 / pDC->GetDeviceCaps(LOGPIXELSX) ; int nTwipsPerDotY = 1440 / pDC->GetDeviceCaps(LOGPIXELSY) ; //计算选中格的左上角的坐标(象素为单位) long y = m_AddBuiding_FlexGrid.get_RowPos(lRow)/nTwipsPerDotY; long x = m_AddBuiding_FlexGrid.get_ColPos(lCol)/nTwipsPerDotX; //计算选中格的尺寸(象素为单位)。加1是实际调试中,发现加1后效果更好 long width = m_AddBuiding_FlexGrid.get_ColWidth(lCol)/nTwipsPerDotX+1; long height = m_AddBuiding_FlexGrid.get_RowHeight(lRow)/nTwipsPerDotY+1; //形成选中个所在的矩形区域 CRect rcCell(x,y,x+width,y+height); //转换成相对对话框的坐标 rcCell.OffsetRect(rect.left+1,rect.top+1); ReleaseDC(pDC); CString strValue = m_AddBuiding_FlexGrid.get_TextMatrix(lRow,lCol); if(0==lCol) { //ID_BUILDINGSEL_SELECT int rows = m_AddBuiding_FlexGrid.get_Rows(); if ((lRow == 0)||(lRow + 1 == rows)) { return; } if (lRow!=0) { CMenu menu; menu.LoadMenu(IDR_BUILDINGSELE_MENU); CMenu *pmenu=menu.GetSubMenu(0); CPoint point; GetCursorPos(&point); pmenu->TrackPopupMenu(TPM_LEFTBUTTON | TPM_LEFTALIGN ,point.x,point.y,this); } } if(lCol==AB_MAINNAME) { m_mainBuildEdt.MoveWindow(&rcCell,1); m_mainBuildEdt.ShowWindow(SW_SHOW); m_mainBuildEdt.SetWindowText(strValue); m_mainBuildEdt.SetFocus(); int nLenth=strValue.GetLength(); m_mainBuildEdt.SetSel(0,nLenth); //全选// } if(AB_NAME==lCol||AB_IPADDRESS==lCol||AB_IPPORT==lCol) { //m_AddBuiding_FlexGrid.get_RowPos(lRow); m_AddBuiding_SetEditCtrl.MoveWindow(&rcCell,1); m_AddBuiding_SetEditCtrl.ShowWindow(SW_SHOW); m_AddBuiding_SetEditCtrl.SetWindowText(strValue); m_AddBuiding_SetEditCtrl.SetFocus(); int nLenth=strValue.GetLength(); m_AddBuiding_SetEditCtrl.SetSel(0,nLenth); //全选// } /* if(AB_CONNECTION==lCol) { m_AddBuiding_SetComBox.ResetContent(); m_AddBuiding_SetComBox.InsertString(0,_T("COM Port")); m_AddBuiding_SetComBox.InsertString(1,_T("IP(VIA NC)")); m_AddBuiding_SetComBox.InsertString(2,_T("IP(Direct)")); m_AddBuiding_SetComBox.MoveWindow(&rcCell,1); //移动到选中格的位置 m_AddBuiding_SetComBox.BringWindowToTop(); m_AddBuiding_SetComBox.ShowWindow(SW_SHOW);//显示控件 m_AddBuiding_SetComBox.SetFocus(); //获取焦点 } */ if(AB_PROTOCOL==lCol) { m_AddBuiding_SetComBox.ResetContent(); m_AddBuiding_SetComBox.InsertString(0,_T("Modbus 485")); m_AddBuiding_SetComBox.InsertString(1,_T("Modbus TCP")); m_AddBuiding_SetComBox.InsertString(2,_T("BacnetIP")); m_AddBuiding_SetComBox.MoveWindow(&rcCell,1); //移动到选中格的位置 m_AddBuiding_SetComBox.BringWindowToTop(); m_AddBuiding_SetComBox.ShowWindow(SW_SHOW);//显示控件 m_AddBuiding_SetComBox.SetFocus(); //获取焦点 } if(AB_COMPORT==lCol) { m_AddBuiding_SetComBox.ResetContent(); for (UINT i = 0; i < m_szComm.size(); i++) { m_AddBuiding_SetComBox.AddString(m_szComm[i]); } m_AddBuiding_SetComBox.MoveWindow(&rcCell,1); //移动到选中格的位置 m_AddBuiding_SetComBox.BringWindowToTop(); m_AddBuiding_SetComBox.ShowWindow(SW_SHOW);//显示控件 m_AddBuiding_SetComBox.SetFocus(); //获取焦点 } if(AB_BAUDRAT==lCol) { m_AddBuiding_SetComBox.ResetContent(); m_AddBuiding_SetComBox.AddString(_T("9600")); m_AddBuiding_SetComBox.AddString(_T("19200")); m_AddBuiding_SetComBox.MoveWindow(&rcCell,1); //移动到选中格的位置 // m_AddBuiding_SetComBox.BringWindowToTop(); m_AddBuiding_SetComBox.ShowWindow(SW_SHOW);//显示控件 m_AddBuiding_SetComBox.SetFocus(); //获取焦点 } #endif }
void CRegisterViewerDlg::ClickInputMsflexgrid() { m_inNameEdt.ShowWindow(SW_HIDE); long lRow,lCol; lRow = m_registerlistGrid.get_RowSel();//获取点击的行号 lCol = m_registerlistGrid.get_ColSel(); //获取点击的列号 TRACE(_T("Click input grid!\n")); CRect rect; m_registerlistGrid.GetWindowRect(rect); //获取表格控件的窗口矩形 ScreenToClient(rect); //转换为客户区矩形 CDC* pDC =GetDC(); int nTwipsPerDotX = 1440 / pDC->GetDeviceCaps(LOGPIXELSX) ; int nTwipsPerDotY = 1440 / pDC->GetDeviceCaps(LOGPIXELSY) ; //计算选中格的左上角的坐标(象素为单位) long y = m_registerlistGrid.get_RowPos(lRow)/nTwipsPerDotY; long x = m_registerlistGrid.get_ColPos(lCol)/nTwipsPerDotX; //计算选中格的尺寸(象素为单位)。加1是实际调试中,发现加1后效果更好 long width = m_registerlistGrid.get_ColWidth(lCol)/nTwipsPerDotX+1; long height = m_registerlistGrid.get_RowHeight(lRow)/nTwipsPerDotY+1; //形成选中个所在的矩形区域 CRect rcCell(x,y,x+width,y+height); //转换成相对对话框的坐标 rcCell.OffsetRect(rect.left+1,rect.top+1); ReleaseDC(pDC); CString strValue = m_registerlistGrid.get_TextMatrix(lRow,lCol); m_oldname=strValue; m_SelCurCol=lCol; m_SelCurRow=lRow; if (!m_CanEdit) { /* m_registerlistGrid.put_Row(m_SelCurRow); m_registerlistGrid.put_Col(m_SelCurCol); unsigned long color=m_registerlistGrid.get_CellBackColor(); if (BACK_CELL==color) { m_registerlistGrid.put_Row(m_SelCurRow); m_registerlistGrid.put_Col(m_SelCurCol); m_registerlistGrid.put_CellBackColor(WRITE_COLOR); } else { m_registerlistGrid.put_Row(m_SelCurRow); m_registerlistGrid.put_Col(m_SelCurCol); m_registerlistGrid.put_CellBackColor(BACK_CELL); }*/ return; } m_inNameEdt.MoveWindow(&rcCell,1); m_inNameEdt.ShowWindow(SW_SHOW); m_inNameEdt.SetWindowText(strValue); m_inNameEdt.SetFocus(); m_inNameEdt.SetCapture();//LSC int nLenth=strValue.GetLength(); m_inNameEdt.SetSel(nLenth,nLenth); //全选// }
void CRegisterViewerDlg::DblClickInputMsflexgrid() { m_inNameEdt.ShowWindow(SW_HIDE); long lRow,lCol; lRow = m_registerlistGrid.get_RowSel();//获取点击的行号 lCol = m_registerlistGrid.get_ColSel(); //获取点击的列号 TRACE(_T("Click input grid!\n")); CRect rect; m_registerlistGrid.GetWindowRect(rect); //获取表格控件的窗口矩形 ScreenToClient(rect); //转换为客户区矩形 CDC* pDC =GetDC(); int nTwipsPerDotX = 1440 / pDC->GetDeviceCaps(LOGPIXELSX) ; int nTwipsPerDotY = 1440 / pDC->GetDeviceCaps(LOGPIXELSY) ; //计算选中格的左上角的坐标(象素为单位) long y = m_registerlistGrid.get_RowPos(lRow)/nTwipsPerDotY; long x = m_registerlistGrid.get_ColPos(lCol)/nTwipsPerDotX; //计算选中格的尺寸(象素为单位)。加1是实际调试中,发现加1后效果更好 long width = m_registerlistGrid.get_ColWidth(lCol)/nTwipsPerDotX+1; long height = m_registerlistGrid.get_RowHeight(lRow)/nTwipsPerDotY+1; //形成选中个所在的矩形区域 CRect rcCell(x,y,x+width,y+height); //转换成相对对话框的坐标 rcCell.OffsetRect(rect.left+1,rect.top+1); ReleaseDC(pDC); CString strValue = m_registerlistGrid.get_TextMatrix(lRow,lCol); m_oldname=strValue; m_SelCurCol=lCol; m_SelCurRow=lRow; m_regno=m_Inifile.GetProfileInt(SECTION,_T("RegNo"),0); m_value=m_Inifile.GetProfileInt(SECTION,_T("Value"),1); m_name=m_Inifile.GetProfileInt(SECTION,_T("Name"),2); m_type=m_Inifile.GetProfileInt(SECTION,_T("Data Type"),3); //m_length=m_Inifile.GetProfileInt(SECTION,_T("Data Length"),4); m_description=m_Inifile.GetProfileInt(SECTION,_T("Description"),5); m_Operation=m_Inifile.GetProfileInt(SECTION,_T("Operation"),6); // m_registerlistGrid.put_Row(m_SelCurRow); // m_registerlistGrid.put_Col(m_SelCurCol); // m_registerlistGrid.put_CellBackColor(WRITE_COLOR); if (m_CanEdit) { return; } if ((m_SelCurCol==m_value)&&m_SelCurRow!=0) { CString reg_no=m_registerlistGrid.get_TextMatrix(m_SelCurRow,m_regno); CString reg_value=m_registerlistGrid.get_TextMatrix(m_SelCurRow,m_value); CString reg_name=m_registerlistGrid.get_TextMatrix(m_SelCurRow,m_name); CString reg_description=m_registerlistGrid.get_TextMatrix(m_SelCurRow,m_description); CString reg_Type=m_registerlistGrid.get_TextMatrix(m_SelCurRow,m_type); CString reg_Operation=m_registerlistGrid.get_TextMatrix(m_SelCurRow,m_Operation); m_WriteValueDlg.Set(0,reg_Type,reg_name,reg_no,reg_value,reg_description,reg_Operation); m_WriteValueDlg.DoModal(); } if ((m_SelCurCol==m_description)&&m_SelCurRow!=0) { CString reg_no=m_registerlistGrid.get_TextMatrix(m_SelCurRow,m_regno); CString reg_value=m_registerlistGrid.get_TextMatrix(m_SelCurRow,m_value); CString reg_name=m_registerlistGrid.get_TextMatrix(m_SelCurRow,m_name); CString reg_description=m_registerlistGrid.get_TextMatrix(m_SelCurRow,m_description); CString reg_Type=m_registerlistGrid.get_TextMatrix(m_SelCurRow,m_type); CString reg_Operation=m_registerlistGrid.get_TextMatrix(m_SelCurRow,m_Operation); m_WriteValueDlg.Set(1,reg_Type,reg_name,reg_no,reg_value,reg_description,reg_Operation); m_WriteValueDlg.DoModal(); } }
RBitmapImage& RWinColorPalette::GetPaletteBitmapImage( ) { static BOOLEAN m_fPaletteInitialized = FALSE; static RBitmapImage m_biPalette; if ( !m_fPaletteInitialized ) { // find the resource in the resource file HRSRC hRsrc = FindResource( AfxGetResourceHandle(), MAKEINTRESOURCE( m_uPaletteBitmapID ), RT_BITMAP ); if ( hRsrc != NULL ) { // get a handle to the resource data HGLOBAL hTemp = LoadResource( AfxGetResourceHandle(), hRsrc ); if ( hTemp != NULL ) { // Initlize the palette bitmap with the resource data m_biPalette.Initialize( LockResource( hTemp ) ); // unlock and free the resource UnlockResource( hTemp ); FreeResource( hTemp ); } else AfxThrowResourceException( ); } else AfxThrowResourceException( ); m_fPaletteInitialized = TRUE; COLORMAP crColorMap[] = { { RGB( 255, 255, 255 ), GetSysColor( COLOR_BTNHIGHLIGHT ) }, { RGB( 192, 192, 192 ), GetSysColor( COLOR_BTNFACE ) }, { RGB( 128, 128, 128 ), GetSysColor( COLOR_BTNSHADOW ) } }; RIntPoint ptCells[] = { FindColor( crColorMap[0].from ), FindColor( crColorMap[1].from ), FindColor( crColorMap[2].from ) }; void* pRawData = m_biPalette.GetRawData(); RGBQUAD* pColorData = (RGBQUAD *) RBitmapImage::GetColorData( pRawData ); LPBYTE pImageData = (LPBYTE) RBitmapImage::GetImageData( pRawData ); for (int j = 0; (LPVOID) pColorData < (LPVOID) pImageData; j++, pColorData++) { for (int i = 0; i < NumElements( crColorMap ); i++) { if (crColorMap[i].from == RGB( pColorData->rgbRed, pColorData->rgbGreen, pColorData->rgbBlue )) { pColorData->rgbBlue = GetBValue( crColorMap[i].to ); pColorData->rgbRed = GetRValue( crColorMap[i].to ); pColorData->rgbGreen = GetGValue( crColorMap[i].to ); pColorData->rgbReserved = 0; } } if (j == 9) { // We only need to look at the system colors, so // jump to the last 10 entries in the palette. pColorData += 235; } } m_biPalette.UpdatePalette(); // // Relace the cells that got remapped // ROffscreenDrawingSurface dsMem; dsMem.SetImage( &m_biPalette ); RSolidColor rSolid; for (int i = 0; i < NumElements( ptCells ); i++) { if (ptCells[i].m_x >= 0 && ptCells[i].m_y >= 0) { RIntRect rcCell( RIntSize( kCellSize.m_dx - 2, kCellSize.m_dy - 2 ) ); rcCell.Offset( RIntSize( ptCells[i].m_x + 1, ptCells[i].m_y + 1 ) ); rSolid = crColorMap[i].from; RColor rColor( rSolid ); dsMem.SetFillColor( rColor ); dsMem.FillRectangle( rcCell ); } } dsMem.ReleaseImage(); } return m_biPalette; }
void CXTPCalendarDayViewTimeScale::Draw(CDC* pDC) { ASSERT(pDC && m_pDayView); if (!pDC || !m_pDayView) { return; } pDC->FillSolidRect(m_Layout.m_rcHeader, GetSysColor(COLOR_3DFACE)); pDC->SetBkMode(TRANSPARENT); int nRowHeight = XTP_SAFE_GET1(m_pDayView, GetRowHeight(), 0); if (nRowHeight <= 0) return; const int nRowCount = m_pDayView->GetVisibleRowCount(); const int nTopRow = m_pDayView->GetTopRow(); COleDateTimeSpan spScaleInterval = GetScaleInterval(); if (CXTPCalendarUtils::GetTotalMinutes(spScaleInterval) < 1) { ASSERT(FALSE); spScaleInterval.SetDateTimeSpan(0, 0, 5, 0); } //=== Calculate 'now' line. Draw it's BK ================================ int nNowLineY = 0; if (m_bDrawNowLineDyn) { int nBottomRow = nTopRow + m_pDayView->GetVisibleRowCount(); COleDateTime dtTopTime = m_pDayView->GetCellTime(nTopRow); COleDateTime dtBottomTime = m_pDayView->GetCellTime(nBottomRow); COleDateTimeSpan spView = dtBottomTime - dtTopTime; COleDateTime dtNow = CXTPCalendarUtils::GetCurrentTime(); dtNow = CXTPCalendarUtils::ResetDate(dtNow); COleDateTimeSpan spNow = dtNow - dtTopTime; double dPixelPerSecond = m_Layout.m_rcTimeZone.Height() / (double)CXTPCalendarUtils::GetTotalSeconds(spView); int nDlta = int(CXTPCalendarUtils::GetTotalSeconds(spNow) * dPixelPerSecond); nNowLineY = m_Layout.m_rcTimeZone.top + nDlta; XTP_SAFE_CALL3(m_pDayView, GetPaintManager(), GetDayViewTimeScaleHeaderPart(), DrawNowLine(pDC, m_pDayView, m_Layout.m_rcTimeZone, nNowLineY, TRUE) ); } //================================================================ int nTimeShiftCorrectorY = 0; COleDateTimeSpan spShiftCorrector(0); int nScaleInterval_min = max(1, (int)CXTPCalendarUtils::GetTotalMinutes(spScaleInterval)); double dPixelPerMin = (double)nRowHeight / (double)nScaleInterval_min; if (CXTPCalendarUtils::GetTotalHours(spScaleInterval) < 1) { int nMul = m_nTimeshift_min / 60; int nMod = m_nTimeshift_min % 60; int nShiftCorrector_min = (nMul + (nMod ? 1 :0))*60 - m_nTimeshift_min; //------------------------------------------------------------------- int nMul2 = nShiftCorrector_min / nScaleInterval_min; int nMod2 = nShiftCorrector_min % nScaleInterval_min; int nShiftCorrector2_min = (nMul2 + (nMod2 ? 1 :0)) * nScaleInterval_min; nTimeShiftCorrectorY = (int)(dPixelPerMin * nShiftCorrector2_min); spShiftCorrector = CXTPCalendarUtils::Minutes2Span(nShiftCorrector_min); } // draw time scale header COleDateTimeSpan spShift = CXTPCalendarUtils::Minutes2Span(m_nTimeshift_min); // draw time scale rows if (CXTPCalendarUtils::GetTotalHours(spScaleInterval) >= 1) { // draw time scale cells one by one for (int i = 0; i < nRowCount; i++) { CRect rcCell(m_Layout.m_rcTimeZone.left, m_Layout.m_rcTimeZone.top + nRowHeight * i, m_Layout.m_rcTimeZone.right, m_Layout.m_rcTimeZone.top + nRowHeight * (i + 1)); COleDateTime dtTime = m_pDayView->GetCellTime(nTopRow + i); dtTime += spShift; CString str = Format(dtTime, FALSE); XTP_SAFE_CALL3(m_pDayView, GetPaintManager(), GetDayViewTimeScaleCellPart(), DrawHourCell(pDC, rcCell, str, FALSE)); } } else { COleDateTimeSpan spHour(0, 1, 0, 0); spShift += spShiftCorrector; int nRowPerHour = (int)((double)spHour / (double)spScaleInterval + XTP_HALF_SECOND); ASSERT(nRowPerHour > 0); nRowPerHour = max(1, nRowPerHour); const int nHourCellHeight = nRowHeight*nRowPerHour; // Adjust time font size CRect rcStartCell(m_Layout.m_rcTimeZone); rcStartCell.top += nTimeShiftCorrectorY; rcStartCell.bottom = rcStartCell.top + nHourCellHeight; //XTP_SAFE_CALL3(m_pDayView, GetPaintManager(), GetDayViewTimeScaleCellPart(), // AdjustTimeFont(pDC, rcStartCell)); //------------------------------------------------------------------- int nHrCellDiv = m_Layout.m_rcTimeZone.Height() / rcStartCell.Height(); int nHrCellMod = m_Layout.m_rcTimeZone.Height() / rcStartCell.Height(); int nDrawCellCount = nHrCellDiv + (nHrCellMod ? 1 :0); COleDateTime dtStartCell = m_pDayView->GetCellTime(nTopRow); dtStartCell += spShift; int nSCMinute = dtStartCell.GetMinute(); if (nSCMinute != 0) { int nMinutesShiftY = (int)(dPixelPerMin * nSCMinute); rcStartCell.top -= nMinutesShiftY; rcStartCell.bottom -= nMinutesShiftY; dtStartCell.SetTime(dtStartCell.GetHour(), 0, 0); nDrawCellCount++; } //while (rcStartCell.top > m_rcTimeZone.top) for (int n = 0; rcStartCell.top > m_Layout.m_rcTimeZone.top && n < 100; n++) { dtStartCell -= spHour; rcStartCell.top -= nHourCellHeight; rcStartCell.bottom -= nHourCellHeight; nDrawCellCount++; } // draw time scale cells with only one big hour number BOOL bTopCell = TRUE; CRect rcCell = rcStartCell; for (int i = 0; i < nDrawCellCount; i++) { COleDateTime dtCell = dtStartCell + COleDateTimeSpan(i * (double)spHour); ASSERT(dtCell.GetMinute() == 0); CString strHour, strMin; Format(dtCell, bTopCell, &strHour, &strMin); if (rcCell.top >= m_Layout.m_rcTimeZone.top) { bTopCell = FALSE; } // draw text XTP_SAFE_CALL3(m_pDayView, GetPaintManager(), GetDayViewTimeScaleCellPart(), DrawBigHourCell(pDC, rcCell, strHour, strMin, nRowPerHour, FALSE)); rcCell.top += nHourCellHeight; rcCell.bottom += nHourCellHeight; } } //*** draw 'now' line if (m_bDrawNowLineDyn) { XTP_SAFE_CALL3(m_pDayView, GetPaintManager(), GetDayViewTimeScaleHeaderPart(), DrawNowLine(pDC, m_pDayView, m_Layout.m_rcTimeZone, nNowLineY, FALSE) ); } //*** Draw Expand Signs XTP_SAFE_CALL3(m_pDayView, GetPaintManager(), GetDayViewTimeScaleHeaderPart(), DrawExpandSigns(pDC, m_pDayView, m_Layout.m_rcTimeZone) ); //*** Draw header CRect rcHeader(m_Layout.m_rcHeader.left, m_Layout.m_rcHeader.top, m_Layout.m_rcHeader.right, m_Layout.m_rcTimeZone.top); XTP_SAFE_CALL3(m_pDayView, GetPaintManager(), GetDayViewTimeScaleHeaderPart(), OnDraw(pDC, m_pDayView, rcHeader, m_strCaption)); }
void CModbusPollView::ClickMsflexgridDataGrid(){ long lRow,lCol; lRow = m_MsDataGrid.get_RowSel();//获取点击的行号 lCol = m_MsDataGrid.get_ColSel(); //获取点击的列号 TRACE(_T("Click input grid!\n")); CRect rect; m_MsDataGrid.GetWindowRect(rect); //获取表格控件的窗口矩形 ScreenToClient(rect); //转换为客户区矩形 CDC* pDC =GetDC(); int nTwipsPerDotX = 1440 / pDC->GetDeviceCaps(LOGPIXELSX) ; int nTwipsPerDotY = 1440 / pDC->GetDeviceCaps(LOGPIXELSY) ; //计算选中格的左上角的坐标(象素为单位) long y = m_MsDataGrid.get_RowPos(lRow)/nTwipsPerDotY; long x = m_MsDataGrid.get_ColPos(lCol)/nTwipsPerDotX; //计算选中格的尺寸(象素为单位)。加1是实际调试中,发现加1后效果更好 long width = m_MsDataGrid.get_ColWidth(lCol)/nTwipsPerDotX+1; long height = m_MsDataGrid.get_RowHeight(lRow)/nTwipsPerDotY+1; //形成选中个所在的矩形区域 CRect rcCell(x,y,x+width,y+height); //转换成相对对话框的坐标 rcCell.OffsetRect(rect.left+1,rect.top+1); ReleaseDC(pDC); CString strValue = m_MsDataGrid.get_TextMatrix(lRow,lCol); m_Current_Col=lCol; m_Current_Row=lRow; m_edit_name.ShowWindow(SW_HIDE); if (m_Hide_Alias_Columns!=0)//都是数值的 { Show_Name=FALSE; } else//含义名字的 { if (lCol%3==1) { Show_Name=TRUE; } else { Show_Name=FALSE; } //Index=(lCol/2-1)*(m_MsDataGrid.get_Rows()-1)+(lRow-1); } if (Show_Name) { // m_edit_name.ShowWindow(SW_SHOW); // m_edit_name.SetWindowText(strValue); // m_edit_name.MoveWindow(rcCell); //移动到选中格的位置,覆盖 // m_edit_name.BringWindowToTop(); // m_edit_name.SetFocus(); //获取焦点 } // m_MsDataGrid.put_Row(lRow); //m_MsDataGrid.put_Col(lCol); ////100 149 237 //m_MsDataGrid.put_CellBackColor(RGB(100,150,240)); // if (lRow!=0&&lCol==0) // { // /*for (int row=1;row<m_msflexgrid.get_Rows();row++) // {*/ // for (int i=1;i<m_MsDataGrid.get_Cols();i++){ // m_MsDataGrid.put_Row(lRow); // m_MsDataGrid.put_Col(i); // //100 149 237 // m_MsDataGrid.put_CellBackColor(RGB(100,150,240)); // } ///* }*/ // // } //if (lCol!=0&&lRow==0) //{ // for (int row=1;row<m_MsDataGrid.get_Rows();row++) // { // /*for (int i=1;i<m_msflexgrid.get_Cols();i++){*/ // m_MsDataGrid.put_Row(row); // m_MsDataGrid.put_Col(lCol); // //100 149 237 // m_MsDataGrid.put_CellBackColor(RGB(100,150,240)); // /* }*/ // } //} }
void CModbusPollView::DBClickMsflexgridDataGrid(){ long lRow,lCol; lRow = m_MsDataGrid.get_RowSel();//获取点击的行号 lCol = m_MsDataGrid.get_ColSel(); //获取点击的列号 TRACE(_T("Click input grid!\n")); CRect rect; m_MsDataGrid.GetWindowRect(rect); //获取表格控件的窗口矩形 ScreenToClient(rect); //转换为客户区矩形 CDC* pDC =GetDC(); int nTwipsPerDotX = 1440 / pDC->GetDeviceCaps(LOGPIXELSX) ; int nTwipsPerDotY = 1440 / pDC->GetDeviceCaps(LOGPIXELSY) ; //计算选中格的左上角的坐标(象素为单位) long y = m_MsDataGrid.get_RowPos(lRow)/nTwipsPerDotY; long x = m_MsDataGrid.get_ColPos(lCol)/nTwipsPerDotX; //计算选中格的尺寸(象素为单位)。加1是实际调试中,发现加1后效果更好 long width = m_MsDataGrid.get_ColWidth(lCol)/nTwipsPerDotX+1; long height = m_MsDataGrid.get_RowHeight(lRow)/nTwipsPerDotY+1; //形成选中个所在的矩形区域 CRect rcCell(x,y,x+width,y+height); //转换成相对对话框的坐标 rcCell.OffsetRect(rect.left+1,rect.top+1); ReleaseDC(pDC); CString strValue = m_MsDataGrid.get_TextMatrix(lRow,lCol); m_Current_Col=lCol; m_Current_Row=lRow; int Index; UINT Address; if (m_Hide_Alias_Columns!=0)//都是数值的 { // Index=(lCol/3)*(m_MsDataGrid.get_Rows()-1)+(lRow-1); if (lCol%2==0) { Index=(lCol/2-1)*(m_MsDataGrid.get_Rows()-1)+(lRow-1); } else { Index=(lCol/2)*(m_MsDataGrid.get_Rows()-1)+(lRow-1); } Show_Name=FALSE; } else//含义名字的 { if (lCol%3==1) { Show_Name=TRUE; } else { Show_Name=FALSE; if (lCol%3==0) { Index=(lCol/3-1)*(m_MsDataGrid.get_Rows()-1)+(lRow-1); } else { Index=(lCol/3)*(m_MsDataGrid.get_Rows()-1)+(lRow-1); } //Index=(lCol/4)*(m_MsDataGrid.get_Rows()-1)+(lRow-1); } //Index=(lCol/2-1)*(m_MsDataGrid.get_Rows()-1)+(lRow-1); } if (Show_Name) { m_edit_name.ShowWindow(SW_SHOW); m_edit_name.SetWindowText(strValue); m_edit_name.MoveWindow(rcCell); //移动到选中格的位置,覆盖 m_edit_name.BringWindowToTop(); m_edit_name.SetFocus(); //获取焦点 } else { Address=Get_Reg_Add(Index); CString Value=Get_Data_No_Address(Index); //CWriteSingleRegisterDlg(UINT Slave_ID=255,UINT Address=0,BOOL Close_Dlg=FALSE,BOOL Single_Function=FALSE,UINT DataFormat=0,int value=0,CWnd* pParent = NULL) if (m_Display<3) { CWriteSingleRegisterDlg dlg(m_Slave_ID,Address,m_close_dlg,m_function,m_Display,m_PLC_Addresses,Value,NULL); if (IDOK==dlg.DoModal()) { m_close_dlg=dlg.m_close_dlg; m_function=dlg.m_function; } } else if (m_Display==3) { CWriteSingle_BinaryDlg dlg; dlg.m_slave_id=m_Slave_ID; dlg.m_address=Address; dlg.m_close_dlg=m_close_dlg; dlg.m_function=m_function; dlg.m_data_format=m_Display; dlg.m_base_0=m_PLC_Addresses; dlg.m_StrValue=Value; if (IDOK==dlg.DoModal()) { m_close_dlg=dlg.m_close_dlg; m_function=dlg.m_function; } } } }