Sign in to follow this  
Followers 0
dany

[SOLVED] Buttons placed behind Tab item

9 posts in this topic

#1 ·  Posted (edited)

The script below demonstrates my problem. If I run this script all icon buttons save the one created before the tab control are placed behind the tab and only the icon shows. I've tried everything I could think of, setting different styles, states etc. to the GUI, tab, button, icon... Well you get the picture. Nothing has worked thusfar and I'm at a complete loss here. Any help would be much appreciated.

This will create a GUI with two tabs and four buttons of which three are behind the tab control.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

Local $iExit, $iGUIMsg

GUICreate('Problem...', 180, 150, -1, -1, $GUI_SS_DEFAULT_GUI, $WS_EX_TOPMOST)
; This button will show correctly.
$iExit = _IconOnButton('Close', 10, 120, 160, 20, 200)
; Create tab.
GUICtrlCreateTab(5, 5, 120, 140)
; First item and button with missing text and borders.
GUICtrlCreateTabItem('One')
_IconOnButton('First', 10, 30, 160, 20, 3)
; Second item and button with missing text and borders.
GUICtrlCreateTabItem('Two')
_IconOnButton('Second', 10, 60, 160, 20, 24)
; Close tab control.
GUICtrlCreateTabItem('')
; Another button with missing text and borders.
_IconOnButton('Third', 10, 90, 160, 20, 1001)

GUISetState(@SW_SHOW)
While 1
    $iGUIMsg = GUIGetMsg()
    Switch $iGUIMsg
        Case $iExit, $GUI_EVENT_CLOSE ; Exit
            Exit
    EndSwitch
WEnd

; By Valuater
Func _IconOnButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $BIconNum, $BIDLL = 'shell32.dll')
    GUICtrlCreateIcon($BIDLL, $BIconNum, $BIleft + 5, $BItop + (($BIheight - 16) / 2), 16, 16)
    GUICtrlSetState( -1, $GUI_DISABLE)
    Local $XS_btnx = GUICtrlCreateButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $WS_CLIPSIBLINGS)
    Return $XS_btnx
EndFunc
Edited by dany

[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Share this post


Link to post
Share on other sites



It's because of your $WS_CLIPSIBLINGS style for buttons.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

Thanks for the reply. But I wish it was that easy...

Take out $WS_CLIPSIBLINGS and the buttons don't have icons. Not what I want. Reverse the order of the creation in _IconOnButton (button first, then the icon) and the icons do show but disappear as soon as the button's clicked.


[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Share this post


Link to post
Share on other sites

Why don't you use $BS_ICON style for buttons and set the icon directly to button?


When the words fail... music speaks

Share this post


Link to post
Share on other sites

Afaik that doesn't allow for buttons with text, only icon buttons. Those do work btw...


[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Share this post


Link to post
Share on other sites

dany,

This works for me: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiImageList.au3>
#include <GuiButton.au3>

GUICreate('Problem...', 180, 150, -1, -1, $GUI_SS_DEFAULT_GUI, $WS_EX_TOPMOST)
$iExit = _IconOnButton('Close', 10, 120, 160, 20, 200)
; Create tab.
GUICtrlCreateTab(5, 5, 120, 110)
GUICtrlCreateTabItem('One')
_IconOnButton('First', 10, 30, 100, 20, 3)
GUICtrlCreateTabItem('Two')
_IconOnButton('Second', 10, 60, 100, 20, 24)
; Close tab control.
GUICtrlCreateTabItem('')
_IconOnButton('Third', 10, 90, 160, 20, 1001)

GUISetState(@SW_SHOW)
While 1
    $iGUIMsg = GUIGetMsg()
    Switch $iGUIMsg
        Case $iExit, $GUI_EVENT_CLOSE ; Exit
            Exit
    EndSwitch
WEnd

Func _IconOnButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $BIconNum, $BIDLL = 'shell32.dll')

    $cButton = GUICtrlCreateButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight)
    $hImageList = _GUIImageList_Create(32, 32, 5, 3)
    _GUIImageList_AddIcon($hImageList, $BIDLL, $BIconNum, True)
    _GUICtrlButton_SetImageList($cButton, $hImageList)
    Return $cButton

EndFunc

The icon indices seem a little off - but I leave finding the correct ones to you. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

Something like this?

#include 
#include 
#include 
#include 
#include 

Local $iExit, $iGUIMsg

GUICreate('No Problem...', 180, 150, -1, -1, $GUI_SS_DEFAULT_GUI, $WS_EX_TOPMOST)

Global $iExit = GUICtrlCreateButton('Close', 10, 120, 160, 20)
_GUICtrlButton_SetImageList(-1, _GetImageListHandle("shell32.dll", -200, False))

; Create tab.
GUICtrlCreateTab(5, 5, 120, 140)
GUICtrlCreateTabItem('One')

GUICtrlCreateButton('First', 10, 30, 160, 20)
_GUICtrlButton_SetImageList(-1, _GetImageListHandle("shell32.dll", -3, False))

GUICtrlCreateTabItem('Two')
GUICtrlCreateButton('Second', 10, 60, 160, 20)
_GUICtrlButton_SetImageList(-1, _GetImageListHandle("shell32.dll", -24, False))

GUICtrlCreateTabItem('') ; Close tab control.


GUICtrlCreateButton('Third', 10, 90, 160, 20)
_GUICtrlButton_SetImageList(-1, _GetImageListHandle("shell32.dll", -1001, False))

GUISetState(@SW_SHOW)
While 1
    $iGUIMsg = GUIGetMsg()
    Switch $iGUIMsg
        Case $iExit, $GUI_EVENT_CLOSE ; Exit
            Exit
    EndSwitch
WEnd

; using image list to set 1 image and have text on button
Func _GetImageListHandle($sFile, $nIconID = 0, $fLarge = False)
    Local $iSize = 16
    If $fLarge Then $iSize = 32

    Local $hImage = _GUIImageList_Create($iSize, $iSize, 5, 3)
    If StringUpper(StringMid($sFile, StringLen($sFile) - 2)) = "BMP" Then
        _GUIImageList_AddBitmap($hImage, $sFile)
    Else
        _GUIImageList_AddIcon($hImage, $sFile, $nIconID, $fLarge)
    EndIf
    Return $hImage
EndFunc   ;==>_GetImageListHandle

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

funkey,

Great minds, eh? :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

AWESOME

Much appreciated, gentlemen. Funkey, your #includes are missing, but I get the point. I definetely need to read up on the standard lib.

Again, Thanks!

Edited by dany

[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

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

  • Similar Content

    • WoodGrain
      How do I Click a button with ControlSend or ControlClick with a variable button name?
      By WoodGrain
      Hi All,
      I'm wanting to learn how to use ControlSend or ControlClick to be able to click a button when prompted, part of the problem is the button text changes.
      The button I want to click displays "NO (XX)" where XX is a countdown each second from 90 - image attached.
      I've not done Control based code before, so the below code may be wrong lol, but this is what I've got so far:
      While 1 If WinExists("System", "reboot") Then Local $hWnd = WinWait("System", "reboot", 5) Local $iPID = WinGetProcess($hWnd) ControlClick($hWnd, "", "[CLASS:Button; Text: NO"] ;ProcessClose($iPID) EndIf Sleep(10000) WEnd Thanks!

    • guiltyking
      Check RightClick on a Button
      By guiltyking
      Is there any better solution to check right Click on a button rather than that one? Since could be there 100`s keys to process.
      Topic is about to find out what is missing in AutoIT to handle contol ID`s of right Clicked Buttons amongst bunch of buttonkeys.
      #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) $hGUI = GUICreate("Test", 300, 300) GUISetOnEvent($GUI_EVENT_CLOSE, "bye") GUISetOnEvent($GUI_EVENT_SECONDARYUP, "_SecondaryUp") global $cButton[9] for $x=1 to 3 $cButton[$x] = GUICtrlCreateButton("Check"&$x, 10, 10*($X*5), 80, 30) GUICtrlSetOnEvent(-1, "_Button") next $x+=1 $cButton[$x] = GUICtrlCreateButton("NoCheck", 10, 10*($X*5), 80, 30) GUISetState() While Sleep(10) WEnd Func _Button() $nTempId=GUICtrlRead(@GUI_CtrlId) ; can get ID from Left Clicked Button// $aCInfo = GUIGetCursorInfo($hGUI) MsgBox(0, "Pressed", "LEFT "&$nTempId&":"&GUICtrlRead($aCInfo[4]),.5) EndFunc Func _SecondaryUp() $aCInfo = GUIGetCursorInfo($hGUI) for $x=1 to 3 ; my solutionprocess slower.... If $aCInfo[4] = $cButton[$x] Then $nTempId=GUICtrlRead(@GUI_CtrlId) ;cannot get real ID, but last one. $nTempId2=GUICtrlRead($cButton[$x]) ;can get ID MsgBox(0, "Pressed", "RIGHT "&$nTempId&":<=? True= "&$nTempId2,1) EndIf next EndFunc Func bye() Exit EndFunc  
    • akomax
      How to add/refresh a text after clicking a button ?
      By akomax
      Hey AI3 community ! I'm wondering how to do this :
      When I click a button on a GUI made (with koda), add a text somewhere in the GUI (most likely under the button) like, an "ok!" to say that no error happened <- If you can help on this too, I don't know how to check if any error occured after a Case, i know @error exist but I can't find how it works !
      And, I don't want an other GUI to appear, I want to do everyting in the same While Loop.
      Thanks to any helpers, hugs and kisses to your beautiful face
       
    • Anas
      ListView in a Tab
      By Anas
      Hi,
      I've a problem and a few questions about list view.
      When I expand/collapse a group that causes the list view to add/remove a scrolling bar, the list view contents disappears and minimizing/restoring the window fix it.
      - How can I fix the list view content disappearing without removing $LVS_EX_FULLROWSELECT.
       
      Also, How can I:
      - expand a collapsed group without applying $LVGS_NORMAL and $LVGS_COLLAPSIBLE separately (without calling  _GUICtrlListView_SetGroupInfo twice)
      - remove the empty space at the end of the list view when scrolled to the end.
      - place the groups expand arrow on the left side.
       
      Thanks.
      #include <GuiListView.au3> #include <GUIConstants.au3> Example() Func Example() GUICreate("ListView in a Tab", 400, 250) GUICtrlCreateTab(1, 1, 400, 200) GUICtrlCreateTabItem('Tab') $LV = GUICtrlCreateListView("Column", 15, 35, 370, 150) ;$LV = GUICtrlCreateListView("Column", 15, 35, 370, 150, Default, $WS_EX_CLIENTEDGE) ;Works, $LVS_EX_FULLROWSELECT removed. $BT1 = GUICtrlCreateButton("Expand 1", 50, 210, 100, 30) $BT2 = GUICtrlCreateButton("Expand 2", 250, 210, 100, 30) GUISetState() _GUICtrlListView_EnableGroupView($LV) _GUICtrlListView_InsertGroup($LV, -1, 1, "") _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, BitOR($LVGS_COLLAPSED, $LVGS_COLLAPSIBLE)) For $i = 1 To 10 GUICtrlCreateListViewItem("Item " & $i, $LV) ;_GUICtrlListView_AddItem($LV, "Item " & $i) ;Same problem _GUICtrlListView_SetItemGroupID($LV, $i-1, 1) Next While 1 $msg = GUIGetMsg() Switch $msg Case $BT1 _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, BitOR($LVGS_NORMAL, $LVGS_COLLAPSIBLE)) Case $BT2 _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_NORMAL) _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_COLLAPSIBLE) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() EndFunc  
    • 31290
      Show button when clicking a checkbox
      By 31290
      Hi everyone, 
      I'm trying to display a button once a checkbox is clicked in my main GUI and to hide said button when the said checkbox is unticked:
      #include <ButtonConstants.au3> #Include <Constants.au3> #include <Date.au3> #include <File.au3> #Include <FontConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <Misc.au3> #include <WindowsConstants.au3> #include <StringConstants.au3> Opt("GUIOnEventMode", 1) f_MainGui() While 1 Sleep (10) Wend Func f_MainGui() Global $g_MainGUI = GUICreate ("SEE Delete Temp Files", 400, 450) GUISetFont (8.5, 700, 0) GUISetBkColor ($Color_White) $g_Label1 = GUICtrlCreateLabel ("Select action(s):", 150, 96, 360, 17) $g_Label2 = GUICtrlCreateLabel ("Web Browsers:", 13, 125, 360, 17) Global $g_ChkBox1 = GUICtrlCreateCheckbox ("I.Explorer [ Cookies / Temp Internet Files / Tracking Data]", 16, 152, 360, 17) Global $g_ChkBox2 = GUICtrlCreateCheckbox ("Chrome", 16, 176, 120, 17) Global $g_ChkBox3 = GUICtrlCreateCheckbox ("Firefox", 16, 200, 120, 17) $g_Label3 = GUICtrlCreateLabel ("Windows Explorer:", 13, 231, 360, 17) Global $g_ChkBox4 = GUICtrlCreateCheckbox ("C:\Temp", 16, 255, 120, 17) Global $g_ChkBox5 = GUICtrlCreateCheckbox ("C:\Windows\Temp", 16, 279, 130, 17) Global $g_ChkBox6 = GUICtrlCreateCheckbox ("C:\Users\XXXXXX\Recent", 16, 303, 200, 17) Global $g_ChkBox7 = GUICtrlCreateCheckbox ("C:\Users\XXXXXX\Local Settings\Temp", 16, 327, 250, 17) Global $g_SelWB = GUICtrlCreateButton ("Select All Web Browsers", 16,360,150,25) GUICtrlSetOnEvent (-1, "f_SelectAllWB") Global $g_SelWinExpl = GUICtrlCreateButton (" Windows Explorer Only", 16,390,150,25) GUICtrlSetOnEvent (-1, "f_WinExplOnly") Global $g_SelAll = GUICtrlCreateButton ("All", 16, 420, 70, 25) GUICtrlSetOnEvent (-1, "f_SelAll") Global $g_SelAll = GUICtrlCreateButton ("None", 95, 420, 70, 25) GUICtrlSetOnEvent (-1, "f_SelNone") Global $g_SubmitAndClean = GUICtrlCreateButton ("Clean Temp Files", 264, 360, 120, 85) GUICtrlSetState ($g_SubmitAndClean, $GUI_HIDE) GUICtrlSetOnEvent (-1, "f_SumitAndClean") GUISetOnEvent ($GUI_EVENT_CLOSE, "_exit") GUISetState() EndFunc I tried everything ==> "Do...Until", "While...Wend", hotkeys etc... and the best I can have a a button that can't stop flicking. 
      I work exclusively with Events and for sure, when going trough the non event method,  Switch...Case...EndSwitch, it's working...
      I'm sure that this may be a beginner question but I think my mind stopped working after an all day coding on different projects
      Thanks in advance