stefionesco

Image background

3 posts in this topic

#1 ·  Posted

Hi there.

I make a GUI that works just fine. I try to improve only the aesthetic side, adding a background image, but I can't do it "under" the radio buttons. If I use a colour it's OK. Only with am image didn't work. It is possible to use some image as background or not?

Here is my script:

#include <GuiConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#include <file.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <FontConstants.au3>
#include <ColorConstants.au3>

Opt("GUIOnEventMode", 1)

Global $mainwindow = GuiCreate("Background", 275, 200, 100, 100)
GUICtrlCreatePic('background.jpg', 0, 0, 0, 0)
GUICtrlSetState(-1, $GUI_DISABLE)

Local $sFont = "Arial Black"
GUISetFont(12,  $FW_NORMAL, $sFont)
GUISetIcon("icon.ico")


Local $idRadio1 = GUICtrlCreateRadio("Radio 1", 10, 10, 255, 20)
Local $idRadio2 = GUICtrlCreateRadio("Radio 2", 10, 40, 255, 20)
Local $idRadio3 = GUICtrlCreateRadio("Radio 3", 10, 70, 255, 20)
GUICtrlSetState($idRadio1, $GUI_CHECKED)

Local $searchbutton = GUICtrlCreateButton("ACTION", 85, 110, 100, 30)

GUICtrlSetOnEvent($searchbutton, "_action")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Terminate")

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func _action()

            If GUICtrlRead($idRadio1) = $GUI_CHECKED Then
                MsgBox($MB_ICONINFORMATION, "Background", "1", 0)
            EndIf

            If GUICtrlRead($idRadio2) = $GUI_CHECKED Then
                MsgBox($MB_ICONINFORMATION, "Background", "2", 0)
            EndIf

            If GUICtrlRead($idRadio3) = $GUI_CHECKED Then
                MsgBox($MB_ICONINFORMATION, "Background", "3", 0)
            EndIf

EndFunc

Func _Terminate()
    Exit
EndFunc

Thanks.

background.jpg

icon.ico

Share this post


Link to post
Share on other sites



#2 ·  Posted

Try it this way:

#include <GuiConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#include <file.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <FontConstants.au3>
#include <ColorConstants.au3>

Opt("GUIOnEventMode", 1)

Global $mainwindow = GuiCreate("Background", 275, 200, 100, 100)
GUICtrlCreatePic('background.jpg', 0, 0, 0, 0)
GUICtrlSetState(-1, $GUI_DISABLE)

Local $sFont = "Arial Black"
GUISetFont(12,  $FW_NORMAL, $sFont)
GUISetIcon("icon.ico")


Local $idRadio1 = GUICtrlCreateRadio("Radio 1", 10, 10, 255, 20)
GUICtrlSetBkColor(-1,  $GUI_BKCOLOR_TRANSPARENT)
Local $idRadio2 = GUICtrlCreateRadio("Radio 2", 10, 40, 255, 20)
GUICtrlSetBkColor(-1,  $GUI_BKCOLOR_TRANSPARENT)
Local $idRadio3 = GUICtrlCreateRadio("Radio 3", 10, 70, 255, 20)
GUICtrlSetBkColor(-1,  $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetState($idRadio1, $GUI_CHECKED)

Local $searchbutton = GUICtrlCreateButton("ACTION", 85, 110, 100, 30)

GUICtrlSetOnEvent($searchbutton, "_action")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Terminate")

DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($idRadio1), "wstr", 0, "wstr", 0)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($idRadio2), "wstr", 0, "wstr", 0)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($idRadio3), "wstr", 0, "wstr", 0)

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func _action()

            If GUICtrlRead($idRadio1) = $GUI_CHECKED Then
                MsgBox($MB_ICONINFORMATION, "Background", "1", 0)
            EndIf

            If GUICtrlRead($idRadio2) = $GUI_CHECKED Then
                MsgBox($MB_ICONINFORMATION, "Background", "2", 0)
            EndIf

            If GUICtrlRead($idRadio3) = $GUI_CHECKED Then
                MsgBox($MB_ICONINFORMATION, "Background", "3", 0)
            EndIf

EndFunc

Func _Terminate()
    Exit
EndFunc

 


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#3 ·  Posted

i don't know what GUICtrlGetHandle do, but it looks good. I should study this one.

Thanks. It works.

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