function that looks a little different, one of the following reasons should
explain the change to you:
■ API functions that take an object handle as a parameter often omit the
handle in the ObjectWindows version. The TGdiObject base object
maintains a handle to each object. The ObjectWindows version then uses
that handle when passing the call on to Windows. For example, when
selecting an object in a device context, you would normally use the
SelectObject API function, as shown here:
void SelectPen(HDC& hdc, HPEN& hpen)
HPEN hpenOld;
hpenOld = SelectObject(hdc, hpen);
// Do something with the new pen.
.
.
.
// Now select the old pen again.
SelectObject(hdc, hpenOld);
}
The ObjectWindows version of this function is encapsulated in the TDC
class, which is derived from TGdiObject. The following example shows
how the previous function would appear in a member function of a
TDC-derived class. Notice the difference between the two calls to
SelectObject:
void SelectPen(TDC& dc, TPEN& pen)
dc.SelectObject(pen);
// Do something with the new pen.
.
.
.
// Now select the old pen again.
dc.RestorePen();
}
■ ObjectWindows GDI functions usually substitute an ObjectWindows
type in place of a Windows type:
● Windows API functions use individual parameters to specify x and y
coordinate values; ObjectWindows GDI functions use TP int objects.o
● Windows API functions use RECT structures to specify a rectangular
area; ObjectWindows GDI functions use TRect objects.
● Windows API functions use RGN structures to specify a region;
ObjectWindows GDI functions use TRegion objects.
● Windows API functions take HLOCAL or HGLOBAL parameters to
pass an object that doesn’t have a predefined Windows structure;
ObjectWindows GDI functions use references to ObjectWindows
objects.
Chapter 13, Graphics objects
289