Sign in to follow this  
Followers 0
AustrianOak

Set image behind child GUI

5 posts in this topic

#include <GUIConstants.au3>
#include <WindowsConstants.au3>

Global $OptionPages[5][2]    ; 5 Pages, for each page button + GUI
Global $bk = @ScriptDir & "\bk.bmp"

#region - GUI Create
$parent = GUICreate('PArent',200,240)
$OptionPages[0][0] = GUICtrlCreateButton("1",10,10,30,30)
$OptionPages[1][0] = GUICtrlCreateButton("2",50,10,30,30)
$OptionPages[2][0] = GUICtrlCreateButton("3",90,10,30,30)
$OptionPages[3][0] = GUICtrlCreateButton("4",130,10,30,30)
$OptionPages[4][0] = GUICtrlCreateButton("5",170,10,30,30)

GUICtrlCreatePic($bk, 0, 40, 160, 160)

$OptionPages[0][1] = GUICreate("Option1",180,170,0,40,$WS_CHILD,0,$parent)
GUISetBkColor(0xFFFFFF)
GUICtrlCreateLabel("hallo",10,10)
GUICtrlCreateEdit("kjkkkk",10,40)

$OptionPages[1][1] = GUICreate("Option2",180,170,0,40,$WS_CHILD,0,$parent)
GUISetBkColor(0xFFFF00)
GUICtrlCreateEdit("kjkkkk",10,40)

$OptionPages[2][1] = GUICreate("Option3",180,170,0,40,$WS_CHILD,0,$parent)
GUISetBkColor(0x00FFFF)

$OptionPages[3][1] = GUICreate("Option4",180,170,0,40,$WS_CHILD,0,$parent)
GUISetBkColor(0x000000)

$OptionPages[4][1] = GUICreate("Option5",180,170,0,40,$WS_CHILD,0,$parent)
GUISetBkColor(0xFF0000)

GUISwitch($parent)
GUISetState()
#endregion

#region - GUI SelectLoop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case Else
            $newpage = _CheckOptionPages($msg)
            If $newpage Then ConsoleWrite($newpage & @CRLF)
    EndSelect
WEnd
#endregion

Func _CheckOptionPages($msg)
    For $i = 0 To UBound($OptionPages)-1
        If $msg = $OptionPages[$i][0] And BitAND(WinGetState($OptionPages[$i][1]),2) <> 2 Then
            Return _SwitchToPage($i)
            ExitLoop
        EndIf
    Next
EndFunc

Func _SwitchToPage($page)
    If $page >= UBound($OptionPages) Then Return SetError(1,0,0)
    For $i = 0 To UBound($OptionPages)-1
        GUISetState(@SW_HIDE,$OptionPages[$i][1])
    Next
    GUISetState(@SW_SHOW,$OptionPages[$page][1])
    Return $page+1
EndFunc

Above if you run it you'll see a blank space because you don't have the image file but on line 15 I create one with GUICtrlCreatePic() where a part of the child GUI is. My question is how do I set the image behind this GUI?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <GUIConstants.au3>
#include <WindowsConstants.au3>

Global $OptionPages[5][2]    ; 5 Pages, for each page button + GUI
Global $bk = @ScriptDir & "\bk.bmp"

#region - GUI Create
$parent = GUICreate('PArent',200,240)

GUICtrlCreatePic($bk, 0, 0, 200, 240,Default,$WS_EX_TRANSPARENT)
GUICtrlSetState(-1,$GUI_DISABLE)

$OptionPages[0][0] = GUICtrlCreateButton("1",10,10,30,30)
$OptionPages[1][0] = GUICtrlCreateButton("2",50,10,30,30)
$OptionPages[2][0] = GUICtrlCreateButton("3",90,10,30,30)
$OptionPages[3][0] = GUICtrlCreateButton("4",130,10,30,30)
$OptionPages[4][0] = GUICtrlCreateButton("5",170,10,30,30)

$OptionPages[0][1] = GUICreate("Option1",180,170,0,40,$WS_CHILD,0,$parent)
GUISetBkColor(0xFFFFFF)
GUICtrlCreateLabel("hallo",10,10)
GUICtrlCreateEdit("kjkkkk",10,40)

$OptionPages[1][1] = GUICreate("Option2",180,170,0,40,$WS_CHILD,0,$parent)
GUICtrlCreateLabel("",0,40,180,170)
GUISetBkColor(0xFFFF00)
GUICtrlCreateEdit("kjkkkk",10,40)

$OptionPages[2][1] = GUICreate("Option3",180,170,0,40,$WS_CHILD,0,$parent)
GUICtrlCreateLabel("",0,40,180,170)
GUISetBkColor(0x00FFFF)

$OptionPages[3][1] = GUICreate("Option4",180,170,0,40,$WS_CHILD,0,$parent)
GUICtrlCreateLabel("",0,40,180,170)
GUISetBkColor(0x000000)

$OptionPages[4][1] = GUICreate("Option5",180,170,0,40,$WS_CHILD,0,$parent)
GUICtrlCreateLabel("",0,40,180,170)
GUISetBkColor(0xFF0000)

GUISwitch($parent)
GUISetState()
GUICtrlSetState($OptionPages[0][0],$GUI_FOCUS)
GUICtrlSetState($OptionPages[1][0],$GUI_FOCUS)
GUICtrlSetState($OptionPages[2][0],$GUI_FOCUS)
GUICtrlSetState($OptionPages[3][0],$GUI_FOCUS)
GUICtrlSetState($OptionPages[4][0],$GUI_FOCUS)

#endregion

#region - GUI SelectLoop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case Else
            $newpage = _CheckOptionPages($msg)
            If $newpage Then ConsoleWrite($newpage & @CRLF)
    EndSelect
WEnd
#endregion

Func _CheckOptionPages($msg)
    For $i = 0 To UBound($OptionPages)-1
        If $msg = $OptionPages[$i][0] And BitAND(WinGetState($OptionPages[$i][1]),2) <> 2 Then
            Return _SwitchToPage($i)
            ExitLoop
        EndIf
    Next
EndFunc

Func _SwitchToPage($page)
    If $page >= UBound($OptionPages) Then Return SetError(1,0,0)
    For $i = 0 To UBound($OptionPages)-1
        GUISetState(@SW_HIDE,$OptionPages[$i][1])
    Next
    GUISetState(@SW_SHOW,$OptionPages[$page][1])
    Return $page+1
EndFunc

Not perfect, maybe a little bit messy :P, but for me it works...

Edited by Polyphem

This post will be edited again by Polyphem: Tomorrow, 11:55 AM

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

ok that problem is fixed thanks to you.

but IMO in introduces another problem at least for me.

Take a look at the screenshot I posted:

Do you see that ugly brownish borders around the control? How do I get rid of them?

Edited by IWantIt

Share this post


Link to post
Share on other sites

Do you see that ugly brownish borders around the control? How do I get rid of them?

Hmmmm, maybe either one of these will solve this problem....

; for all controls of a GUI
GUICtrlSetDefBkColor(0x000000, $GUI)

; after the control
GUICtrlSetBkColor(-1, 0x000000)

This post will be edited again by Polyphem: Tomorrow, 11:55 AM

Share this post


Link to post
Share on other sites

No that wouldn't work because the image I'm using has a type of gradient and setting all my controls to one color would be disasterous.

I know there has to be another way....

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