Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

[SOLVED] Buttons placed behind Tab item

button tab icon

  • Please log in to reply
8 replies to this topic

#1 dany

dany

    Polymath

  • Active Members
  • PipPipPipPip
  • 229 posts

Posted 20 August 2012 - 11:56 PM

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.
AutoIt         
#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, 21 August 2012 - 10:32 AM.

Spiderskank Spiderskank

GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF







#2 Andreik

Andreik

    Bishop

  • Active Members
  • PipPipPipPipPipPip
  • 2,592 posts

Posted 21 August 2012 - 06:56 AM

It's because of your $WS_CLIPSIBLINGS style for buttons.
When the words fail... music speaks

#3 dany

dany

    Polymath

  • Active Members
  • PipPipPipPip
  • 229 posts

Posted 21 August 2012 - 09:32 AM

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.

Spiderskank Spiderskank

GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

#4 Andreik

Andreik

    Bishop

  • Active Members
  • PipPipPipPipPipPip
  • 2,592 posts

Posted 21 August 2012 - 10:02 AM

Why don't you use $BS_ICON style for buttons and set the icon directly to button?
When the words fail... music speaks

#5 dany

dany

    Polymath

  • Active Members
  • PipPipPipPip
  • 229 posts

Posted 21 August 2012 - 10:08 AM

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

Spiderskank Spiderskank

GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

#6 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,816 posts

Posted 21 August 2012 - 10:26 AM

dany,

This works for me: :)
AutoIt         
#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
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#7 funkey

funkey

    New Dad

  • Active Members
  • PipPipPipPipPipPip
  • 671 posts

Posted 21 August 2012 - 10:26 AM

Something like this?
AutoIt         
#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.


#8 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,816 posts

Posted 21 August 2012 - 10:27 AM

funkey,

Great minds, eh? :D

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#9 dany

dany

    Polymath

  • Active Members
  • PipPipPipPip
  • 229 posts

Posted 21 August 2012 - 10:31 AM

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, 21 August 2012 - 10:32 AM.

Spiderskank Spiderskank

GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF





Also tagged with one or more of these keywords: button, tab, icon

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users