Sign in to follow this  
Followers 0
PartyPooper

Covering End Tab on resizing GUI

5 posts in this topic

Can anyone get this red label to position itself correctly on resizing the GUI?

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
Opt('GUIResizeMode', 1) ; see GUICtrlSetResizing
;GUIRegisterMsg($WM_SIZE, '_WM_RESIZE')
;GUIRegisterMsg($WM_SIZING, '_WM_RESIZE')
Global $hTab
Global $hCoverLabel
Example()

Func Example()
    Local $aRect, $sRect, $hTab

    ; Create GUI
    GUICreate("Tab Control Get Display Rect", 400, 300, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MINIMIZEBOX + $WS_MAXIMIZEBOX + $WS_CAPTION + $WS_POPUP)
    $hTab = GUICtrlCreateTab(10, 10, 380, 280)
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    GUISetState(@SW_SHOW)

    ; Add tabs
    GUICtrlCreateTabItem("Tab 0")
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    GUICtrlCreateTabItem("")
    GUICtrlCreateTabItem("Tab 1")
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    GUICtrlCreateTabItem("")
    GUICtrlCreateTabItem("Tab 2")
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    GUICtrlCreateTabItem("")

    ; Get empty tab display rectangle
    Local $aRect1 = _GUICtrlTab_GetItemRect($hTab, 2); xul, yul, xlr, ylr
    Local $aRect2 = _GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($hTab)); xul, yul, xlr, ylr
    ;_ArrayDisplay($aRect1)
    ;_ArrayDisplay($aRect2)
    $hCoverLabel = GUICtrlCreateLabel('', $aRect1[2] + 10, 10, ($aRect2[0] + $aRect2[2]) - $aRect1[2], $aRect2[1])
    GUICtrlSetBkColor(-1, '0x00ff0000')


    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func _WM_RESIZE($hWnd, $iMsg, $iwParam, $ilParam) ; resizes control when interface resizing
    Local $aRect1 = _GUICtrlTab_GetItemRect($hTab, 2)
    Local $aRect2 = _GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($hTab))
    GUICtrlSetPos($hCoverLabel, $aRect1[2] + 10, 10, ($aRect2[0] + $aRect2[2]) - $aRect1[2], $aRect2[1])
    GUICtrlSetBkColor(-1, 0x00ff0000)
    Return
EndFunc   ;==>_WM_RESIZE

Share this post


Link to post
Share on other sites



$hCoverLabel = GUICtrlCreateLabel('', $aRect1[2] + 10, 10, ($aRect2[0] + $aRect2[2]) - $aRect1[2], $aRect2[1])
GUICtrlSetBkColor(-1, '0x00ff0000')
GUICtrlSetResizing($hCoverLabel,$GUI_DOCKALL)

Doesn't work unfortunately.  The red bar locks to end of last tab item, but doesn't resize when I pull edges of gui.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
; #include <MsgBoxConstants.au3>
#include <Array.au3>
Opt('GUIResizeMode', 802) ; see GUICtrlSetResizing
Global $hTab
Global $hCoverLabel
Example()

Func Example()
    Local $aRect, $sRect, $hTab

    ; Create GUI
    GUICreate("Tab Control Get Display Rect", 400, 300, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_POPUP)
    $hTab = GUICtrlCreateTab(10, 10, 380, 280)
    GUICtrlSetResizing(-1, 2+4+32+64)
    GUISetState(@SW_SHOW)

    ; Add tabs
    GUICtrlCreateTabItem("Tab 0")
    GUICtrlCreateTabItem("Tab 1")
    GUICtrlCreateTabItem("Tab 2")
    GUICtrlCreateTabItem("")

    ; Get empty tab display rectangle
    Local $aRect1 = _GUICtrlTab_GetItemRect($hTab, 2); xul, yul, xlr, ylr
    Local $aRect2 = _GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($hTab)); xul, yul, xlr, ylr
    ;_ArrayDisplay($aRect1)
    ;_ArrayDisplay($aRect2)
    $hCoverLabel = GUICtrlCreateLabel('', $aRect1[2] + 10, 10, ($aRect2[0] + $aRect2[2]) - $aRect1[2], $aRect2[1])
    GUICtrlSetResizing(-1, 2+4+32+512)
    GUICtrlSetBkColor(-1, 0xff0000)


    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Edited by AZJIO
1 person likes this

Share this post


Link to post
Share on other sites

Thanks AZJIO, you da man :-)  I spent hours on this yesterday and got nowhere.

I see you have adjusted Opt('GUIResizeMode', 802).  The help file is a little vague on this, can you please explain how you arrived at the number 802?

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