用msflexgrid控件设置宽度,坐标问题! 我在程序中使用msflexgrid控件调用行列宽度的函数SetColWidth(行号,大小),SetRowHeight(列号,大小),但是控件的大小非象素坐标,发现是一种Twips坐标,请问如何与象素坐标转换!拜谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 转载一下别人的原话:a TWIP is 1/20 of a point and 1/1440 of an inch, the conversion between twips and pixels is done as follows:Pixels=TWIPS*pixelsperinch/1440 是的。1象素=20twips.我原先也用了这个控件。我以前的部分程序是这样的: long lRow = m_Points.GetRowSel();//m_Points就是CMSFlexGrid类型 long lCol = m_Points.GetColSel(); // MSFlexGrid 控件的函数的长度单位是"缇(twips)", //需要将其转化为像素,1440 缇 = 1 英寸 CDC* pDC =GetDC(); int nTwipsPerDotX = 1440 / pDC->GetDeviceCaps(LOGPIXELSX) ; int nTwipsPerDotY = 1440 / pDC->GetDeviceCaps(LOGPIXELSY) ; // long y = m_Points.GetRowPos(lRow)/nTwipsPerDotY; long x = m_Points.GetColPos(lCol)/nTwipsPerDotX; long width = m_Points.GetColWidth(lCol)/nTwipsPerDotX+1; long height = m_Points.GetRowHeight(lRow)/nTwipsPerDotY+1; CDC* pDC = GetDC(); m_nLogX = pDC->GetDeviceCaps(LOGPIXELSX); m_nLogY = pDC->GetDeviceCaps(LOGPIXELSY);pDC->SetWindowOrg(CPoint(x0*m_nLogX/1440,y0*m_nLogY/1440));//设置相对坐标原点ReleaseDC(pDC);MoveWindow(((m_fgrid.GetCellLeft() - x0+m_fgrid.GetCellHeight()) * m_nLogX)/1440, ((m_fgrid.GetCellTop() - y0+m_fgrid.GetCellHeight()) * m_nLogY)/1440, (m_fgrid.GetCellWidth()* m_nLogX)/1440, (m_fgrid.GetCellHeight()* m_nLogY)/1440, FALSE);//x0和y0的值如下:m_fgrid.SetRow(0);m_fgrid.SetRow(0);x0=m_fgrid.GetCellLe();//y0=m_fgrid.GetCellTop() ;x0和y0是相对原点的象素坐标 n个矩形碰撞问题 C++里面怎么取整 请问这样的界面怎么做 VC MFC 'IHTMLControlElement' : redefinition,CHtmlView和ado冲突怎么解决了? 散分:程序模拟鼠标输入有几种方法? 初学都,求大家帮助,关于消息映射 宏的理解,在线等,在线等啦哈 如何用vc和MTS开发多层数据库应用系统(参与有分)请各位高手指点 用MFC怎么可以加个数组到类里去 怎么检测当前是否连上因特网? 怎样实现回调? AfxStd.h问题总结 欢迎跟贴 如何实现授权运行(象商业数据库那种)
a TWIP is 1/20 of a point and 1/1440 of an inch, the conversion between twips and pixels is done as follows:Pixels=TWIPS*pixelsperinch/1440
我以前的部分程序是这样的:
long lRow = m_Points.GetRowSel();//m_Points就是CMSFlexGrid类型
long lCol = m_Points.GetColSel();
// MSFlexGrid 控件的函数的长度单位是"缇(twips)",
//需要将其转化为像素,1440 缇 = 1 英寸
CDC* pDC =GetDC();
int nTwipsPerDotX = 1440 / pDC->GetDeviceCaps(LOGPIXELSX) ;
int nTwipsPerDotY = 1440 / pDC->GetDeviceCaps(LOGPIXELSY) ;
//
long y = m_Points.GetRowPos(lRow)/nTwipsPerDotY;
long x = m_Points.GetColPos(lCol)/nTwipsPerDotX;
long width = m_Points.GetColWidth(lCol)/nTwipsPerDotX+1;
long height = m_Points.GetRowHeight(lRow)/nTwipsPerDotY+1;
m_nLogX = pDC->GetDeviceCaps(LOGPIXELSX);
m_nLogY = pDC->GetDeviceCaps(LOGPIXELSY);
pDC->SetWindowOrg(CPoint(x0*m_nLogX/1440,y0*m_nLogY/1440));//设置相对坐标原点
ReleaseDC(pDC);
MoveWindow(((m_fgrid.GetCellLeft() - x0+m_fgrid.GetCellHeight()) * m_nLogX)/1440,
((m_fgrid.GetCellTop() - y0+m_fgrid.GetCellHeight()) * m_nLogY)/1440,
(m_fgrid.GetCellWidth()* m_nLogX)/1440,
(m_fgrid.GetCellHeight()* m_nLogY)/1440, FALSE);
//x0和y0的值如下:m_fgrid.SetRow(0);m_fgrid.SetRow(0);x0=m_fgrid.GetCellLe();
//y0=m_fgrid.GetCellTop() ;x0和y0是相对原点的象素坐标