|
Компьютерный форум OSzone.net » Программирование, базы данных и автоматизация действий » AutoIt » Как сделать прозрачный фон для надписи в GUICtrlCreateGroup? |
|
Как сделать прозрачный фон для надписи в GUICtrlCreateGroup?
|
Ветеран Сообщения: 989 |
Профиль | Отправить PM | Цитировать Подскажите пожалуйста, возможно ли при создании GUICtrlCreateGroup наложеной на картинку, сделать так чтоб надпись "Установка" была на прозрачном фоне? Т.е. надпись распологалась прям на картинке, а не на белом фоне?
Если можно пример как это сделать. Заранее большое спасибо. |
|
Отправлено: 17:04, 14-11-2011 |
Must AutoIt Сообщения: 3054
|
Профиль | Сайт | Отправить PM | Цитировать #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 |
------- Отправлено: 17:40, 14-11-2011 | #2 |
Для отключения данного рекламного блока вам необходимо зарегистрироваться или войти с учетной записью социальной сети. Если же вы забыли свой пароль на форуме, то воспользуйтесь данной ссылкой для восстановления пароля. |
Ветеран Сообщения: 989
|
Профиль | Отправить PM | Цитировать Creat0R, большое спасибо, но я так понимаю что в этом скрипте Вы полностью создаёте горизонтальные и вертикальные линии(подобие линий в GUICtrlCreateGroup)? А нельзя всё-таки как нибудь просто задать прозрачность надписи в стандартной GUICtrlCreateGroup?
|
Последний раз редактировалось МИШАНЧИК, 15-11-2011 в 04:36. Отправлено: 04:08, 15-11-2011 | #3 |
Must AutoIt Сообщения: 3054
|
Профиль | Сайт | Отправить PM | Цитировать Цитата МИШАНЧИК:
Я ещё часто использую вот такие самопальные 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 |
|
------- Отправлено: 09:00, 15-11-2011 | #4 |
Ветеран Сообщения: 989
|
Профиль | Отправить PM | Цитировать |
|
Отправлено: 01:47, 16-11-2011 | #5 |
Ветеран Сообщения: 812
|
Профиль | Отправить PM | Цитировать МИШАНЧИК,
FAQ по использованию ресурсов в AutoIt |
Отправлено: 02:38, 16-11-2011 | #6 |
Must AutoIt Сообщения: 3054
|
Профиль | Сайт | Отправить PM | Цитировать Цитата МИШАНЧИК:
#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 |
|
------- Отправлено: 02:55, 16-11-2011 | #7 |
Старожил Сообщения: 206
|
Профиль | Отправить PM | Цитировать Цитата:
Картинка + Пустой Group + Кусок нижней картинки со смещением на месте текста + Текст |
|
Отправлено: 06:08, 18-11-2011 | #8 |
Участник сейчас на форуме | Участник вне форума | Автор темы | Сообщение прикреплено |
| |||||
Название темы | Автор | Информация о форуме | Ответов | Последнее сообщение | |
Не сохраняется прозрачный фон в Corel PaintShop | Drec555 | Цифровое изображение | 0 | 13-06-2011 01:39 | |
[решено] Как здать прозрачный фон в GUICtrlCreateLabel | Centrinar | AutoIt | 3 | 26-03-2011 00:49 | |
[решено] GUICtrlCreateRadio - как задать прозрачный фон? | Centrinar | AutoIt | 6 | 21-06-2010 22:08 | |
[решено] Прозрачный фон под текстом | D_Master | AutoIt | 1 | 02-04-2009 09:49 | |
Прозрачный фон иконок рабочего стола | smusmumrik | Хочу все знать | 8 | 11-12-2003 03:11 |
|