Код:
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
Dim $W_HEIGHT = 300, $W_WIDTH = 500, $TITLE = "Graphic Edge Demo"
$MAIN_WINDOW = GUICreate($TITLE, $W_WIDTH, $W_HEIGHT)
GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 20, 20, 200, 50)
$hctrl = _GUICtrlCreateGroupBox("My Group", 25, 25, 2, 190, 40)
GUICtrlSetColor($hctrl, 0xFF0000)
$nEXIT = GUICtrlCreateButton("E&xit", 310, $W_HEIGHT - 40, 120, 25)
GUISetState(@SW_SHOW, $MAIN_WINDOW)
While 1
Switch GUIGetMsg()
Case $nEXIT, $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
;===============================================================================
;
; Description: _GUICtrlCreateEdge "Create an edge line from a label"
; Parameter(s): $i_x - left
; $i_y - top
; $i_width - width
; $i_height - height
; $v_color - color
; Requirement: none
; Return Value(s): none
; User CallTip: none
; Author(s): layer
; Note(s): all the following were inspired by this simple function
;
;===============================================================================
Func _GUICtrlCreateEdge($i_x, $i_y, $i_width, $i_height, $v_color)
GUICtrlCreateGraphic($i_x, $i_y, $i_width, $i_height, 0x1000)
GUICtrlSetBkColor(-1, $v_color)
EndFunc ;==>_GUICtrlCreateEdge
;===============================================================================
;
; Description: _GUICtrlCreateEdgeBox
; Parameter(s): $i_x - left
; $i_y - top
; $i_weight - line weight
; $i_width - width
; $i_height - height
; $v_color - color
; Requirement: GUICtrlCreateEdge
; Return Value(s): none
; User CallTip: none
; Author(s): Gary Frost (gary.frost@arnold.af.mil)
; Note(s):
;
;===============================================================================
Func _GUICtrlCreateEdgeBox($i_x, $i_y, $i_weight, $i_width, $i_height, $v_color)
; left vertical line
_GUICtrlCreateEdge($i_x, $i_y, $i_weight, $i_height, $v_color)
; top horizontal line
_GUICtrlCreateEdge($i_x, $i_y, $i_width, $i_weight, $v_color)
; right vertical line
_GUICtrlCreateEdge($i_width + $i_x - 1, $i_y, $i_weight, $i_height, $v_color)
; bottom horizontal line
_GUICtrlCreateEdge($i_x, $i_height + $i_y - 1, $i_width + $i_weight - 1, $i_weight, $v_color)
EndFunc ;==>_GUICtrlCreateEdgeBox
Func _GUICtrlCreateGroupBox($sText, $i_x, $i_y, $i_weight, $i_width, $i_height, $v_color = -1)
Local $hdc = _WinAPI_GetDC(0)
Local $tSize = _WinAPI_GetTextExtentPoint32($hdc, $sText)
If ($v_color == -1) Then $v_color = 0x000000
; left vertical line
_GUICtrlCreateEdge($i_x, $i_y, $i_weight, $i_height, $v_color)
Local $h_ctlid = GUICtrlCreateLabel($sText, $i_x + 4, $i_y - (DllStructGetData($tSize, "Y") / 2))
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
; top horizontal line
_GUICtrlCreateEdge($i_x + DllStructGetData($tSize, "X") - 4, $i_y, $i_width - DllStructGetData($tSize, "X") + 4, $i_weight, $v_color)
; right vertical line
_GUICtrlCreateEdge($i_width + $i_x - 1, $i_y, $i_weight, $i_height, $v_color)
; bottom horizontal line
_GUICtrlCreateEdge($i_x, $i_height + $i_y - 1, $i_width + $i_weight - 1, $i_weight, $v_color)
Return $h_ctlid
EndFunc ;==>_GUICtrlCreateGroupBox