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

    • Queener
      Click on Toolbar icon
      By Queener
      This is the info of the interface:
      Window
      Title:    Password Safe
      Class:    #32770
      Control
      Class:    ToolbarWindow32
      Instance:    2
      ClassnameNN:    ToolbarWindow322
      Name:    
      Advanced (Class):    [CLASS:ToolbarWindow32; INSTANCE:2]
       ToolsBar
      1:    32003    Make New Database
      2:    32002    Open Another Database
      3:    32004    Close Database
      4:    32005    Save Database
      5:    0    
      6:    32066    Copy Password to Clipboard
      7:    32068    Copy Username to Clipboard
      8:    32069    Copy Notes to Clipboard
      9:    32065    Clear the clipboard contents
      10:    0    
       
      I wanted to click on 1:    32003    Make New Database. But unfortunately, I'm unable to click on that. Any help is much appreciated. Below are the code I tried:

      $Title = "Password Safe" $Class = "[CLASS:ToolbarWindow32; INSTANCE:2]" WinWaitActive($Title) Sleep(500) Dim $hWnd = WinGetHandle($Title,"") Dim $hToolBar = ControlGetHandle($hWnd, '', $Class) ConsoleWrite($hWnd & @TAB & $hToolBar & @LF) _GUICtrlToolbar_ClickIndex($hToolBar, 32003)
    • cookiemonster
      Can't click button after show window
      By cookiemonster
      I have a window with two buttons, when i click the second button it shows a new window and hides the orgional window, when you click close on the second window, it hides the second window and shows the first one again, but now on the first one I can click the buttons but they no longer do anything, why is this?
    • Comboku
      Exit function from "outsite" with button press
      By Comboku
      Hi Guys,
      I have written a little loop program that counts to whatever you choose in "Rounds". 

      (this is just a short version of my program, but it should cover what I try to achieve)

      I now want to be able to stop the counting by pressing the start/stop button. Unfortunately, autoit only registers my click on my button AFTER the func has ended.

      Do you guys have an idea how to stop the function? Maybe check if button was pressed in the loop? 


      Thanks,

      Comboku

       
       
       
      #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <IE.au3> #include <Array.au3> #include <File.au3> $Form1 = GUICreate("Looper", 355, 229, 435, 293) $StartStop = GUICtrlCreateButton("Start", 136, 184, 75, 25) $Rounds = GUICtrlCreateInput("1", 210, 40, 80, 21) $lRounds = GUICtrlCreateLabel("Rounds", 298, 42, 52, 18) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $StartStop If GUICtrlRead($StartStop) = "Start" Then GUICtrlSetData($StartStop, "Stop") GUICtrlSetState($Rounds, $GUI_DISABLE) Call("Loop") ElseIf GUICtrlRead($StartStop) = "Stop" Then ExitLoop MsgBox(0, "Info", "Stopped") Else MsgBox(0, "Info", "Error") EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Loop() $LoopTimes = GUICtrlRead($Rounds) For $i = 1 To $LoopTimes MsgBox(0, "Info", "LET US COUNT: " & $i) Sleep("2000") Next GUICtrlSetData($StartStop, "Start") GUICtrlSetState($StartStop, $GUI_ENABLE) GUICtrlSetState($Rounds, $GUI_ENABLE) EndFunc
       
    • Trolleule
      TabPage Set Font
      By Trolleule
      Hi,
      i did some researchs how to set the font and the only way is to overwrite the subclass with WM_DRAWITEM. With WM_SETFONT i can only change the font for all tab pages, but i want to change the font for a specific page.
      So i have to set the $TCS_OWNERDRAWFIXED style to the tab control to send the WM_DRAWITEM message to the parent window. When i set this style, i can change the fonts, but sadly the tab looses the nice and simple "AutoIt style". I created two child guis, the first is the owner draw tab and the second the "Normal" tab.
      My questions is, how to create this special "AutoIt style"???
      #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <ColorConstants.au3> Global Const $ODT_TAB = 101 Global Const $ODS_SELECTED = 0x0001 Global Const $ODA_DRAWENTIRE = 0x1 Global Const $ODS_FOCUS = 0x0010 $hStrikeOutDefaultFont = _WinAPI_CreateFont(14, 0, 0, 0, 400, False, False, True) ; see system apps module $hGUI = GUICreate("Draw Tab", 500, 600) ; Create child GUIs to hold tabs $hTab_Win0 = GUICreate("", 400, 200, 50, 20, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) $hTab_0 = GUICtrlCreateTab(10, 10, 380, 180, $TCS_OWNERDRAWFIXED);BitOR($TCS_OWNERDRAWFIXED, $TCS_TOOLTIPS, $WS_TABSTOP, $WS_CLIPSIBLINGS)) $hTab_00 = GUICtrlCreateTabitem("00") GUICtrlCreateButton("00", 160, 90, 80, 30) $hTab_01 = GUICtrlCreateTabitem("01") GUICtrlCreateButton("01", 160, 90, 80, 30) GUICtrlCreateTabitem ("") GUISetState() $hTab_Win1 = GUICreate("", 400, 200, 50, 250, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) $hTab_1 = GUICtrlCreateTab(10, 10, 380, 180) $hTab_10 = GUICtrlCreateTabitem("10") GUICtrlCreateButton("10", 160, 90, 80, 30) $hTab_11 = GUICtrlCreateTabitem("11") GUICtrlCreateButton("11", 160, 90, 80, 30) GUICtrlCreateTabitem ("") GUISetState() GUIRegisterMsg($WM_DRAWITEM, "WM_DRAWITEM") ;~ GUIRegisterMsg($WM_SETFONT, "WM_SETFONT") ;~ GUICtrlSendMsg ( $hTab_1, $WM_SETFONT , $hStrikeOutDefaultFont, 1 ) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_SETFONT($hWnd, $Msg, $wParam, $lParam) ConsoleWrite("$hWnd: " & $hWnd & " $Msg: " & $Msg & " $wParam: " & $wParam & " $lParam: " & $lParam & @CRLF) EndFunc Func WM_DRAWITEM($hWnd, $Msg, $wParam, $lParam) Local $DRAWITEMSTRUCT $DRAWITEMSTRUCT = DllStructCreate("uint cType;uint cID;uint itmID;uint itmAction;uint itmState;" & _ "hwnd hItm;hwnd hDC;dword itmRect[4];dword itmData", $lParam) If DllStructGetData($DRAWITEMSTRUCT, "cType") <> $ODT_TAB Then Return $GUI_RUNDEFMSG Local $cID = DllStructGetData($DRAWITEMSTRUCT, "cID") Local $itmID = DllStructGetData($DRAWITEMSTRUCT, "itmID") Local $itmAction = DllStructGetData($DRAWITEMSTRUCT, "itmAction") Local $itmState = DllStructGetData($DRAWITEMSTRUCT, "itmState") Local $hItm = DllStructGetData($DRAWITEMSTRUCT, "hItm") Local $hDC = DllStructGetData($DRAWITEMSTRUCT, "hDC") If $itmAction <> $ODA_DRAWENTIRE Then Return $GUI_RUNDEFMSG Local $iTextColor, $itmText $iTextColor = 0xFFFFFF Switch $itmID Case 0 $iBrushColor = 0x11AADD Case 1 $iBrushColor = 0xEEBB99 EndSwitch _WinAPI_SetBkMode($hDC, $TRANSPARENT) Local $iBrush = _WinAPI_CreateSolidBrush($iBrushColor) Local $iBrushOld = _WinAPI_SelectObject($hDC, $iBrush) $g_tRECT = DllStructCreate($tagRect, DllStructGetPtr($DRAWITEMSTRUCT, "itmRect")) DllStructSetData($g_tRECT, "Left", DllStructGetData($g_tRECT, "Left")) DllStructSetData($g_tRECT, "Top", DllStructGetData($g_tRECT, "Top")) DllStructSetData($g_tRECT, "Right", DllStructGetData($g_tRECT, "Right")) DllStructSetData($g_tRECT, "Bottom", DllStructGetData($g_tRECT, "Bottom")+10) _WinAPI_FillRect ( $hDC, $g_tRECT, $iBrush ) _WinAPI_SetTextColor($hDC, $iTextColor) _WinAPI_DrawText($hDC, "Item " & $itmID, $g_tRECT, $DT_LEFT) _WinAPI_SelectObject($hDC, $iBrushOld) _WinAPI_DeleteObject($iBrush) Return $GUI_RUNDEFMSG EndFunc ;==>WM_DRAWITEM Thanks in advance
    • dkim1017
      Locating a specific element on IE
      By dkim1017
      Hello all, I am at an impasse trying to move mouse to a specific element on a webpage, a button in this case, and clicking it (this would be the easy part).
      The element is defined as followed:
      id = "controls-4"
      class = "set btn"
       
      I am able to locate the element using the following lines:
          Local $oDiv = _IEGetObjById($oIE, "controls-4")
          MsgBox($MB_SYSTEMMODAL, "controls-4", $oDiv.innertext)
      From here, I've tried the following lines, but all failed to move the mouse or click the element:
          Local $locDM = ControlGetPos("","",$oDiv)
          MouseMove($locDM[0],$locDM[1])
          _IEAction($oDiv, "click")
      After storing the element to $oDiv, how should I go about using it to achieve what I want?
       
      Thank you for your help in advance.