Jump to content

Transparent label


legend
 Share

Recommended Posts

Hi. here's a working example on how to make transparent labels, what I need it for is making a checkbox transparent, but it only works with labels

maybe someone know why :)?

#include 
#include 
#include 
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 315, 211, 192, 124)
$Pic1 = GUICtrlCreatePic("background.jpg", 0, 0, 313, 209)
$Label1 = GUICtrlCreateLabel("Label1", 56, 176, 36, 17)
_BKColor( -1, $Label1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

Case $Form1
Case $Form1
Case $Form1
Case $Form1
Case $Pic1
Case $Label1
EndSwitch
WEnd


;===========================================================================
; Function : _BKColor( backgroundcolor, controlID, textcolor )
; Description : Sets the background color of a control. (Transparent Label)
; : Sets the text color of a control.
; Author : Thunder-man (Frank Michalski)
; Date : 19. September 2007
; Version : V 1.20
; Example : _BKColor() :Transparent
; _BKColor( -1, $MyLabel) :Transparent
; _BKColor(0x00ff00) :Color Green
; _BKColor(0x00ff00, $MyLabel) :Color Green
; _BKColor( -1, $MyLabel, 0x00ff00) :Text Color Green
;===========================================================================
Func _BKColor($BackColor_ = "", $GuiID_ = -1, $Textcolor_ = 0x000000)
If $BackColor_ = "" or $BackColor_ = -1 Then
GUICtrlSetBkColor($GuiID_, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor($GuiID_, $Textcolor_)
Else
GUICtrlSetBkColor($GuiID_, $BackColor_)
GUICtrlSetColor($GuiID_, $Textcolor_)
EndIf
EndFunc ;==>_BKColor
;=======================================================================
Link to comment
Share on other sites

The cheat I used was to make the checkbox control only the size that I wanted the checkbox itself.

Then position a label that you can make transparent to describe the box, you can put a label above the box, right of the box or both.

You could also overlap the transparent label with the checkbox and react to guigetmsg() events from the label.

No need to get fancy just yet.

Make a checkbox with no label.

guictrlcreatelabel() your own transparent label.

Solved.

Hmm, does that make sense?

Edited by Xandy
Link to comment
Share on other sites

it does, but i found a better solution :)

#Include  <GuiConstantsEx.au3>
$hGUI = GUICreate("",110,100)
GUICtrlCreateGraphic(0,0,200,200)
GUICtrlSetBkColor(-1,0xFF11EE)
GUICtrlSetState(-1,$GUI_DISABLE)
$check =  GUICtrlCreatecheckbox ( " checkbox " , 20 , 20 )
GUICheckBoxSetColor ($check, 0x000000 , $GUI_BKCOLOR_TRANSPARENT )
GUISetState ( )

While  1
    $nMsg =  GUIGetMsg ( )
    Switch  $nMsg
        Case  - 3
            Exit
    EndSwitch
WEnd


Func GUICheckBoxSetColor ( ByRef  $nats, $iColor, $iBkColor= "0xF1EDED" )
    $CtrlHWnd =  $nats
    If Not  IsHWnd ( $CtrlHWnd)  Then  $CtrlHWnd =  GUICtrlGetHandle ($nats)
    $AParent =  DllCall ( "user32.dll" ,  "hwnd" ,  "GetParent" ,  "hwnd" ,  $CtrlHWnd)
    $aCPos =  ControlGetPos ( $AParent[ 0 ] , "" , $nats)
    $Soldt =  GUICtrlRead ( $nats, 1 )
    GUICtrlDelete ( $nats)
    DllCall ( 'uxtheme.dll' ,  'none' ,  'SetThemeAppProperties' ,  'int' ,  0 )
    $nats =  GUICtrlCreatecheckbox ( $Soldt, $aCPos[ 0 ] , $aCPos[ 1 ] , $aCPos[ 2 ] , $aCPos[ 3 ] )
    GUICtrlSetColor ( - 1 , $iColor)
    GUICtrlSetBkColor ( - 1 , $iBkColor)
    DllCall ( 'uxtheme.dll' ,  'none' ,  'SetThemeAppProperties' ,  'int' ,  7 )
EndFunc
Edited by legend
Link to comment
Share on other sites

Might be better to use GetThemeAppProperties before using Set... so that you can set it back to the correct value afterwards.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Here is a quick attempt :

#include  <GUIConstantsEx.au3>

#region GUI
GUICreate("")
GUISetBkColor(0xABCDEF)

_GUICtrlCreateCheckboxTransparent("checkbox", 20, 20)

GUISetState()
#endregion GUI

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

Sleep(10)
WEnd

Func _GUICtrlCreateCheckboxTransparent($sText = "", $iLeft = 0, $iTop = 0, $iWidth = Default, $iHeight = Default, $iStyle = Default, $iExStyle = Default)
Local $aBackAppProperties, $cbTransCheckBox

$aBackAppProperties = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")

DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)

$cbTransCheckBox = GUICtrlCreateCheckbox($sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle)
GUICtrlSetBkColor($cbTransCheckBox, $GUI_BKCOLOR_TRANSPARENT)

DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $aBackAppProperties[0])

Return $cbTransCheckBox
EndFunc   ;==>_GUICtrlCreateCheckboxTransparent
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...