GDI (Graphical Device Interface):
It contains several
functions, data type, structure and macro. GDI provide function to draw line
rectangle, image, GDI also supports colour capability.
The GDI functions:
i.
Functions that get (create) and
release (destroy) a device context.
ii.
Functions that obtain information
about the device context.
iii.
Function that draw something.
iv.
Function that work with GDI Object.
TextOut:
TextOut(hdc,x,y,string,iLength);
To point client area of
window, we use windows “Graphical Device Interface” (GDI) functions for writing
text string, rectangle, ellipse, begin point & end point to the client area
of window.
For e.g.:
TextOut(hdc,x,y,PSText,iLength);
I.
PSText:
The PSText argument is a pointer to the character string.
II.
iLength:
The length is a length of the string in character.
III.
x,y:
The x and y define the starting position of the character
string in the client area.
IV.
hdc:
The hdc argument is a “handle to a device context”.
The GDI Primitive:
1. Line
& Curve:
To draw any shape in the system area, we use line and curve
for rectangle, arc, ellipse these are the examples.
2. Filled
area:
Whenever a series of line or curve enclose an area, we can
fill it with current GDI Brush Object.
3. Bitmap:
A bitmap is a rectangular array of bits.
4. Text:
This is not very easy to draw a text in graphics. Windows 3.1
GDI began supporting fonts.
Some other GDI functions:
Rectangle(hdc,x,y,x1,y1)
Ellipse(hdc,left,iTop,Right,Bottom)
RoundRect(hdc,left,top,right,bottom,width,height)
SetTextColor(hdc,RGB(0,0,0))
SetBkColor(hdc,RGB(0,0,0))
Device Context:
The GDI function always contains the handle to the device
context. The device context is also referred as DC. The device context is a
data structure associated with particular window.
The window application generally use two method for getting a
device context handle for painting screen –
1. Case
WM_PAINT:
hdc=BeginPaint(hwnd,
&PS);
[Use
GDI Function]
EndPoint(hwnd,
&PS);
break;
2. Case
WM_PAINT:
hdc=GetDC(hwnd);
[Use
GDI Function]
ReleaseDC(hwnd,hdc);
break;
Child Window Control:
When
one window has control in the form child window, these components of the
windows are called as child window control. The various control can be placed
on the main window, these control build user friendliness in the program. These
child window control respond to mouse & keyboard events.
0 comments:
Post a Comment