Что нового

прозрачный Label +прозрачный GUI

Arei

Скриптер
Сообщения
938
Репутация
115
Здравствуйте, скажите пожалуйста почему не работает прозрачный фон у Label.
Код:
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("", 400, 400, 20, 20, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
$Label1 = GUICtrlCreateLabel("Label1", 40, 88, 132, 81)
GUICtrlSetBkColor ($Label1,$GUI_BKCOLOR_TRANSPARENT)
GUISetControlsVisible($Form1)
GUISetState(@SW_SHOW)



While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

	EndSwitch
WEnd



Func GUISetControlsVisible($hWnd)
    Local $aM_Mask, $aCtrlPos, $aMask

    $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0)
    $aLastID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", GUICtrlGetHandle(-1))

    For $i = 3 To $aLastID[0]
        $aCtrlPos = ControlGetPos($hWnd, '', $i)
        If Not IsArray($aCtrlPos) Then ContinueLoop

        $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", _
            "long", $aCtrlPos[0], _
            "long", $aCtrlPos[1], _
            "long", $aCtrlPos[0] + $aCtrlPos[2], _
            "long", $aCtrlPos[1] + $aCtrlPos[3])
        DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 2)
    Next
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWnd, "long", $aM_Mask[0], "int", 1)
EndFunc
 

Ganibal95

GreenBytes
Сообщения
876
Репутация
239
что эта за функция такая?
GUISetControlsVisible($Form1)


Добавлено:
Сообщение автоматически объединено:

Короче вот что-то намудрил:
Код:
#Include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <WinAPI.au3>

$color = 0xFF00FF
$TextM = 'Ваш текст'

$GuiMenu = GUICreate("", 500, 500, -1, -1, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_LAYERED + $WS_EX_TRANSPARENT + $WS_EX_TOPMOST)
GUICtrlCreateLabel($TextM, 10, 0,500,500)
GUICtrlSetFont(-1, 11, 800, 0, "Comic Sans MS")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetBkColor($color)
_WinAPI_SetLayeredWindowAttributes($GuiMenu, $color)
GUISetState()

While 1
	Sleep(100)
WEnd
 

Zaramot

I ♥ AutoIt
Сообщения
1,160
Репутация
660
Ещё вариант:
Код:
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <FontConstants.au3>

Global $tRECT, $hFont, $hOldFont, $hDC

HotKeySet("{ESC}", "_Exit")

$tRECT = DllStructCreate($tagRect)
DllStructSetData($tRECT, "Left", 5)
DllStructSetData($tRECT, "Top", 5)
DllStructSetData($tRECT, "Right", 250)
DllStructSetData($tRECT, "Bottom", 50)

$hDC = _WinAPI_GetDC(0)
$hFont = _WinAPI_CreateFont(50, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _
		$OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
$hOldFont = _WinAPI_SelectObject($hDC, $hFont)

_WinAPI_SetTextColor($hDC, 0x0000FF)
_WinAPI_SetBkColor($hDC, 0x000000)
; comment next line to get black background instead of transparent one
_WinAPI_SetBkMode($hDC, $TRANSPARENT)

While 1
	_WinAPI_DrawText($hDC, "Hello world!", $tRECT, $DT_CENTER)
	Sleep(100)
WEnd

Func _Exit()
	_WinAPI_SelectObject($hDC, $hOldFont)
	_WinAPI_DeleteObject($hFont)
	_WinAPI_ReleaseDC(0, $hDC)
	_WinAPI_InvalidateRect(0, 0)
	$tRECT = 0
	Exit
EndFunc   ;==>_Exit
 
Верх