|
제라툴입니다.
HDC는 Device Context Handle입니다. 보통 화면상에 어떠한 것을 그리기 원할때
속성값으로 많이 주어지게 됩니다.
When you want to draw on a graphics output device such as the screen or printer, you must first obtain a handle to a device context (or DC). In giving your program this handle, Windows is giving you permission to use the device. You then include the handle as an argument to the GDI functions to identify to Windows the device on which you wish to draw.
The device context contains many "attributes" that determine how the GDI functions work on the device. These attributes allow GDI functions to have just a few arguments, such as starting coordinates. The GDI functions do not need arguments for everything else that Windows needs to display the object on the device. For example, when you call TextOut, you need specify in the function only the device context handle, the starting coordinates, the text, and the length of the text. You don't need to specify the font, the color of the text, the color of the background behind the text, or the intercharacter spacing. These are all attributes that are part of the device context. When you want to change one of these attributes, you call a function that does so. Subsequent TextOut calls to that device context use the new attribute.
---- Programming Windows by Charles Petzold ----
페졸드 아저씨 책의 일부인데 DC에 관해서 간략히 설명하고 있습니다. 한번읽어 보세요..^^
HPEN 은 pen의 handle 입니다. 쉽게 말하면 HPEN은 Drawing 시 어떤 pen으로 Draw할것이냐를 설정해 주는 값입니다.^^
아래 글도 페졸드 아저씨 책에 있는 글인데요. 설명이 넘 잘되서 제가 설명해 드릴 부분이 없군요
^^
Using Stock Pens
When you call any of the line-drawing functions that I've discussed in this section, Windows uses the "pen" currently selected in the device context to draw the line. The pen determines the line's color, its width, and its style, which can be solid, dotted, or dashed. The pen in the default device context is called BLACK_PEN. This pen draws a solid black line with a width of one pixel. BLACK_PEN is one of three "stock pens" that Windows provides. The other two are WHITE_PEN and NULL_PEN. NULL_PEN is a pen that doesn't draw. You can also create your own customized pens.
In your Windows programs, you refer to pens by using a handle. The Windows header file WINDEF.H defines the type HPEN, a handle to a pen. You can define a variable (for instance, hPen) using this type definition:
HPEN hPen ;
You obtain the handle to one of the stock pens by a call to GetStockObject. For instance, suppose you want to use the stock pen called WHITE_PEN. You get the pen handle like this:
hPen = GetStockObject (WHITE_PEN) ;
Now you must "select" that pen into the device context:
SelectObject (hdc, hPen) ;
Now the white pen is the current pen. After this call, any lines you draw will use WHITE_PEN until you select another pen into the device context or release the device context handle.
Rather than explicitly defining an hPen variable, you can instead combine the GetStockObject and SelectObject calls in one statement:
SelectObject (hdc, GetStockObject (WHITE_PEN)) ;
If you then want to return to using BLACK_PEN, you can get the handle to that stock object and select it into the device context in one statement:
SelectObject (hdc, GetStockObject (BLACK_PEN)) ;
SelectObject returns the handle to the pen that had been previously selected into the device context. If you start off with a fresh device context and call
hPen = SelectObject (hdc, GetStockobject (WHITE_PEN)) ;
the current pen in the device context will be WHITE_PEN and the variable hPen will be the handle to BLACK_PEN. You can then select BLACK_PEN into the device context by calling
SelectObject (hdc, hPen) ;
---- Programming Windows by Charles Petzold ----
---- 아름다운 청년 제라툴 ----
|