Sign in to follow this  
Followers 0
dazza

I just need a transparent label with a red outline

5 posts in this topic

It seems that the SetColor command is just ignored as black is always the outline colour.

$k = GUICtrlCreateLabel("", 10, 500, 20, 20, $WS_BORDER)
    GUICtrlSetColor($k, 0xFF0000)
    GUICtrlSetBkColor($k, $GUI_BKCOLOR_TRANSPARENT)

I am clearly missing something fundamental... and after all these years. I hang my head.

Share this post


Link to post
Share on other sites



This is one way to draw a border around a control.

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

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $msg, $k

    GUICreate("My GUI") ; will create a dialog box that when displayed is centered
    ;GUISetBkColor(0xFFFFE0)

    $k = GUICtrlCreateLabel("A", 20, 50, 20, 20, 0x201)
    GUICtrlSetFont(-1, 12, 600)
    GUICtrlSetColor($k, 0x000080) ; Text colour
    GUICtrlSetBkColor($k, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlCreateGraphic(0, 0, 300, 300)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xFF0000) ; Border colour
    GUICtrlSetGraphic(-1, $GUI_GR_PENSIZE, 2)
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, 20 - 2, 50 - 2, 20 + 4, 20 + 4) ; Draw border

    GUISetState() ; will display an empty dialog box

    ; Run the GUI until the dialog is closed
    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE
    Return
EndFunc ;==>Example

Share this post


Link to post
Share on other sites

Many thanks; I can actually ditch the label and just use the graphic. But... I need this red square on top of a jpg (GUICtrlCreatePic) and even though I have created the PIC before the GRAPHIC, the GRAPHIC is hidden by the PIC.

Share this post


Link to post
Share on other sites

This is an example of a red square on top of a GUICtrlCreatePic() control.

;#include <GUIConstantsEx.au3>
;#include <WindowsConstants.au3>
#include <GDIPlus.au3>

Opt('MustDeclareVars', 1)

Local $msg, $k, $hGraphic, $hPen, $hWnd, $hGraphicGUI, $hBMPBuff
Local $sImageFileName = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\logo4.gif"

$hWnd = GUICreate("My GUI", 300, 300)
;GUISetBkColor(0xFFFFE0)

$k = GUICtrlCreatePic($sImageFileName, 20, 50, 169, 68)

_GDIPlus_Startup()
$hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hWnd) ; Graphics of GUI
$hBMPBuff = _GDIPlus_BitmapCreateFromGraphics(300, 300, $hGraphicGUI); $hBMPBuff is a bitmap in memory
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff) ; Graphics of memory bitmap
$hPen = _GDIPlus_PenCreate(0xC4FF0000, 3)

_GDIPlus_GraphicsDrawRect($hGraphic, 15, 45, 20, 20, $hPen) ; Draw to memory bitmap

GUISetState()

; Run the GUI until the dialog is closed
Do
    _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) ; Draw memory bitmap to GUI
    $msg = GUIGetMsg()
Until $msg = -3 ; $GUI_EVENT_CLOSE

_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()

Share this post


Link to post
Share on other sites

Aye karumba!

What a load of work to just get a red outlined square. Many thanks Malkey.

Maybe the boffins at AutoIT could just fix the GUICtrlSetColor function.

Over and out.

Share this post


Link to post
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
Sign in to follow this  
Followers 0