OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Device-context Operators

TDC provides one conversion operator, HDC, that lets you return the handle to the device context of your particular TDC or TDC-derived object.

This operator is most often invoked implicitly. When you use a TDC object where you would normally use an HDC, such as in a function call or the like, the compiler tries to find a way to cast the object to the required type. Thus it uses the HDC conversion operator even though it is not explicitly called.

For example, suppose you want to create a device context in memory that is compatible with the device associated with a TDC object. You can use the CreateCompatibleDC Windows API function to create the new DC from your existing TDC object:

HDC GetCompatDC(TDC& dc, TWindow& window)
{
{
window.MessageBox("Couldn't create compatible device context!",
"Failure",
return NULL;
}
else return compatDC;
}

Notice that CreateCompatibleDC takes a single parameter, an HDC. Thus the function parameter dc is implicitly cast to an HDC in the CreateCompatibleDC call.

See Also