Jump to content

Recommended Posts

Posted

Hello to everyone, experts help needed.

Is there any way to draw an Icon over an Image, but image remaining as the background.

If so could the image be as background of a checkbox?

Change this

"D:\commando.jpg"
with an image.

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

Opt('MustDeclareVars', 1)
Test()

Func Test()
    Local $nMsg1,$Button3

    GUICreate("My gui", 264, 300, -1, -1, $WS_SYSMENU, $WS_EX_TOPMOST)
    GUISetBkColor(0xFB11FF)
    GUICtrlCreatePic("D:\commando.jpg", 24, 60, 200, 130)
    GUICtrlCreateCheckbox("Test checkbox", 24, 70, 217, 17)
    GUICtrlCreateIcon("shell32.dll", 10, 35, 100)
    $Button3 = GUICtrlCreateButton("Exit", 65, 230, 107, 33)
    GUISetState(@SW_SHOW)

    While 1
        $nMsg1 = GUIGetMsg()
        Select
            Case $nMsg1 = $GUI_EVENT_CLOSE
                Exit
            Case $nMsg1 = $Button3
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Test
  • Moderators
Posted

Fantastic,

For transparent checkboxes look here.

For transparent icons look here.

M23

P.S. Trying "Search" is usually a good idea before posting. :)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

  • Moderators
Posted

Fantastic,

I have been working on a transparent checkbox for you. How does this look?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#Include <WinAPI.au3>

Global $fState = False, $iCurr_Check = 0, $fCurr_Trans = False

Global $iBorder = _WinAPI_GetSystemMetrics($SM_CXDLGFRAME)
Global $iCaption = _WinAPI_GetSystemMetrics($SM_CYCAPTION)

Global $iX = 80, $iY = 100, $iSize = 12
Global $iDraw_X = $iX + $iBorder, $iDraw_Y = $iY + $iBorder + $iCaption

$hGUI = GUICreate("Tranparent Checkbox", 350, 300)
GUISetBkColor(0xFB11FF)

GUICtrlCreatePic("Your_Pic", 24, 60, 200, 130)
GUICtrlSetState(-1, $GUI_DISABLE)

; Create a normal checkbox
$hCheck = GUICtrlCreateCheckbox("Unchecked Normal Checkbox", 80, 60, 300, 17)

$hButton = GUICtrlCreateButton("Exit", 65, 230, 107, 33)

GUISetState(@SW_SHOW)

; Create our replacement checkbox AFTER we have created the GUI
; Create a transparent graphic control to "click"
$hGraphic = GUICtrlCreateGraphic($iX, $iY, $iSize, $iSize, $SS_NOTIFY)
; Draw a "Checkbox" box
$hDC = _WinAPI_GetWindowDC($hGUI)
$hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0)
$obj_orig = _WinAPI_SelectObject($hDC, $hPen)
Draw_Box()
; Create the "Checkbox" label
$hLabel = GUICtrlCreateLabel("Unchecked Transparent Checkbox", 100, 100, 300, 20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $hButton
            _WinAPI_SelectObject($hDC, $obj_orig)
            _WinAPI_DeleteObject($hPen)
            _WinAPI_ReleaseDC(0, $hDC)
            Exit
        Case $hGraphic
            If $fState = True Then
                _WinAPI_RedrawWindow($hGUI)
                Draw_Box()
                $fState = False
            Else
                _WinAPI_RedrawWindow($hGUI)
                Draw_Box()
                _WinAPI_DrawLine($hDC, $iDraw_X + 3, $iDraw_Y + 6, $iDraw_X + 6, $iDraw_Y + 9)
                _WinAPI_DrawLine($hDC, $iDraw_X + 6, $iDraw_Y + 9, $iDraw_X + 9, $iDraw_Y + 2)
                _WinAPI_DeleteObject($hPen)
                $fState = True
            EndIf
    EndSwitch

    ; How to read the normal checkbox
    If GUICtrlRead($hCheck) <> $iCurr_Check Then
        $iCurr_Check = GUICtrlRead($hCheck)
        Switch $iCurr_Check
            Case 4
                GUICtrlSetData($hCheck, "Unchecked Normal Checkbox")
            Case 1
                GUICtrlSetData($hCheck, "Checked Normal Checkbox")
        EndSwitch
    EndIf

    ; How to read the transparent checkbox - not really very different!!!!!!!!
    If $fState <> $fCurr_Trans Then
        $fCurr_Trans = $fState
        Switch $fCurr_Trans
            Case True
                GUICtrlSetData($hLabel, "Checked Transparent Checkbox")
            Case False
                GUICtrlSetData($hLabel, "Unchecked Transparent Checkbox")
        EndSwitch
    EndIf

WEnd

Func Draw_Box()

    _WinAPI_DrawLine($hDC, $iDraw_X, $iDraw_Y, $iDraw_X + $iSize, $iDraw_Y)
    _WinAPI_DrawLine($hDC, $iDraw_X + $iSize, $iDraw_Y, $iDraw_X + $iSize, $iDraw_Y + $iSize)
    _WinAPI_DrawLine($hDC, $iDraw_X + $iSize, $iDraw_Y + $iSize, $iDraw_X, $iDraw_Y + $iSize)
    _WinAPI_DrawLine($hDC, $iDraw_X, $iDraw_Y + $iSize, $iDraw_X, $iDraw_Y)

EndFunc

It works nicely for me. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

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