首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

MFC程序重绘有关问题

2013-07-04 
MFC程序重绘问题MFC程序运行过程中,如果切换到别的程序,在程序面前来回拖动,那么MFC程序不能够实现及时的

MFC程序重绘问题
MFC程序运行过程中,如果切换到别的程序,在程序面前来回拖动,那么MFC程序不能够实现及时的重绘。这是为什么??

MFC程序中加载了一张整个程序的背景图片,还有一个picture控件,picture控件在程序中加载了一张位图。onpaint中代码:

CPaintDC dc(this); // 用于绘制的设备上下文
CRect rect1;
GetClientRect(rect1);
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
CBitmap bkbitmap;
bkbitmap.LoadBitmapA(IDB_BITMAP4);
BITMAP bitmap;
bkbitmap.GetBitmap(&bitmap);
CBitmap* cbitmapOld = dcMem.SelectObject(&bkbitmap);
dc.StretchBlt(0, 0, rect1.Width(), rect1.Height(), &dcMem, 0, 0, bitmap.bmWidth, bitmap.bmHeight, SRCCOPY);
dcMem.DeleteDC();


onpaint中加载了背景图片,picture控件中位图加载在代码中实现。 MFC onpaint 重绘
[解决办法]
OnPaint中每次都加载图片?这设计效率太低了吧,加载一次,在OnPaint中直接画嘛。不能实现重绘?来回拖动 这个应该会自动重绘吧
[解决办法]
引用:
我想的方法是在onactivate事件中设了一个变量来判断,这样只有在回到程序界面的时候才重新加载picture控件的位图,但是这样也不能解决在程序前面拖动别的程序(如:我的电脑)时程序的重绘

repaint is needed, but reload is not.
[解决办法]
引用:
MSDN98\SAMPLES\VC98\MFC\TUTORIAL\SCRIBBLE\STEP1~7\*.*
什么意思啊。。。。

搜索下载安装MSDN98
然后老老实实按照MSDN里面的步骤一步一步学习SAMPLES\VC98\MFC\TUTORIAL\SCRIBBLE\STEP1~7

SCRIBBLE: Illustrates Use of Foundation Class Libraries

Click to open or copy STEP1

Click to open or copy STEP2

Click to open or copy STEP3

Click to open or copy STEP4

Click to open or copy STEP5

Click to open or copy STEP6

Click to open or copy STEP7

SCRIBBLE is the tutorial sample application discussed in Visual C++? Tutorials. The SCRIBBLE sample directory has seven subdirectories that correspond to different steps in the tutorial. Each subdirectory contains the complete sources for a given step.

SCRIBBLE provides simple illustrations of a wide breadth of MFC features. Step 1 through Step 6 of theScribble Tutorial give the best introduction to the following framework features. 

Application objects


Documents, views, and document templates


Commands, message maps, and command user interface updating


MDI (multiple document interface) frame and child windows


Toolbars and status bars


Update hints from documents to views


Dialogs, data exchange, and validation




Scroll view


Splitter window


Printing and print preview


Context-sensitive Help 
Refer to other samples for illustrations of advanced use of the above features, and for illustrations of many other features not covered in the tutorial.

Step 7,Creating an OLE Server, of the Scribble Tutorial adds another step to the development of the SCRIBBLE application by introducing OLE Visual Editing server functionality.

……

热点排行