Jump to content
Sign in to follow this  
Josbe

Tabs and controls

Recommended Posts

I need a confirmation, if this behavior is correct. I have a small example.

The example shows two buttons (show and hide a control); The normal way is using the ID's control,

but I'm trying to use another way for certain script...the main problem is the behavior getting the info from GUIGetCursorInfo( ) and using this method in the tab2...

That function (GUIGetCursorInfo) show the ID of the control of "Tab1" (the control hidden)

Is correct this behavior? :)

#include <GuiConstants.au3>

$hwnd = GuiCreate("GUI Example")

GUICtrlCreateTab(20, 30, 320, 350)
;------------------------------------------------------
$tab1 = GUICtrlCreateTabItem("Tab1")

$Btn1 = GuiCtrlCreateButton("Show CTRL(ID=5)", 120, 100, 120, 50)

$Btn2 = GuiCtrlCreateButton("Hide CTRL(ID=6)", 120, 190, 120, 50)

$icon = GUICtrlCreateIcon("Shell32.dll", 1, 250, 150, 50, 40, $SS_SUNKEN)
GUICtrlSetState(-1, $GUI_HIDE)
;------------------------------------------------------
$tab2 = GUICtrlCreateTabItem("Tab2")

GUICtrlCreateLabel("Click inside the rectangles", 50, 70)
; Only for represent the click-area
_setCTRLBorder($btn1)
_setCTRLBorder($btn2)

#CS
GUICtrlCreateLabel("Show control", 120, 100, 120, 50, $SS_WHITEFRAME  )
GUICtrlSetBkColor(-1, 0xFF55)
GUICtrlCreateLabel("Hide control", 120, 190, 90, 50)
GUICtrlSetBkColor(-1, 0xFF55)
#CE

GuiSetState()

While 1
    $msg = GuiGetMsg()
    
    $mouInfo =  GUIGetCursorInfo( )
    ToolTip( $mouInfo[4] )
    
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
        
    Case $mouInfo[4] = $Btn1 AND $mouInfo[2]= 1; $msg = $Btn1
        GUICtrlSetState( $icon, $GUI_SHOW)
        
    Case $mouInfo[4] = $Btn2 AND $mouInfo[2]= 1;$msg = $Btn2
        GUICtrlSetState( $icon, $GUI_HIDE )
        
    EndSelect
WEnd
Exit

Func _setCTRLBorder( $_ID )
    $cp = ControlGetPos($hwnd, '', $_ID)
    If @error Then Return
        
    $_x = $cp[0]
    $_y = $cp[1]
    $_w = $cp[2]
    $_h = $cp[3]
    $wt = 2
    $bc = 0xFF5522
    
    $nx = $_x - 3
    $ny = $_y - 3
    $nw = $_w + 3
    $nh = $_h + 3
    GUICtrlCreateLabel("", $nx, $ny, $nw, $wt)
    GUICtrlSetBkColor(-1, $bc)

    GUICtrlCreateLabel("", $nx, $ny, $wt, $nh)
    GUICtrlSetBkColor(-1, $bc)
    
    GUICtrlCreateLabel("", $nx, $_y + $_h, $nw, $wt)
    GUICtrlSetBkColor(-1, $bc)
    
    GUICtrlCreateLabel("", $nx + $nw, $ny, $wt, $nh)
    GUICtrlSetBkColor(-1, $bc)
EndFunc

Share this post


Link to post
Share on other sites

I will try to investigate if GUIGetCursorInfo( ) can get the id's corresponding to the control of the switched tab. :)

That's a JON production

Share this post


Link to post
Share on other sites

As the code is working this will never work because if a match occur on a specific area corresponding to a control the info are updated. As the control in the 2 tabs are stricly the same location only the first one will match so it is wrong for the second tab.

I cannot see how I can correct the code. I leave that to JON comeback. He needs some homework ... :)

Share this post


Link to post
Share on other sites

As the code is working this will never work because if a match occur on a specific area corresponding to a control the info are updated. As the control in the 2 tabs are stricly the same location only the first one will match so it is wrong for the second tab.

I cannot see how I can correct the code. I leave that to JON comeback. He needs some homework ... :(

<{POST_SNAPBACK}>

Ok, Thanks for the support. :(

Share this post


Link to post
Share on other sites

Ok, Thanks for the support.  :(

<{POST_SNAPBACK}>

Finally I get a solution without JON, I am proud...

You get it in 3.1.1.30 :(

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...