Sign in to follow this  
Followers 0
Yashied

Vista+ Header

3 posts in this topic

#1 ·  Posted (edited)

This is a simple example of using Windows Vista+ new styles and formats of Header control.

 

post_img_075.png

 

#Include <Constants.au3>
#Include <GUIConstantsEx.au3>
#Include <GUIHeader.au3>
#Include <GUIListView.au3>
#Include <GUIMenu.au3>
#Include <StructureConstants.au3>
#Include <WindowsConstants.au3>

; Vista+ format constants
Global Const $HDF_CHECKBOX = 0x00000040
Global Const $HDF_CHECKED = 0x00000080
Global Const $HDF_FIXEDWIDTH = 0x00000100
Global Const $HDF_SPLITBUTTON = 0x01000000

; Vista+ notification constants
Global Const $HDN_DROPDOWN = $HDN_FIRST - 18

$hForm = GUICreate('MyGUI', 400, 200)
$LV = GUICtrlCreateListView('Column1|Column2|Column3', 10, 10, 380, 180)

DllCall('uxtheme.dll', 'uint', 'SetWindowTheme', 'hwnd', GUICtrlGetHandle($LV), 'wstr', 'Explorer', 'ptr', 0)

$hHdr = _GUICtrlListView_GetHeader(-1)
$Format = _GUICtrlHeader_GetItemFormat($hHdr, 0)
_WinAPI_SetWindowLong($hHdr, $GWL_STYLE, BitOR(_WinAPI_GetWindowLong($hHdr, $GWL_STYLE), $HDS_CHECKBOXES))
_GUICtrlHeader_SetItemFormat($hHdr, 0, BitOR($Format, $HDF_SPLITBUTTON))
_GUICtrlHeader_SetItemWidth($hHdr, 0, 120)
_GUICtrlHeader_SetItemFormat($hHdr, 1, BitOR($Format, $HDF_SPLITBUTTON))
_GUICtrlHeader_SetItemWidth($hHdr, 1, 120)
_GUICtrlHeader_SetItemFormat($hHdr, 2, BitOR($Format, BitOR($HDF_CHECKBOX, $HDF_FIXEDWIDTH, $HDF_SPLITBUTTON)))
_GUICtrlHeader_SetItemWidth($hHdr, 2, 120)

$Dummy = GUICtrlCreateDummy()
$Menu = GUICtrlCreateContextMenu($Dummy)
GUICtrlCreateMenuItem('Item1', $Menu)
GUICtrlCreateMenuItem('Item2', $Menu)
GUICtrlCreateMenuItem('Item3', $Menu)
$Menu = GUICtrlGetHandle($Menu)

GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Dummy
            _GUICtrlMenu_TrackPopupMenu($Menu, $hForm)
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    Switch $hWnd
        Case $hForm

            Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
            Local $hWndFrom = DllStructGetData($tNMHDR, 'hWndFrom')
            Local $Code = DllStructGetData($tNMHDR, 'Code')

            Switch $hWndFrom
                Case $hHdr
                    If @AutoItX64 Then
                        Local $tNMHEADER = DllStructCreate('hwnd hWndFrom;uint_ptr IDFrom;int Code;uint Aligment;int Item;int Button;ptr pItem', $lParam)
                    Else
                        Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    EndIf
                    Local $tHDITEM = DllStructCreate($tagHDITEM, DllStructGetData($tNMHEADER, 'pItem'))
                    Local $Item = DllStructGetData($tNMHEADER, 'Item')

                    Switch $Code
                        Case $HDN_DROPDOWN
                            GUICtrlSendToDummy($Dummy, $Item)
                        Case $HDN_ITEMCHANGINGW
                            If BitAND(DllStructGetData($tHDITEM, 'Mask'), $HDI_FORMAT) Then
                                $Format = BitAND($Format, $HDF_CHECKED)
                                If BitXOR(BitAND(DllStructGetData($tHDITEM, 'Fmt'), $HDF_CHECKED), $Format) Then
                                    If $Format Then
                                        ConsoleWrite('Column' & ($Item + 1) & ': ' & 'Unchecked' & @CR)
                                    Else
                                        ConsoleWrite('Column' & ($Item + 1) & ': ' & 'Checked' & @CR)
                                    EndIf
                                EndIf
                            EndIf
                        Case $HDN_ITEMCHANGEDW
                            If BitAND(DllStructGetData($tHDITEM, 'Mask'), $HDI_FORMAT) Then
                                $Format = _GUICtrlHeader_GetItemFormat($hHdr, $Item)
                            EndIf
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Edited by Yashied

Share this post


Link to post
Share on other sites



Great Example!


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

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