请问高手们,ScrollView中的OnPrepareDC()到底应该怎么用啊? 我现在在一个视图上面绘制一个30000个像素长的线我使用ScrollToPosition来滚动视图但是每当走到1500个像素的时候会出错,而且是在OnprepareDC()中挂掉的高手们,何解啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 this->SetScrollSizes(MM_TEXT,CSize(30000,0),sizepage,sizeline); 我这里所说的出错就是说坐标好像发生了错乱,本来应该是客户上面的坐标,好像跑到屏幕上面去了,是不是应该重构一下OnprepareDC()? 是你自己调用了OnPrepareDC吗?最好不要调用 我如果不自己调用的话,那怎么能在视图上面画出30000像素长的线?pc->moveto();pc->lineto();怎么写? 检查线的X坐标,如果到最右边的时候:ScrollToPosition(point);InvalidateRect(NULL,TRUE);高手,还是不行啊重画出画不出来 如果使用onpreparedc()的话,那就很自然的绘出了这些线,但是直接重画的话,好像出不来使用DC没有什么要求吧?其实可以用STATIC重写来做出一个窗口出来,然后使用setwindowpos来设置窗口坐标,这样看起来也是滚动。在SCROLLVIEW中为什么不能用onpreparedc()啊?现在真的搞不定这个东西了,找不到这方面的文章,还望高手相救! void CImageView::OnPaint() { //launching flag=false; CPaintDC dc(this); //CDC *dc=GetDC();// device context for painting //OnPrepareDC(&dc); // TODO: Add your message handler code here CRect rect; GetClientRect(&rect); rect.right=30000; //background dc.FillSolidRect(CRect(0,0,30000,rect.bottom),RGB(240,240,240));// int x=rect.left;// int y=rect.top+30; int x=0; int y=30; int drawy=y-4; HPEN hPen1,hPen2,hPenOld; hPen1=CreatePen(PS_SOLID,1,RGB(100,100,100)); hPen2=CreatePen(PS_SOLID,1,RGB(210,210,210)); hPenOld=(HPEN)dc.SelectObject(hPen1); dc.MoveTo(x,drawy); dc.LineTo(30000,drawy); drawy+=21; hPenOld=(HPEN)dc.SelectObject(hPen2); for(int i=1;i<=16;i++) { dc.MoveTo(x,drawy); dc.LineTo(30000,drawy); drawy+=21; } for(int drawx=0;drawx<=30000;) { if(drawx%250==0) { char temp[4]; sprintf(temp,"%d",drawx/250); hPenOld=(HPEN)dc.SelectObject(hPen1); dc.TextOut(drawx,0,temp); } else { hPenOld=(HPEN)dc.SelectObject(hPen2); } dc.MoveTo(drawx,rect.top); dc.LineTo(drawx,rect.bottom); drawx+=50; } dc.SelectObject(hPenOld); HPEN hPen,hPenOld2; hPen=CreatePen(PS_SOLID,2,RGB(0,0,0)); hPenOld2=(HPEN)dc.SelectObject(hPen); dc.MoveTo(firstx,firsty); dc.LineTo(firstx,firstz); CRect clientrect; GetClientRect(&clientrect); //判断指示线是否已经到了视图的最右边 if(firstx>=(clientrect.right+scrollpoint)) { scrollpoint=clientrect.right+scrollpoint; POINT point; point.x=firstx; point.y=0; ScrollToPosition(point); InvalidateRect(CRect(firstx,0,clientrect.right,clientrect.bottom),TRUE); } dc.SelectObject(hPenOld2); //drawline1 int x1=x+50; int y1=y; int x2=2000; int y2=y+10; hPen1=CreatePen(PS_SOLID,1,RGB(255,255,255)); hPen2=CreatePen(PS_SOLID,3,RGB(100,100,100)); CRect rectpaintchannel1(x1,y1,x2,y2); dc.FillSolidRect(rectpaintchannel1,RGB(230,0,0)); hPenOld=(HPEN)dc.SelectObject(hPen1); dc.MoveTo(x1,y1+2); dc.LineTo(x2,y1+2); hPenOld=(HPEN)dc.SelectObject(hPen2); dc.MoveTo(x1,y2-2); dc.LineTo(x2,y2-2); dc.SelectObject(hPenOld); } 其中我的firstx的值在一个wm_timer中加一 读access,请帮忙看看~! win32下怎样才能使文本框中输入的数字 字符串 变成数值然后赋值给float类型 对话框中的按钮状态改变的问题 请问三维图像格式问题 用VC怎么调用C++ Builder 写的动态库呀? VS2010编辑框中字体获取处理问题。 关于camshift跟踪的一点思路问题 有关数据类型转换的问题... *****急救******在VC里怎么具体的使用MS的TTS语音引擎!能发音就行! NiceFeather: 到主页在线聊天聊聊如何? 各位:请教一个问题! 参与者有分,如何删除Doc而只要Frame/View?
pc->lineto();怎么写?
:
ScrollToPosition(point);
InvalidateRect(NULL,TRUE);高手,还是不行啊重画出画不出来
其实可以用STATIC重写来做出一个窗口出来,然后使用setwindowpos来设置窗口坐标,这样看起来也是滚动。在SCROLLVIEW中为什么不能用onpreparedc()啊?现在真的搞不定这个东西了,找不到这方面的文章,还望高手相救!
{
//launching
flag=false;
CPaintDC dc(this);
//CDC *dc=GetDC();// device context for painting
//OnPrepareDC(&dc);
// TODO: Add your message handler code here
CRect rect;
GetClientRect(&rect);
rect.right=30000;
//background
dc.FillSolidRect(CRect(0,0,30000,rect.bottom),RGB(240,240,240));
// int x=rect.left;
// int y=rect.top+30;
int x=0;
int y=30;
int drawy=y-4;
HPEN hPen1,hPen2,hPenOld;
hPen1=CreatePen(PS_SOLID,1,RGB(100,100,100));
hPen2=CreatePen(PS_SOLID,1,RGB(210,210,210));
hPenOld=(HPEN)dc.SelectObject(hPen1);
dc.MoveTo(x,drawy);
dc.LineTo(30000,drawy);
drawy+=21;
hPenOld=(HPEN)dc.SelectObject(hPen2);
for(int i=1;i<=16;i++)
{
dc.MoveTo(x,drawy);
dc.LineTo(30000,drawy);
drawy+=21;
}
for(int drawx=0;drawx<=30000;)
{
if(drawx%250==0)
{
char temp[4];
sprintf(temp,"%d",drawx/250);
hPenOld=(HPEN)dc.SelectObject(hPen1);
dc.TextOut(drawx,0,temp);
}
else
{
hPenOld=(HPEN)dc.SelectObject(hPen2);
}
dc.MoveTo(drawx,rect.top);
dc.LineTo(drawx,rect.bottom);
drawx+=50;
}
dc.SelectObject(hPenOld);
HPEN hPen,hPenOld2;
hPen=CreatePen(PS_SOLID,2,RGB(0,0,0));
hPenOld2=(HPEN)dc.SelectObject(hPen);
dc.MoveTo(firstx,firsty);
dc.LineTo(firstx,firstz);
CRect clientrect;
GetClientRect(&clientrect);
//判断指示线是否已经到了视图的最右边
if(firstx>=(clientrect.right+scrollpoint))
{
scrollpoint=clientrect.right+scrollpoint;
POINT point;
point.x=firstx;
point.y=0;
ScrollToPosition(point);
InvalidateRect(CRect(firstx,0,clientrect.right,clientrect.bottom),TRUE);
}
dc.SelectObject(hPenOld2);
//drawline1
int x1=x+50;
int y1=y;
int x2=2000;
int y2=y+10;
hPen1=CreatePen(PS_SOLID,1,RGB(255,255,255));
hPen2=CreatePen(PS_SOLID,3,RGB(100,100,100));
CRect rectpaintchannel1(x1,y1,x2,y2);
dc.FillSolidRect(rectpaintchannel1,RGB(230,0,0));
hPenOld=(HPEN)dc.SelectObject(hPen1);
dc.MoveTo(x1,y1+2);
dc.LineTo(x2,y1+2);
hPenOld=(HPEN)dc.SelectObject(hPen2);
dc.MoveTo(x1,y2-2);
dc.LineTo(x2,y2-2);
dc.SelectObject(hPenOld);
}