Syntax
DrawBoxStroke(x.d, y.d, Width.d, Height.d, Color.l, Opacity.f=1)
Description
Draws the outline (stroke) of a rectangle at the specified position and size using the given color and opacity. The appearance of the stroke (width, dash style, corners, caps) is determined by the current stroke settings defined by DrawSetStroke().
Parameters
x.d
The horizontal coordinate of the rectangle's top-left corner in
device-independent pixels (DIPs).
y.d
The vertical coordinate of the rectangle's top-left corner in DIPs.
Width.d
The width of the rectangle in DIPs.
Height.d
The height of the rectangle in DIPs.
Color.l
The color of the stroke in RGB format (e.g., using
RGB(r, g, b)).
Opacity.f (optional)
The opacity of the stroke, ranging from 0.0 (fully
transparent) to 1.0 (fully opaque). Default is 1.0.
Return Value
This command does not return a value. It returns internally if Width, Height, or Opacity are zero or less.
Remarks
The coordinates and dimensions are specified in DIPs but are converted internally to physical pixels based on the current output's DPI and aligned to the pixel grid before drawing. The stroke is drawn using an internal solid color brush. Use DrawSetStroke() before calling this function to customize the line's appearance.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
Procedure DrawHandler(Window, EventType, *EventData.PG_EventDraw, *UserData)
DrawClear(RGB(255, 255, 255), 1) ; White background
; Draw a simple box outline (default 1px stroke)
DrawBoxStroke(20, 20, 100, 80, RGB(255, 0, 0))
; Set stroke to 5px wide, dashed, with round corners/ends
DrawSetStroke(5, #PG_Stroke_Dash | #PG_Stroke_RoundCorner | #PG_Stroke_RoundEnd)
; Draw a thick dashed box outline with 50% opacity
DrawBoxStroke(150, 50, 120, 100, RGB(0, 0, 255), 0.5)
; Restore default stroke for subsequent drawing
DrawSetStroke(1)
EndProcedure
MyWindow = CreateWindow(0, 0, 300, 200, "DrawBoxStroke Example")
If MyWindow
AddEventHandler(MyWindow, #PG_Event_Draw, @DrawHandler())
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()
See Also
DrawSetStroke, DrawBox, DrawBoxStrokeFill, DrawRoundBoxStroke, BeginDraw, EndDraw
Supported OS
Windows, Linux