如何为此应用程序处理WM_PAINT? [英] How do I handle WM_PAINT for this my application?

查看:60
本文介绍了如何为此应用程序处理WM_PAINT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继续发现为我的应用程序处理WM_PAINT是一个挑战.

我通过使用BitBlt从内存兼容的DC复制到窗口DC进行重画,如下所示.

I have continue to find handling WM_PAINT for my application a challenge.

I repaint by copying from a memory compartible DC to window DC using BitBlt a follows.

case WMN_PAINT:
hdc = BeginPaint(hWnd,&ps);
BitBlt(hdc,ps.rcPaint.left,ps.rcPaint.top,
ps.rcPaint.right-ps.rcPaint.left,
ps.rcPaint.bottom - ps.rcPaint.top,memDC,ps.rcPaint.left, + iHpos, ps.rcPaint + iVpos,SRCCOPY);
EndPaint(hWnd,&ps);


其中memDC-记忆兼容的DC,
iHpos = Hprizontal;滚动位置,iVpos-垂直滚动位置


我从缓冲区写入内存DC memDC,并允许系统从memDC复制到窗口.

最大的问题是,一旦iVpos和iHpos超过内存DC的大小,正常的显示就会崩溃.

我只能处理文本或位图的重绘,但是一旦它以DC i9n不可预测的方式混合了文本和位图,我最终将使用这种内存DC方法.


我的缓冲区的组织方式与此类似


where memDC - memmory compartible DC,
iHpos = Hprizontal; scroll position, iVpos - verticical scroll position


I write from a buffer to the memeory DC memDC and allow the system to copy from the memDC to window.

The big problem is that once iVpos and iHpos exceed the size of the memory DC proper display collpses.

I can handle repaint for text only or bitmap only well, but once it is a mixture of text and bitmap rendered on a DC i9n unpredictable manner I end up using this memory DC approach.


My buffer is organised in a manner similar to this

class Buffer
{ 
   vector<int> iPageCount;
   vector<int> icharCount;
   vector<tchar> chChar;
   vector<int> icharXpos;
   vector<int> icharYPos;

  vector<int> iImageCount;
  vector<string> sImagePath;
  vector<int> iImageXpos;
  vector<int> iImageYpos;
};


我试图一页一页地渲染,但同样的问题是面孔.我该如何解决内存DC极限超出问题.

Internet Explorer,MS和其他人如何从滚动的角度处理重画.

问题是重新粉刷,滚动和内存DC问题.

拜托,我该如何解决这个问题


我真的不知道上述方法称为double bufferig.我只使用一个内存DC.什么是双重缓冲?如何使用?



有人说如何使用SetWindowOrg解决此问题,如何完成?


I attempted to do a page by page rendering but the same problem was faces. how do I tackle this issue of memmory DC limit exeeding problem.

How does internet explorer, MS word amd others handle repainting from the view point of scrolling.

The problem is a problem of repaint, scrolling and memory DC.

Please, how do I solve this problem


I really don''t know that the above method is called double bufferig. I use only one memory DC. What really is the double buffering? How is it used?



Someone said how can use SetWindowOrg to solve this problem, how is it done?

推荐答案

如您所知,通过内存DC进行的双缓冲最多只能使用一个.一定的限制.如果您的虚拟绘图平面变得非常大,则此技术需要越来越多的内存来缓冲您的全部内容.

使用API​​调用ScrollWindow滚动效果最佳,此外还绘制窗口的未覆盖部分.

只要您的全部内容不超过两个窗口的宽度或高度,通过大缓冲位图中的BitBlt-ing绘制未覆盖的部分都是非常有效的.

对于较大的内容,您可以按需按块生成内存位图,并从它们中发现未覆盖的部分.这需要软件中的一些缓冲区管理代码.作为替代方案,您可能希望脱离双缓冲方法,仅按需生成WM_PAINT中的内容,并且仅生成滚动机制所需的清单.这样效率不高,但实现起来却容易得多.

浏览器通常使用更复杂的方法和完整的双缓冲.但是不要认为它们的代码简单而紧凑.
As you have found out, double buffering via a memory DC works only up to a certain limit. If your virtual drawing plane becomes very big, this technique requires increasingly more memory to buffer your entire contents.

Scrolling works best by using the API call ScrollWindow and in addition painting the uncovered part of the window.

As long as your entire contents is no more than a couple of window widths or heights, it is very efficient to draw the uncovered part by BitBlt-ing from your big buffered bitmap.

For larger contents you can generate the memory bitmap in chunks on-demand and feed the uncovered parts from their. This requires quite some buffer management code in your software. As alternative, you might want to depart from the double-buffering approach and generate the contents in WM_PAINT just on demand and only the slips that are needed by the scrolling mechanism. This is not as efficient, but a lot easier to implement.

Browsers use generally the more complicated approach with full double buffering. But don''t think that their code is easy and compact.


这篇关于如何为此应用程序处理WM_PAINT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆