Jump to content

Set image behind child GUI


Recommended Posts

#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?

Link to comment
Share on other sites

#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
Link to comment
Share on other sites

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