Sign in to follow this  
Followers 0
Vadersapien

Trouble hiding controls

3 posts in this topic

Hi,

I'm having trouble hiding a couple of controls in my program. Here is my complete code:

#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)

Global Const $DTT_GRAYED = 0x00000001
Global Const $DTT_FLAGS2VALIDBITS = $DTT_GRAYED
Global Const $DTT_TEXTCOLOR = 0x00000001
Global Const $DTT_BORDERCOLOR = 0x00000002
Global Const $DTT_SHADOWCOLOR = 0x00000004
Global Const $DTT_SHADOWTYPE = 0x00000008
Global Const $DTT_SHADOWOFFSET = 0x00000010
Global Const $DTT_BORDERSIZE = 0x00000020
Global Const $DTT_FONTPROP = 0x00000040
Global Const $DTT_COLORPROP = 0x00000080
Global Const $DTT_STATEID = 0x00000100
Global Const $DTT_CALCRECT = 0x00000200
Global Const $DTT_APPLYOVERLAY = 0x00000400
Global Const $DTT_GLOWSIZE = 0x00000800
Global Const $DTT_CALLBACK = 0x00001000
Global Const $DTT_COMPOSITED = 0x00002000
Global Const $DTT_VALIDBITS = BitOR($DTT_TEXTCOLOR, $DTT_BORDERCOLOR, $DTT_SHADOWCOLOR, $DTT_SHADOWTYPE, $DTT_SHADOWOFFSET, $DTT_BORDERSIZE, _
        $DTT_FONTPROP, $DTT_COLORPROP, $DTT_STATEID, $DTT_CALCRECT, $DTT_APPLYOVERLAY, $DTT_GLOWSIZE, $DTT_COMPOSITED)

If Not IsDeclared('WM_DWMCOMPOSITIonchangeD') Then Global Const $WM_DWMCOMPOSITIonchangeD = 0x031E
If Not IsDeclared('tagDTTOPTS') Then Global Const $tagDTTOPTS = _
        'uint Size;uint Flags;uint clrText;uint clrBorder;uint clrShadow;int TextShadowType;' & $tagPOINT & _
        ';int BorderSize;int FontPropId;int ColorPropId;int StateId;int ApplyOverlay;int GlowSize;ptr DrawTextCallback;int lParam;'

Global $hGUI = GUICreate('RS Media Manager', 800, 600)
Global $hThemeData = _WinAPI_OpenThemeData($hGUI, 'globals')

;Tab Bar
Local $PersonalitiesTab = GUICtrlCreateButton('Personalities', 0, 10, 80, 28)
Local $EditorTab = GUICtrlCreateButton('Editor', 90, 10, 80, 28)
Local $MediaTab = GUICtrlCreateButton('Media', 180, 10, 80, 28)
Local $JavaTab = GUICtrlCreateButton('Java', 270, 10, 80, 28)
Local $ApplicationsTab = GUICtrlCreateButton('Applications', 360, 10, 80, 28)
Local $TimeTab = GUICtrlCreateButton('Time', 450, 10, 80, 28)

;First Tab - Personalities
Global $PersonalitiesTabStart = GUICtrlCreateDummy()
GUICtrlCreateLabel("blah", 0, 100)
GUICtrlCreateLabel("blah", 0, 150)
Global $PersonalitiesTabEnd = GUICtrlCreateDummy()

;Second Tab - Editor
Local $EditorTabStart = GUICtrlCreateDummy()
Local $EditorTabEnd = GUICtrlCreateDummy()

;Third Tab - Media
Local $MediaTabStart = GUICtrlCreateDummy()
Local $MediaTabEnd = GUICtrlCreateDummy()

;Fourth Tab - Java
Local $JavaTabStart = GUICtrlCreateDummy()
Local $JavaTabEnd = GUICtrlCreateDummy()

;Fifth Tab - Applications
Local $ApplicationsTabStart = GUICtrlCreateDummy()
Local $ApplicationsTabEnd = GUICtrlCreateDummy()

;Sixth Tab - Time
Local $TimeTabStart = GUICtrlCreateDummy()
Local $TimeTabEnd = GUICtrlCreateDummy()

GUIRegisterMsg($WM_ERASEBKGND, '_WM_ERASEBKGND')
GUIRegisterMsg($WM_DWMCOMPOSITIonchangeD, '_WM_DWMCOMPOSITIonchangeD')
GUISetState()

_SendMessage($hGUI, $WM_DWMCOMPOSITIonchangeD)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            _WinAPI_CloseThemeData($hThemeData)
            Exit
        Case $PersonalitiesTab
            _GUICtrlHide($PersonalitiesTabStart, $PersonalitiesTabEnd)
    EndSwitch
WEnd

Func _WM_ERASEBKGND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hDC = $iwParam
    Local $tTabBarRect = DllStructCreate('ptr Left; ptr Top; ptr Right; ptr Bottom;')
    Local $tStatusBarRect = DllStructCreate('ptr Left; ptr Top; ptr Right; ptr Bottom;')
    Local $hBrush = _WinAPI_GetStockObject($BLACK_BRUSH)

    DllStructSetData($tTabBarRect, 'Left', 0)
    DllStructSetData($tTabBarRect, 'Top', 0)
    DllStructSetData($tTabBarRect, 'Right', 800)
    DllStructSetData($tTabBarRect, 'Bottom', 40)

    DllStructSetData($tStatusBarRect, 'Left', 0)
    DllStructSetData($tStatusBarRect, 'Top', 576)
    DllStructSetData($tStatusBarRect, 'Right', 800)
    DllStructSetData($tStatusBarRect, 'Bottom', 600)

    _WinAPI_FillRect($hDC, DllStructGetPtr($tTabBarRect), $hBrush)
    _WinAPI_FillRect($hDC, DllStructGetPtr($tStatusBarRect), $hBrush)

    Return 1
EndFunc   ;==>_WM_ERASEBKGND

Func _WM_DWMCOMPOSITIonchangeD($hWnd, $iMsg, $iwParam, $ilParam)
    Local $tMargs = DllStructCreate($tagMARGINS)

    If _WinAPI_DwmIsCompositionEnabled() Then
        DllStructSetData($tMargs, 3, 40)
        DllStructSetData($tMargs, 4, 24)
        _WinAPI_DwmExtendFrameIntoClientArea($hWnd, $tMargs)
    EndIf

    Return 0
EndFunc   ;==>_WM_DWMCOMPOSITIonchangeD

Func _DrawGlowingText($hDC, $sText, $tRc, $iGlowSize = 10, $hFont = 0, $iTextClr = -1)
    Local $hCDC
    Local $tRcText
    Local $tBI, $tDTO
    Local $hDIBBmp, $hOldBmp
    Local $hOldFont
    Local $tST
    Local $iFlags = BitOR($DTT_GLOWSIZE, $DTT_COMPOSITED)

    $hCDC = _WinAPI_CreateCompatibleDC($hDC)

    $tBI = DllStructCreate($tagBITMAPINFO)
    DllStructSetData($tBI, 'Size', DllStructGetSize($tBI) - 4)
    DllStructSetData($tBI, 'Width', DllStructGetData($tRc, 'Right') - DllStructGetData($tRc, 'Left'))
    DllStructSetData($tBI, 'Height', -(DllStructGetData($tRc, 'Bottom') - DllStructGetData($tRc, 'Top')))
    DllStructSetData($tBI, 'Planes', 1)
    DllStructSetData($tBI, 'BitCount', 32)
    DllStructSetData($tBI, 'Compression', 0) ; BI_RGB

    $hDIBBmp = _WinAPI_CreateDIBSection($hDC, $tBI)
    $hOldBmp = _WinAPI_SelectObject($hCDC, $hDIBBmp)
    If $hFont Then $hOldFont = _WinAPI_SelectObject($hCDC, $hFont)

    $tDTO = DllStructCreate($tagDTTOPTS)
    DllStructSetData($tDTO, 'Size', DllStructGetSize($tDTO))

    If $iTextClr <> -1 Then
        $iFlags = BitOR($iFlags, $DTT_TEXTCOLOR)
        DllStructSetData($tDTO, 'clrText', $iTextClr)
    EndIf

    DllStructSetData($tDTO, 'Flags', $iFlags)
    DllStructSetData($tDTO, 'GlowSize', $iGlowSize)

    _WinAPI_DrawThemeTextEx($hThemeData, $hCDC, 0, 0, $sText, _
            BitOR($DT_SINGLELINE, $DT_LEFT, $DT_TOP, $DT_NOPREFIX), $tRc, $tDTO)

    _WinAPI_BitBlt($hDC, DllStructGetData($tRc, 'Left'), DllStructGetData($tRc, 'Top'), _
            DllStructGetData($tRc, 'Right') - DllStructGetData($tRc, 'Left'), _
            DllStructGetData($tRc, 'Bottom') - DllStructGetData($tRc, 'Top'), $hCDC, 0, 0, 0xCC0020) ; SRCCOPY

    _WinAPI_SelectObject($hCDC, $hOldBmp)
    If $hFont Then _WinAPI_SelectObject($hCDC, $hOldFont)
    _WinAPI_DeleteObject($hDIBBmp)
    _WinAPI_DeleteDC($hCDC)
EndFunc   ;==>_DrawGlowingText

Func _GUICtrlHide($CtrlStart, $CtrlEnd)
    For $i = $CtrlStart To $CtrlEnd
        GUICtrlSetState($i, $GUI_HIDE)
    Next
EndFunc   ;==>_GUICtrlHide

Oh, and in case you were wondering, this is just a test program...


Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.

Share this post


Link to post
Share on other sites



Errors when trying to run your code(_WinAPI_OpenThemeData ... and others not being declared), maybe you are missing an #include?


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Oh they're some functions Authenticity used, and I integrated them into my WinAPI UDF...here are the functions:

Func _WinAPI_DwmExtendFrameIntoClientArea($hWnd, ByRef $tMargins)
    Local $aResult = DllCall("dwmapi.dll", "int", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", DllStructGetPtr($tMargins))

    If @error Then Return SetError(@error, @extended, -1)
    Return $aResult[0]
EndFunc

Func _WinAPI_DwmIsCompositionEnabled()
    Local $aResult = DllCall("dwmapi.dll", "int", "DwmIsCompositionEnabled", "int*", 0)

    If @error Then Return SetError(@error, @extended, -1)
    Return SetError($aResult[0], 0, $aResult[1])
EndFunc

Func _WinAPI_CreateDIBSection($hDC, Const ByRef $tBmpInfo, $iUsage = 0, $pBits = 0, $hSecond = 0, $iOffset = 0)
    Local $aResult = DllCall("gdi32.dll", "hwnd", "CreateDIBSection", "hwnd", $hDC, "ptr", DllStructGetPtr($tBmpInfo), _
                        "uint", $iUsage, "ptr", $pBits, "hwnd", $hSecond, "uint", $iOffset)
                        
    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] = 87 Then Return SetError(1, 1, 0); 87 = ERROR_INVALID_PARAMETER
    If $aResult[0] = 0 Then Return SetError(1, 2, 0)
    Return SetError(0, 0, $aResult[0])
EndFunc

Func _WinAPI_DrawThemeTextEx($hTheme, $hDC, $iPartId, $iStateId, $sText, $iFlags, ByRef $tRect, Const ByRef $tDTTOPTS)
    Local $aResult = DllCall("uxtheme.dll", "int", "DrawThemeTextEx", "ptr", $hTheme, "hwnd", $hDC, "int", $iPartId, "int", $iStateId, _
                        "wstr", $sText, "int", -1, "uint", $iFlags, "ptr", DllStructGetPtr($tRect), "ptr", DllStructGetPtr($tDTTOPTS))
                        
    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] <> 0 Then Return SetError(1, 0, 0)
    Return SetError(0, 0, $aResult[0] = 0)
EndFunc

Func _WinAPI_OpenThemeData($hWnd, $sClassList)
    Local $aResult = DllCall("uxtheme.dll", "hwnd", "OpenThemeData", "hwnd", $hWnd, "wstr", $sClassList)
    
    If @error Then Return SetError(@error, @extended, 0)
    If $aResult[0] = 0 Then Return SetError(1, 0, 0)
    Return SetError(0, 0, $aResult[0])
EndFunc

Func _WinAPI_CloseThemeData($hTheme)
    Local $aResult = DllCall("uxtheme.dll", "int", "CloseThemeData", "hwnd", $hTheme)
    
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError(0, 0, $aResult[0] = 0)
EndFunc

EDIT: The Controls(the "blah" labels)should hide when I click the "Personalities" button, but they don't. I have a feeling it has to do with the _WM_ERASEBKGND function...

Edited by Vadersapien

Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.

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