# Function Reference

# _GUICtrlHeader_Create

Creates a Header control

#include <GuiHeader.au3>
_GUICtrlHeader_Create ( $hWnd [, $iStyle = 0x00000046] )

## Parameters

$hWnd | Handle to parent or owner window
$iStyle | [optional] Control styles: $HDS_BUTTONS - Each item in the control looks and behaves like a push button $HDS_DRAGDROP - Allows drag-and-drop reordering of header items $HDS_FILTERBAR - Include a filter bar as part of the standard header control $HDS_FLAT - Causes the header control to be drawn flat $HDS_FULLDRAG - Causes the header control to display column contents $HDS_HIDDEN - Indicates a header control that is intended to be hidden $HDS_HORZ - Creates a header control with a horizontal orientation $HDS_HOTTRACK - Enables hot tracking Default: $HDS_BUTTONS, $HDS_HOTTRACK, $HDS_DRAGDROP Forced : $WS_CHILD, $WS_VISIBLE

## Return Value

Success: | Handle to the Header control
Failure: | 0, @error can be set (see remark)

## Remarks

If $hWnd referenced Window is not in the same process, the @error is set to 4.

## Related

_GUICtrlHeader_Destroy

## Example

### Example 1

    #include "Extras\HelpFileInternals.au3"
    #include "Extras\WM_NOTIFY.au3"

    #include <GUIConstantsEx.au3>
    #include <GuiHeader.au3>
    #include <StructureConstants.au3>
    #include <WindowsStylesConstants.au3>

    Global $g_hHeader

    Example()

    Func Example()
        ; Create GUI
        Local $hGUI = GUICreate("Header Create (v" & @AutoItVersion & ")", 450, 300, 100, 100)
        $g_hHeader = _GUICtrlHeader_Create($hGUI)
        _MemoCreate(2, 37, 444, 229)

    ;~  _GUICtrlHeader_SetUnicodeFormat($g_hHeader, False)

        GUISetState(@SW_SHOW)

        _WM_NOTIFY_Register($_g_idLst_Memo)

        ; Add columns
        _GUICtrlHeader_AddItem($g_hHeader, "Column 0", 100)
        _GUICtrlHeader_AddItem($g_hHeader, "Column 1", 100)
        _GUICtrlHeader_AddItem($g_hHeader, "Column 2", 100)
        _GUICtrlHeader_AddItem($g_hHeader, "Column 3", 100)

        ; Clear all filters
        _GUICtrlHeader_ClearFilterAll($g_hHeader)

        _MemoMsgBoxStatus("", -1, $hGUI) ; no more action, wait GUI for closing

    EndFunc   ;==>Example

    Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
        #forceref $hWnd, $iMsg, $wParam

        Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
        Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
        Local $iCode = DllStructGetData($tNMHDR, "Code")
        Switch $hWndFrom
            Case $g_hHeader
                Switch $iCode
                    Case $HDN_BEGINDRAG ; Sent by a header control when a drag operation has begun on one of its items
                        _WM_NOTIFY_DebugEvent("$HDN_BEGINDRAG", $tagNMHEADER, $lParam, "IDFrom,,Item,Button")
                        Return False ; To allow the header control to automatically manage drag-and-drop operations
                        ; Return True  ; To indicate external (manual) drag-and-drop management allows the owner of the
                        ; control to provide custom services as part of the drag-and-drop process
                    Case $HDN_BEGINTRACK, $HDN_BEGINTRACKW ; Notifies a header control's parent window that the user has begun dragging a divider in the control
                        _WM_NOTIFY_DebugEvent("$HDN_BEGINTRACK", $tagNMHEADER, $lParam, "IDFrom,,Item,Button")
                        Return False ; To allow tracking of the divider
                        ; Return True  ; To prevent tracking
                    Case $HDN_DIVIDERDBLCLICK, $HDN_DIVIDERDBLCLICKW ; Notifies a header control's parent window that the user double-clicked the divider area of the control
                        _WM_NOTIFY_DebugEvent("$HDN_DIVIDERDBLCLICK", $tagNMHEADER, $lParam, "IDFrom,,Item,Button")
                        ; no return value
                    Case $HDN_ENDDRAG ; Sent by a header control when a drag operation has ended on one of its items
                        _WM_NOTIFY_DebugEvent("$HDN_ENDDRAG", $tagNMHEADER, $lParam, "IDFrom,,Item,Button")
                        Return False ; To allow the control to automatically place and reorder the item
                        ; Return True  ; To prevent the item from being placed
                    Case $HDN_ENDTRACK, $HDN_ENDTRACKW ; Notifies a header control's parent window that the user has finished dragging a divider
                        _WM_NOTIFY_DebugEvent("$HDN_ENDTRACK", $tagNMHEADER, $lParam, "IDFrom,,Item,Button")
                        ; no return value
                    Case $HDN_FILTERBTNCLICK ; Notifies the header control's parent window when the filter button is clicked or in response to an $HDM_SETITEM message
                        _WM_NOTIFY_DebugEvent("$HDN_FILTERBTNCLICK", $tagNMHDFILTERBTNCLICK, $lParam, "IDFrom,,Item,Left,Top,Right,Bottom")
                        ; Return True  ; An $HDN_FILTERCHANGE notification will be sent to the header control's parent window
                        ; This notification gives the parent window an opportunity to synchronize its user interface elements
                        Return False ; If you do not want the notification sent
                    Case $HDN_FILTERCHANGE ; Notifies the header control's parent window that the attributes of a header control filter are being changed or edited
                        _WM_NOTIFY_DebugEvent("$HDN_FILTERCHANGE", $tagNMHEADER, $lParam, "IDFrom,,Item,Button")
                        ; no return value
                    Case $HDN_GETDISPINFO, $HDN_GETDISPINFOW ; Sent to the owner of a header control when the control needs information about a callback header item
                        _WM_NOTIFY_DebugEvent("$HDN_GETDISPINFO", $tagNMHDDISPINFO, $lParam, "IDFrom,Item")
                        ; Return LRESULT
                    Case $HDN_ITEMCHANGED, $HDN_ITEMCHANGEDW ; Notifies a header control's parent window that the attributes of a header item have changed
                        _WM_NOTIFY_DebugEvent("$HDN_ITEMCHANGED", $tagNMHEADER, $lParam, "IDFrom,,Item,Button")
                        ; no return value
                    Case $HDN_ITEMCHANGING, $HDN_ITEMCHANGINGW ; Notifies a header control's parent window that the attributes of a header item are about to change
                        _WM_NOTIFY_DebugEvent("$HDN_ITEMCHANGING", $tagNMHEADER, $lParam, "IDFrom,,Item,Button")
                        Return False ; To allow the changes
                        ; Return True  ; To prevent them
                    Case $HDN_ITEMCLICK, $HDN_ITEMCLICKW ; Notifies a header control's parent window that the user clicked the control
                        _WM_NOTIFY_DebugEvent("$HDN_ITEMCLICK", $tagNMHEADER, $lParam, "IDFrom,,Item,Button")
                        ; no return value
                    Case $HDN_ITEMDBLCLICK, $HDN_ITEMDBLCLICKW ; Notifies a header control's parent window that the user double-clicked the control
                        _WM_NOTIFY_DebugEvent("$HDN_ITEMDBLCLICK", $tagNMHEADER, $lParam, "IDFrom,,Item,Button")
                        ; no return value
                    Case $HDN_TRACK, $HDN_TRACKW ; Notifies a header control's parent window that the user is dragging a divider in the header control
                        _WM_NOTIFY_DebugEvent("$HDN_TRACK", $tagNMHEADER, $lParam, "IDFrom,,Item,Button")
                        Return False ; To continue tracking the divider
                        ; Return True  ; To end tracking
                EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
    EndFunc   ;==>WM_NOTIFY

### Example 2 : Header Create to an External process

    #include "Extras\HelpFileInternals.au3"

    #include <GuiHeader.au3>

    Example()

    Func Example()
        Local $sFromTo
        Local $hWin = _MemoRunAU3OutProcess($sFromTo, True)

        Local $hHeader = _MemoCreateOutProcess($hWin, "SysHeader32", 0, $sFromTo)

        _GUICtrlHeader_Destroy($hHeader)
        If @error Then _MemoWrite("_GUICtrlHeader_Destroy()" & " @error = " & @error & @CRLF & _
                @TAB & "cannot be retrieved by an external process")

        _GUICtrlHeader_Create($hWin)
        If @error Then _MemoWrite("_GUICtrlHeader_Create()" & " @error = " & @error & @CRLF & _
                @TAB & "cannot be retrieved by an external process")

        _MemoMsgBoxStatus("", Default, $hWin) ; no more action, wait GUI for closing, close also OutProcess GUI

    EndFunc   ;==>Example