The following methods are used to draw rectangles, lines, pixels, and arcs in a device context. See GetWindowDC, GetDC, and GetButtonDC for how to retrieve a device context. A pen and a brush can be activated using ObjectToDC before invoking the drawing methods.
Note: Because the pixel values include the title bar in a dialog it is easier to define a button filling the window, and then draw on the button.
>>-aDialogControl~Rectangle(--dc--,--x--,--y--,--x2--,--y2--+-----------+--)->< +-,--"FILL"-+
The Rectangle method draws a rectangle to the given device context. The appearance is determined by the graphics objects currently active in the device context. The active pen draws the outline and, optionally, the active brush fills the inside area. The default pen is thin black and the default brush is white.
The arguments are:
The device context.
The position of the upper left corner of the rectangle, in pixels.
The position of the lower right corner.
The rectangle is filled with the active brush.
The following example draws a red rectangle filled with yellow, surrounded by a black rectangle:
dc = self~getButtonDC(100) brush = self~createBrush(15) /* yellow */ pen = self~createPen(10,"solid",13) /* thick red */ oldb = self~objectToDC(dc,brush) oldp = self~objectToDC(dc,pen) self~Rectangle(dc, 50, 50, 200, 150, "FILL") self~objectToDC(dc,oldp); self~deleteObject(pen) self~objectToDC(dc,oldb); self~deleteObject(brush) self~Rectangle(dc, 40, 40, 210, 160) /* default */
>>-aDialogControl~DrawLine(--dc--,--+-------+--,--+-------+--,--toX--,--toY--)->< +-fromX-+ +-fromY-+
The DrawLine method draws a line within the device context using the active pen.
The arguments are:
The device context.
The starting position, in pixels. If omitted, the previous end point of a line or arc is used.
The target position.
>>-aDialogControl~DrawPixel(--dc--,--x--,--y--,--color--)------><
The DrawPixel method draws a pixel within the device context.
The arguments are:
The device context.
The position, in pixels.
The color number for the pixel. For a list of color numbers, refer to Definition of Terms.
>>-aDialogControl~GetPixel(--dc--,--x--,--y--)-----------------><
The GetPixel method returns the color number of a pixel within the device context.
The arguments are:
The device context.
The position, in pixels.
>>-aDialogControl~DrawArc(--dc--,--x--,--Y--,--x2--,--y2--------> >--+----------------------------------------+--)--------------->< +-,--startx--,--starty--,--endx--,--endy-+
The DrawArc method draws a circle or ellipse on the given device context using the active pen for the outline. The circle or ellipse is drawn within the boundaries of an imaginary rectangle whose coordinates are given. A partial figure can be drawn by giving the end points of two radials. By default, the figure is drawn counterclockwise, but the direction can be modified using SetArcDirection.
The arguments are:
The device context.
The position of the upper left corner of the imaginary rectangle, in pixels.
The position of the lower right corner of the imaginary rectangle, in pixels.
The end points of the starting and ending radials for drawing the figure. A full circle or ellipse is drawn if no start and end are given. Omitted values default to 0. Imaginary radials are drawn from the center to the start and end points. The circle or ellipse is then drawn between the intersections of these lines with the full circle or ellipse.
This example draws a full ellipse and a quarter circle:
dc = self~getButtonDC(100) pen = self~createPen(4,"solid",13) oldp = self~objectToDC(dc,pen) self~drawArc(dc,50,50,200,150) /* full ellipse */ self~drawArc(dc,100,100,150,150, 200,50,75,75) /* quarter circle */ self~objectToDC(dc,oldp); self~deleteObject(pen)
>>-aDialogControl~GetArcDirection(--dc--)----------------------><
The GetArcDirection method returns the current drawing direction for the DrawArc method.
The only argument is:
The device context.
>>-aDialogControl~SetArcDirection(--dc--,--"--+-COUNTERCLOCKWISE-+--"--)->< +-CLOCKWISE--------+
The SetArcDirection method changes the drawing direction for the DrawArc and DrawPie methods.
The arguments are:
The device context.
The new drawing direction.
>>-aDialogControl~DrawPie(--dc--,--x--,--y--,--x2--,--y2--> >--,--startx--,--starty--,--endx--,--endy--)-------------><
The DrawPie method draws a pie of a circle or ellipse on the given device context using the active pen for the outline and the active brush to fill the pie. The circle or ellipse is drawn within the boundaries of an imaginary rectangle whose coordinates are given. The arc is drawn between start and end radials in the direction specified by SetArcDirection.
The arguments are:
The device context.
The position of the upper left corner of the imaginary rectangle, in pixels.
The position of the lower right corner of the imaginary rectangle.
The end points of the two radials (same as for DrawArc).
>>-aDialogControl~FillDrawing(--dc--,--x--,--y--,--color--)----><
The FillDrawing method fills an outline figure in the given device context using the active brush.
The arguments are:
The device context.
The inside starting position for filling the outline figure with the color of the brush, in pixels.
The color number of the outline figure whose inside will be filled. For a list of color numbers, refer to Definition of Terms.
>>-aDialogControl~DrawAngleArc(--dc--,--xs--,--ys--,--x--,--y--> >--,--radius--,--startangle--,--sweepangle--)-----------------><
The DrawAngleArc method draws a partial circle (arc) and a line connecting the start drawing point with the start of the arc on the given device context using the active pen for the outline. The circle is drawn counterclockwise with the given radius between the given angles.
The arguments are:
The device context.
The start draw position, in pixels.
The center of the circle, in pixels.
The radius of the circle, in pixels.
The starting and ending angles for the partial circle in degrees (0 is the x-axis).