Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   AutoIt (http://forum.oszone.net/forumdisplay.php?f=103)
-   -   Как сделать прозрачный фон для надписи в GUICtrlCreateGroup? (http://forum.oszone.net/showthread.php?t=220476)

МИШАНЧИК 14-11-2011 17:04 1794922

Как сделать прозрачный фон для надписи в GUICtrlCreateGroup?
 
Подскажите пожалуйста, возможно ли при создании GUICtrlCreateGroup наложеной на картинку, сделать так чтоб надпись "Установка" была на прозрачном фоне? Т.е. надпись распологалась прям на картинке, а не на белом фоне?
Код:

$Group1 = GUICtrlCreateGroup("Установка", 8, 8, 352, 95)
GUICtrlSetFont(-1, 9, 400, 0, "Segoe UI")

Если можно пример как это сделать. Заранее большое спасибо.

Creat0R 14-11-2011 17:40 1794958

Код:

#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


МИШАНЧИК 15-11-2011 04:08 1795318

Creat0R, большое спасибо, но я так понимаю что в этом скрипте Вы полностью создаёте горизонтальные и вертикальные линии(подобие линий в GUICtrlCreateGroup)? А нельзя всё-таки как нибудь просто задать прозрачность надписи в стандартной GUICtrlCreateGroup?

Creat0R 15-11-2011 09:00 1795369

Цитата:

Цитата МИШАНЧИК
А нельзя всё-таки как нибудь просто задать прозрачность надписи в стандартной GUICtrlCreateGroup? »

Не думаю.

Я ещё часто использую вот такие самопальные Group:

Код:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

$sImage = @WindowsDir & "\Web\Wallpaper\Windows XP.jpg"
If @OSVersion = "WIN_7" Then $sImage = @WindowsDir & "\Web\Wallpaper\Windows\img0.jpg"

GUICreate("My GUI", 300, 200)

$pic = GUICtrlCreatePic($sImage, 0, 0, 300, 200)
GUICtrlSetState(-1, $GUI_DISABLE)

$group = _GUICtrlCreateGroupEx("Group1", 10, 10, 280, 180, 3, 0x00FF00, 1)

GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func _GUICtrlCreateGroupEx($sText, $iLeft, $iTop, $iWidth, $iHeight, $iLineWidth = 3, $nColor = 0, $iStyle = 0)
    Local $aIDs[2] ;First + Last IDs

    Local $nLabel_Style = $SS_ETCHEDFRAME

    ;1 to able set color for the Group frame
    If $iStyle > 0 Then $nLabel_Style = $SS_SUNKEN

    Local $hDC = _WinAPI_GetDC(GUICtrlGetHandle(GUICtrlCreateLabel($sText, -100, -100)))
    Local $stExtPoint = _WinAPI_GetTextExtentPoint32($hDC, $sText)

    Local $iExtPoint_X = DllStructGetData($stExtPoint, "X") - StringLen($sText) + 5

    GUIStartGroup()

    If $sText <> '' Then
        $aIDs[0] = GUICtrlCreateLabel('', $iLeft + 1, $iTop, 35, $iLineWidth, $nLabel_Style)
        GUICtrlSetBkColor(-1, $nColor)

        GUICtrlCreateLabel('', $iLeft + 35 + $iExtPoint_X, $iTop, $iWidth - 35 - $iExtPoint_X, $iLineWidth, $nLabel_Style)
    Else
        $aIDs[0] = GUICtrlCreateLabel('', $iLeft + 1, $iTop, $iWidth - 2, $iLineWidth, $nLabel_Style)
    EndIf

    GUICtrlSetBkColor(-1, $nColor)

    GUICtrlCreateLabel('', $iLeft + 2, $iTop + 5, $iLineWidth, $iHeight - 4, $nLabel_Style)
    GUICtrlSetBkColor(-1, $nColor)

    GUICtrlCreateLabel('', ($iLeft + $iWidth), $iTop - 3, $iLineWidth, $iHeight - 3, $nLabel_Style)
    GUICtrlSetBkColor(-1, $nColor)

    $aIDs[1] = GUICtrlCreateLabel('', $iLeft + 6, ($iTop + $iHeight) - 5, $iWidth, $iLineWidth, $nLabel_Style)
    GUICtrlSetBkColor(-1, $nColor)

    If $sText <> '' Then
        $aIDs[1] = GUICtrlCreateLabel('  ' & $sText, $iLeft + 35, $iTop - 6)
        GUICtrlSetColor(-1, $nColor)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    EndIf

    Return $aIDs
EndFunc


МИШАНЧИК 16-11-2011 01:47 1796029

Creat0R, подскажите пожалуйста, когда создаем изображение
Код:

GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 20, 20, 200, 50)
рисунок должен находится в соответствующей директории, а нельзя сделать чтоб рисунок после компиляции распологался в исполняемом файле и брался оттуда?

madmasles 16-11-2011 02:38 1796047

МИШАНЧИК,
FAQ по использованию ресурсов в AutoIt

Creat0R 16-11-2011 02:55 1796049

Цитата:

Цитата МИШАНЧИК
а нельзя сделать чтоб рисунок после компиляции распологался в исполняемом файле и брался оттуда? »

Если сильно не заморачиваться, я бы предложил использовать FileInstall:

Код:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

FileChangeDir(@ScriptDir)

$sImage = @TempDir & "\Image.jpg"

If Not @Compiled And Not FileExists("Image.jpg") Then InetGet("http://img.flyinglobsters.com/wall/src/124227199686.jpg", "Image.jpg", 1, 0)
FileInstall("Image.jpg", $sImage, 1)

GUICreate("My GUI", 300, 200)

$pic = GUICtrlCreatePic($sImage, 0, 0, 300, 200)
GUICtrlSetState(-1, $GUI_DISABLE)

$group = _GUICtrlCreateGroupEx("Group1", 10, 10, 280, 180, 3, 0xFF0000, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func _GUICtrlCreateGroupEx($sText, $iLeft, $iTop, $iWidth, $iHeight, $iLineWidth = 3, $nColor = 0, $iStyle = 0)
    Local $aIDs[2] ;First + Last IDs

    Local $nLabel_Style = $SS_ETCHEDFRAME

    ;1 to able set color for the Group frame
    If $iStyle > 0 Then $nLabel_Style = $SS_SUNKEN

    Local $hDC = _WinAPI_GetDC(GUICtrlGetHandle(GUICtrlCreateLabel($sText, -100, -100)))
    Local $stExtPoint = _WinAPI_GetTextExtentPoint32($hDC, $sText)

    Local $iExtPoint_X = DllStructGetData($stExtPoint, "X") - StringLen($sText) + 5

    GUIStartGroup()

    If $sText <> '' Then
        $aIDs[0] = GUICtrlCreateLabel('', $iLeft + 1, $iTop, 35, $iLineWidth, $nLabel_Style)
        GUICtrlSetBkColor(-1, $nColor)

        GUICtrlCreateLabel('', $iLeft + 35 + $iExtPoint_X, $iTop, $iWidth - 35 - $iExtPoint_X, $iLineWidth, $nLabel_Style)
    Else
        $aIDs[0] = GUICtrlCreateLabel('', $iLeft + 1, $iTop, $iWidth - 2, $iLineWidth, $nLabel_Style)
    EndIf

    GUICtrlSetBkColor(-1, $nColor)

    GUICtrlCreateLabel('', $iLeft + 2, $iTop + 5, $iLineWidth, $iHeight - 4, $nLabel_Style)
    GUICtrlSetBkColor(-1, $nColor)

    GUICtrlCreateLabel('', ($iLeft + $iWidth), $iTop - 3, $iLineWidth, $iHeight - 3, $nLabel_Style)
    GUICtrlSetBkColor(-1, $nColor)

    $aIDs[1] = GUICtrlCreateLabel('', $iLeft + 6, ($iTop + $iHeight) - 5, $iWidth, $iLineWidth, $nLabel_Style)
    GUICtrlSetBkColor(-1, $nColor)

    If $sText <> '' Then
        $aIDs[1] = GUICtrlCreateLabel('  ' & $sText, $iLeft + 35, $iTop - 6)
        GUICtrlSetColor(-1, $nColor)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    EndIf

    Return $aIDs
EndFunc


Yashied 18-11-2011 06:08 1797693

Цитата:

А нельзя всё-таки как нибудь просто задать прозрачность надписи в стандартной GUICtrlCreateGroup?
Рисуешь по слоям:

Картинка + Пустой Group + Кусок нижней картинки со смещением на месте текста + Текст


Время: 15:11.

Время: 15:11.
© OSzone.net 2001-