Usage of Savedc and Restoredc in Tcanvas

zhaozj2021-02-16  50

Savedc and Restoredc in Tcanvas

Summary: This article shows how to properly use Savedc and Restoredc in Tcanvas. The author is Vyatcheslav BaraNov.

Windows GDI functions "Savedc" and "Restoredc" can save and restore device scene status. However, the Tcanvas class does not package these two functions. However, these functions are very necessary for recovery equipment scenarios. For example, when calling an INTERSECTCLIPRECT function, a change in the shear area in an article.

The problem has two questions in Tcanvas. There are two issues using Savedc and Restoredc.

The first problem is that the device scene status will be in line with the Tcanvas state after calling Restore. The second question appears in Win9x. The problem occurs when calling the Savedc and RESTOREDC functions, when Savedc has not deleted Savedc, selecting GDI objects (Font, Pen or Brush) in the device scenario. This is a universal shortcoming in Win9x programs. .

The solution solves the first question, which is the REFRESH function of Tcanvas after restorec. The Refresh method can convert the device scene back to the default state (using the selected storage object) and set Tcanvas to cancel the selected state. Therefore, the real status of the device scene and the Tcanvas state correspond to each other.

There is a difficulty of solving the second problem. It is important to store Tcanvas's Handle property values ​​into an additional variable so that we can call Tcanvas's refresh method. At this time we can call this additional variable as the DC parameter to call the Savedc function.

The Refresh method will set the device scene to the default state. This additional variable can be stored in this default status.

The following code demonstrates the general usage of Savedc and Restoredc: HDC DC; int SaveIndex;

DC = canvas-> handle; canvas-> refresh (); SaveIndex = savedc (dc);. // Some calls to Tcanvas .... Restoredc (DC, SaveIndex); canvas-> refresh (); / / Some calls to Tcanvas ...

More information can be found in the following site: http://www.mblab.by.ru/

转载请注明原文地址:https://www.9cbs.com/read-28277.html

New Post(0)