Sign in to follow this  
Followers 0
Jfish

Adding Tabbed Images On Event

5 posts in this topic

Hello all. Apologies in advance if this is a simple question to which I should know the answer ...

I have created a GUI with Koda that has two tabs. I am trying to add images to the second tab through an event (i.e. Case $Button). I can do this with the following code:

$middleImage1 = GUICtrlCreatePic(@ScriptDir&"\images\"&$fiveCommonCards[0]&".jpg", 162, 244, 44, 68, BitOR($SS_NOTIFY,$WS_GROUP))

GUICtrlSetState($middleImage1,$GUI_SHOW)

However, when I do that it shows on the first tab as well (I only want to see it on tab 2). I suspect this has something to do with making sure that the image is a child of Tab2 but I confess I don't know how to do that when I am trying to add it from an event in the "while" loop section of the code (in other words when you press the button). I thought of declaring the images above in the Koda generated GUI code but the function that creates the values is triggered from the same button.

Any help anyone could offer would be greatly appreciated. Thanks in advance.

Jfish


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites



This?

#include <GuiConstants.au3>

$hGUI = GUICreate("Test GUI", 300, 200)

$hTab = GUICtrlCreateTab(10, 10, 280, 180)

$TabItem1 = GUICtrlCreateTabItem("TabItem1")

$TabItem2 = GUICtrlCreateTabItem("TabItem2")

$hPic = GUICtrlCreatePic(@SystemDir & "\setup.bmp", 10, 34, 278, 150)
GUICtrlSetState(-1, $GUI_DISABLE)

$TabItem1 = GUICtrlCreateTabItem("")

GUISetState()

Do
Until GUIGetMsg() = -3

Share this post


Link to post
Share on other sites

If I read that right you are creating the tabbed GUI and adding a picture at the start (if I am wrong, let me know). My issue is that I won't know the value of the picture until I click a button. Then image file path and left position value are both variable. They are triggered from the even of clicking (i.e. Case $buttton). When I create the image from the button it won't show on the tab unless I either: (a) use the $GUI_SHOW or (:) use the function of GuiCtrlCreatePic twice. Either way leads to the result that the image can be see above all other images on the UI and is visible whether you are on tab 1 or tab 2. I am trying to get the action of creating the image from the button to stick only to tab 2. How would your code work if you moved the GuiCtrlCreatePic function into the while loop and triggered it from a button in such a way that it only appeared on Tab 2? Or, am I just going about this the wrong way?

This?

#include <GuiConstants.au3>

$hGUI = GUICreate("Test GUI", 300, 200)

$hTab = GUICtrlCreateTab(10, 10, 280, 180)

$TabItem1 = GUICtrlCreateTabItem("TabItem1")

$TabItem2 = GUICtrlCreateTabItem("TabItem2")

$hPic = GUICtrlCreatePic(@SystemDir & "\setup.bmp", 10, 34, 278, 150)
GUICtrlSetState(-1, $GUI_DISABLE)

$TabItem1 = GUICtrlCreateTabItem("")

GUISetState()

Do
Until GUIGetMsg() = -3

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

Have you tried using GUISwitch to specify which tab you create the picture control on? Have a look at this example from the help files:

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $parent1, $parent2, $tabitem, $msg
    
    $parent1 = GUICreate("Parent1")
    GUICtrlCreateTab(10, 10)
    $tabitem = GUICtrlCreateTabItem("tab1")
    GUICtrlCreateTabItem("tab2")
    GUICtrlCreateTabItem("")

    $parent2 = GUICreate("Parent2", -1, -1, 100, 100)

    GUISwitch($parent2)
    GUISetState()
    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE

    GUISwitch($parent1, $tabitem) ; <==== Note this line
    GUICtrlCreateButton("OK", 50, 50, 50)
    GUICtrlCreateTabItem("")

    GUISetState(@SW_SHOW, $parent1)
    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Share this post


Link to post
Share on other sites

That did the trick. Many thanks for pointing that out. I can now make them appear on tab 2 only. To get them to show without toggling I still need to use the $GUI_SHOW function but all is well. Thanks again. :)

Have you tried using GUISwitch to specify which tab you create the picture control on? Have a look at this example from the help files:

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $parent1, $parent2, $tabitem, $msg
    
    $parent1 = GUICreate("Parent1")
    GUICtrlCreateTab(10, 10)
    $tabitem = GUICtrlCreateTabItem("tab1")
    GUICtrlCreateTabItem("tab2")
    GUICtrlCreateTabItem("")

    $parent2 = GUICreate("Parent2", -1, -1, 100, 100)

    GUISwitch($parent2)
    GUISetState()
    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE

    GUISwitch($parent1, $tabitem) ; <==== Note this line
    GUICtrlCreateButton("OK", 50, 50, 50)
    GUICtrlCreateTabItem("")

    GUISetState(@SW_SHOW, $parent1)
    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

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