ViSiToR
Silver Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору AZJIO 22:44 02-11-2010 Цитата: Как сделать прозрачную кнопку, чтоб в качестве фона можно было использовать картинку. | Метод #1: Код: #include <GUIConstantsEx.au3> #include <GUIImageList.au3> #include <GUIButton.au3> $hGUI = GUICreate("Button With Icons + Text") $btn1 = _GUICtrlCreateButton("Button1", 10, 10, 90, 25, -1, -1, "shell32.dll", -6, $BUTTON_IMAGELIST_ALIGN_LEFT) $btn2 = _GUICtrlCreateButton("Button2", 10, 50, 90, 25, -1, -1, "shell32.dll", -21, $BUTTON_IMAGELIST_ALIGN_RIGHT) $btn3 = _GUICtrlCreateButton("Button3", 10, 90, 50, 50, -1, -1, "shell32.dll", -32, $BUTTON_IMAGELIST_ALIGN_TOP) $btn4 = _GUICtrlCreateButton("Button4", 10, 140, 50, 50, -1, -1, "shell32.dll", -14, $BUTTON_IMAGELIST_ALIGN_BOTTOM) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd Exit Func _GUICtrlCreateButton($sText, $iLeft, $iTop, $iWidth = -1, $iHeight = -1, $nStyle = -1, $nExStyle = -1, $sIconFile = '', $nIconID = 0, $nAlign = -1) Local $nID = GUICtrlCreateButton($sText, $iLeft, $iTop, $iWidth, $iHeight, $nStyle, $nExStyle) If $sIconFile = '' Then Return $nID EndIf Local $hImgLst = _GUIImageList_Create(16, 16, 5, BitOr($ILC_MASK, $ILC_COLOR32), 0, 1) _GUIImageList_AddIcon($hImgLst, $sIconFile, $nIconID) _GUICtrlButton_SetImageList($nID, $hImgLst, $nAlign) Return $nID EndFunc | Метод #2: Код: #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> Global $Draw = False Global $aCurPos $hGUI = GUICreate("My GUI", 300, 200) $pic = GUICtrlCreatePic(@WindowsDir & "\Web\Wallpaper\Windows XP.jpg", 0, 0, 300, 200) GUICtrlSetState(-1, $GUI_DISABLE) $button = GUICtrlCreateLabel("Test", 100, 65, 100, 25, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState() FrameRect1(GUICtrlGetHandle($button), 0xFFFFFF) While 1 $aCurPos = GUIGetCursorInfo() Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $button While $aCurPos[2] = 1 $aCurPos = GUIGetCursorInfo() Sleep(10) WEnd If $aCurPos[4] = $button Then MsgBox(0, "Info", "Button pressed", 0, $hGUI) EndIf EndSwitch If IsArray($aCurPos) Then If ($aCurPos[4] = $button) And ($Draw = False) Then $Draw = True GUICtrlSetFont($button, 10, 800) FrameRect1(GUICtrlGetHandle($button), 0x000000) ElseIf ($aCurPos[4] <> $button) And ($Draw = True) Then $Draw = False GUICtrlSetFont($button, Default, Default) FrameRect1(GUICtrlGetHandle($button), 0xFFFFFF) EndIf EndIf WEnd Func FrameRect1($hWnd, $sColor) Local $hDC = _WinAPI_GetDC($hWnd) Local $tRect = _WinAPI_GetClientRect($hWnd) Local $hBrush = _WinAPI_CreateSolidBrush($sColor) DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($tRect), "hwnd", $hBrush) _WinAPI_ReleaseDC($hWnd, $hDC) _WinAPI_DeleteObject($hBrush) EndFunc |
---------- ViSiToR a.k.a CreatoR CreatoR это не ник, CreatoR это стиль жизни! |
|