Jump to content

Making checkbox tranparent ?


jslegers
 Share

Recommended Posts

Hello,

I'm making a script which can install programs for my unattended install of Windows XP. Here is the script :

#include <GuiConstants.au3>

GuiCreate("Select programs to Install", 392, 316,-1, -1 , BitOr( $WS_POPUP, $WS_SYSMENU, $WS_CLIPSIBLINGS ))

GUICtrlCreatePic(@Systemdir & "\oobe\images\newtop8.jpg", 0, 0, 392, 42 )

GUICtrlCreatePic(@Systemdir & "\oobe\images\mslogo.jpg", 0, 0, 255, 40 )

;GUICtrlCreatePic(@SystemDir & "\oobe\images\newmark8.jpg", 0, 42, 392, 250 )

$Checkbox_1 = GuiCtrlCreateCheckbox("Notepad", 20, 60, -1, -1)

$Checkbox_2 = GuiCtrlCreateCheckbox("Calc", 20, 80, -1, -1)

$Checkbox_3 = GuiCtrlCreateCheckbox("Checkbox3", 20, 100, -1, -1)

$Checkbox_4 = GuiCtrlCreateCheckbox("Checkbox4", 20, 120, -1, -1)

$Checkbox_5 = GuiCtrlCreateCheckbox("Checkbox5", 20, 140, -1, -1)

$Button_1 = GuiCtrlCreateButton("Install", 20, 200, 60, 20)

$Button_2 = GUICtrlCreateButton("Cancel", 100, 200, 60, 20)

GUICtrlSetBkColor(-1,0x00ff00)

GuiSetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_2

Exit

Case $msg = $Button_1

If GUICtrlRead($Checkbox_1) = 1 Then RunWait ( "notepad.exe" )

If GUICtrlRead($Checkbox_2) = 1 Then RunWait ( "calc.exe" )

MsgBox (0, "Pad is", @ScriptDir)

Exit

EndSelect

WEnd

GUIDelete()

Exit

When I enable the line ;GUICtrlCreatePic(@SystemDir & "\oobe\images\newmark8.jpg", 0, 42, 392, 250 ) the check boxes can't be used as also the buttons. Is there a way to make the check boxes and buttons transparent to the graphic ? In simple words I want to use a background picture with check boxes and buttons.

I have included a screencapture when the line is enabled.

With kind regards,

John Slegers

Link to comment
Share on other sites

Not sure that you can make them transparent, but to get the controls to work with a image in the background you need to disable the image

#include <GuiConstants.au3>

GUICreate("Select programs to Install", 392, 316, -1, -1, BitOR($WS_POPUP, $WS_SYSMENU, $WS_CLIPSIBLINGS))
GUICtrlCreatePic(@SystemDir & "\oobe\images\newtop8.jpg", 0, 0, 392, 316)
GUICtrlSetState(-1,$GUI_DISABLE)
;~ GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 0, 0, 255, 40)
;GUICtrlCreatePic(@SystemDir & "\oobe\images\newmark8.jpg", 0, 42, 392, 250 )

$Checkbox_1 = GUICtrlCreateCheckbox("Notepad", 20, 60, 100)
$Checkbox_2 = GUICtrlCreateCheckbox("Calc", 20, 80, 100)
$Checkbox_3 = GUICtrlCreateCheckbox("Checkbox3", 20, 100, 100)
$Checkbox_4 = GUICtrlCreateCheckbox("Checkbox4", 20, 120, 100)
$Checkbox_5 = GUICtrlCreateCheckbox("Checkbox5", 20, 140, 100)
$Button_1 = GUICtrlCreateButton("Install", 20, 200, 60, 20)
$Button_2 = GUICtrlCreateButton("Cancel", 100, 200, 60, 20)

GUICtrlSetBkColor(-1, 0x00ff00)

GUISetState()
While 1
   $msg = GUIGetMsg()
   
   Select
      Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_2
         Exit
         
      Case $msg = $Button_1
         If BitAND(GUICtrlRead($Checkbox_1),$GUI_CHECKED) = $GUI_CHECKED Then RunWait("notepad.exe")
         If  BitAND(GUICtrlRead($Checkbox_2),$GUI_CHECKED) = $GUI_CHECKED Then RunWait("calc.exe")
         MsgBox(0, "Pad is", @ScriptDir)
         Exit
   EndSelect
WEnd

GUIDelete()
Exit

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I have tried it but the controls have grey background instead of the picture. Well if it doesn't work it is no problem.

I believe checkboxes are another form of button, same applies to standard buttons

With the beta you could always make an OwnerDrawn checkbox, probably make it transparent, haven't tried it myself.

or

#include <GuiConstants.au3>

GUICreate("Select programs to Install", 392, 316, -1, -1, BitOR($WS_POPUP, $WS_SYSMENU, $WS_CLIPSIBLINGS))
GUICtrlCreatePic(@SystemDir & "\oobe\images\newtop8.jpg", 0, 0, 392, 316)
GUICtrlSetState(-1,$GUI_DISABLE)
;~ GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 0, 0, 255, 40)
;GUICtrlCreatePic(@SystemDir & "\oobe\images\newmark8.jpg", 0, 42, 392, 250 )

$Checkbox_1 = GUICtrlCreateCheckbox("", 20, 60, 10, 10)
$label_1 = GUICtrlCreateLabel(" NotePad", 30, 60, 90, 20 )
GUICtrlSetColor(-1,0xffffff)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Checkbox_2 = GUICtrlCreateCheckbox("", 20, 80, 10, 10)
$label_2 = GUICtrlCreateLabel(" Calc", 30, 80, 90, 20 )
GUICtrlSetColor(-1,0xffffff)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Checkbox_3 = GUICtrlCreateCheckbox("", 20, 100, 10, 10)
$label_3 = GUICtrlCreateLabel(" Checkbox3", 30, 100, 90, 20 )
GUICtrlSetColor(-1,0xffffff)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Checkbox_4 = GUICtrlCreateCheckbox("", 20, 120, 10, 10)
$label_4 = GUICtrlCreateLabel(" Checkbox4", 30, 120, 90, 20 )
GUICtrlSetColor(-1,0xffffff)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Checkbox_5 = GUICtrlCreateCheckbox("", 20, 140, 10, 10)
$label_5 = GUICtrlCreateLabel(" Checkbox5", 30, 140, 90, 20 )
GUICtrlSetColor(-1,0xffffff)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
$Button_1 = GUICtrlCreateButton("Install", 20, 200, 60, 20)
$Button_2 = GUICtrlCreateButton("Cancel", 100, 200, 60, 20)

GUICtrlSetBkColor(-1, 0x00ff00)

GUISetState()
While 1
   $msg = GUIGetMsg()
   
   Select
      Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_2
         Exit
         
      Case $msg = $Button_1
         If BitAND(GUICtrlRead($Checkbox_1),$GUI_CHECKED) = $GUI_CHECKED Then RunWait("notepad.exe")
         If  BitAND(GUICtrlRead($Checkbox_2),$GUI_CHECKED) = $GUI_CHECKED Then RunWait("calc.exe")
         MsgBox(0, "Pad is", @ScriptDir)
         Exit
        Case $msg = $label_1
         If BitAND(GUICtrlRead($Checkbox_1),$GUI_CHECKED) = $GUI_CHECKED Then 
                GUICtrlSetState($Checkbox_1,$GUI_UNCHECKED)
            Else
                GUICtrlSetState($Checkbox_1,$GUI_CHECKED)
            EndIf
        Case $msg = $label_2
         If BitAND(GUICtrlRead($Checkbox_2),$GUI_CHECKED) = $GUI_CHECKED Then 
                GUICtrlSetState($Checkbox_2,$GUI_UNCHECKED)
            Else
                GUICtrlSetState($Checkbox_2,$GUI_CHECKED)
            EndIf
        Case $msg = $label_3
         If BitAND(GUICtrlRead($Checkbox_3),$GUI_CHECKED) = $GUI_CHECKED Then 
                GUICtrlSetState($Checkbox_3,$GUI_UNCHECKED)
            Else
                GUICtrlSetState($Checkbox_3,$GUI_CHECKED)
            EndIf
        Case $msg = $label_4
         If BitAND(GUICtrlRead($Checkbox_4),$GUI_CHECKED) = $GUI_CHECKED Then 
                GUICtrlSetState($Checkbox_4,$GUI_UNCHECKED)
            Else
                GUICtrlSetState($Checkbox_4,$GUI_CHECKED)
            EndIf
        Case $msg = $label_5
         If BitAND(GUICtrlRead($Checkbox_5),$GUI_CHECKED) = $GUI_CHECKED Then 
                GUICtrlSetState($Checkbox_5,$GUI_UNCHECKED)
            Else
                GUICtrlSetState($Checkbox_5,$GUI_CHECKED)
            EndIf
   EndSelect
WEnd

GUIDelete()
Exit
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Hi,

I have tried the last code with the latest beta. I'm having a problem with the line GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) it can't find the variable $GUI_BKCOLOR_TRANSPARENT. Is this a new function within Autoit beta ?

John

it's in the GUIConstants.au3 from the beta

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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...