SaveDC、RestoreDC - [Daliy APIs]

SaveDC  


保存指定设备上下文环境的当前状态,通过拷贝数据(该数据描述选择的对象和图形模式,比如位图、画笔、调色板、字体、笔、区域、绘图模式、映射模式)到上下文环境堆栈来完成。

This function saves the current state of the specified device context by copying data describing selected objects and graphic modes (such as the bitmap, brush, palette, font, pen, region, and drawing mode) to a context stack. 

原型:

int SaveDC(HDC hdc);

参数:

hdc:要保存的设备上下文环境的句柄。

返回值:

   如果成功,返回值标识保存的设备上下文环境,如果失败,返回零。调用GetLastError获取扩展错误信息。    

说明:

   SaveDC函数可以用来保存设备上下文环境状态的任何数目的实例和保存任何次数。

   一个被保存的状态以后可以用RestoreDc函数进行恢复。

 

RestoreDC 

   

该函数恢复设备上下文环境(DC)到指定状态,该设备上下文环境的恢复是通过使状态信息出栈而进行的。该堆栈由先前调用SaveDC函数时创建的。

原型:

BOOL RestoreDC(HDC hdc, int nSavedDC);

参数:

   hdc:设备上下文环境句柄。

   nSaveDC:指定将要被恢复的设备上下文环境的实例,如果该参数为正,则nSaveDC代表要恢复的设备上下文环境的一个指定实例。如果该参数为负,则nSaveDC代表与当前设备上下文环境有关的一个实例。 比如,-1恢复当前最近保存的状态。

If this parameter is positive, nSavedDC represents a specific instance of the device context to be restored. 

If this parameter is negative, nSavedDC represents an instance relative to the current device context. 

For example, –1 restores the most recently saved state. 

返回值:

如果成功,返回非零;如果失败,返回零。调用GetLastError获取扩展错误信息。

说明:

堆栈可以包含设备上下文环境多个实例的状态信息,如果给定参数指定的状态不在堆栈的顶部,那么RestoreDC就删除栈顶和指定实例之间的所有状态信息。


参考:

互动百科: SaveDC   RestoreDC 

MSDN: SaveDC   RestoreDC 


 

 

posted on 2010-01-20 17:14  listenlisten  阅读(736)  评论(0编辑  收藏  举报

导航