Sign in to follow this  
Followers 0
DicatoroftheUSA

guiframe+accelerators=No go?

10 posts in this topic

#1 ·  Posted (edited)

I was playing with guiframe udf and it seems like it breaks accelerators. Meaning Alt+"underlined letter" does nothing. What am I missing? Below is what I am having trouble with.

I do not like to use hotkeys because I think they are they make the script look sloppy, interfering and hard to follow IMHO. BTW not using accelerators is not an option, mouses are for "slow" people, I would rather give up go home and cry than use the mouse. /melodramatics

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include "GUIFrame.au3"
#include <Array.au3>
;~ Glbal $iSep_Pos
#include <Misc.au3>
#include<string.au3>
;~ #include<_CArray.au3>
If _Singleton("Single", 1) = 0 Then ;only on instance running
Exit
EndIf

_main()
Func _main()
_GuiCreate()
EndFunc   ;==>_main
Func _GuiCreate()
Local $aAccelartors[1]
$hGUI = GUICreate("GUI_Frame Example 1", @DesktopWidth, @DesktopHeight, -1, -1, BitOR($WS_MAXIMIZE, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetState()

$hMenu=GUICtrlCreateMenu(_EasyAccelerator($aAccelartors,"Title"))
; Create a 1st level frame
$iFrame_Main = _GUIFrame_Create($hGUI, 0, 200)
_GUIFrame_SetMin($iFrame_Main, 50, 100)
_GUIFrame_Switch($iFrame_Main, 2)
$aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_Main, 2))
;~ GUICtrlCreateLabel("", 5, 5, $aWinSize[0] - 5, $aWinSize[1] - 5)
;~ GUICtrlSetBkColor(-1, 0xFF0000)
;~ GUICtrlSetState(-1, $GUI_DISABLE)
$hButton_1 = GUICtrlCreateButton(_EasyAccelerator($aAccelartors,"Pos Sep"), 10, 10, 50, 30)
; Create a 2nd level frame Left
$iFrame_Left = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_Main, 1), 1, $aWinSize[1] * .7)
GUISetBkColor(0x00FF00, _GUIFrame_GetHandle($iFrame_Left, 1))
_GUIFrame_SetMin($iFrame_Left, 10, 10)
_GUIFrame_Switch($iFrame_Left, 1)
$hButton_2 = GUICtrlCreateButton("Po&s Sep", 10, 10, 50, 30)

; Create a 2nd level frame Left
$iFrame_Right = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_Main, 2), 1)
GUISetBkColor(0x00FF00, _GUIFrame_GetHandle($iFrame_Right, 1))
_GUIFrame_SetMin($iFrame_Right, 10, 10)
_GUIFrame_Switch($iFrame_Right, 2)
;~  $hButton_3 = GUICtrlCreateButton(_EasyAccelerator($aAccelartors,"Pos Sep"), 10, 10, 50, 30)

_GUIFrame_ResizeSet(0)

_GUIFrame_ResizeReg()
While 1
  Switch GUIGetMsg()
   Case $GUI_EVENT_CLOSE
    ; The UDF does all the tidying up as you exit
    Exit
  Case $hMenu
  MsgBox(0,"",'arg')
Case $hButton_1
  MsgBox(0,"","Oh nohz! You clicked button 1")
Case $hButton_2
  MsgBox(0,"",'barf')
;~  $iRet = _GUIFrame_SetSepPos($iFrame_Left, 310)
;~  $iSep_Pos = _GUIFrame_GetSepPos($iFrame_Left)
;~  GUICtrlSetData($hButton_2, $iSep_Pos)
    Sleep(1000)
;~  GUICtrlSetData($hButton_2, "Sep Pos")
  EndSwitch
WEnd
EndFunc   ;==>_GuiCreate
Func _EasyAccelerator(ByRef $aEasyAccelerator,  $sTitleString)
_ArraySort($aEasyAccelerator)
;~  _CArray($aEasyAccelerator)
For $iX = 1 To StringLen($sTitleString)
  $sLetter = StringMid($sTitleString, $iX, 1)
  _log(_ArrayBinarySearch($aEasyAccelerator, $sLetter))
  If  _ArrayBinarySearch($aEasyAccelerator, $sLetter)=-1 Then
   _ArrayAdd($aEasyAccelerator, $sLetter)
   $sTitleString=_StringInsert($sTitleString,"&",$ix-1)
   Return ($sTitleString)
  Else
   ContinueLoop
  EndIf
Next
Return $aEasyAccelerator
EndFunc   ;==>_EasyAccelerator
func _log($sMSG)
ConsoleWrite(@lf&$sMSG)
EndFunc

below is a repost of the guiframe UDF

#include-once
; #INDEX# ============================================================================================================
; Title .........: GUIFrame
; AutoIt Version : 3.3 +
; Language ......: English
; Description ...: Splits a GUI into slideable and resizable 2 part frames which can be further split if required
; Remarks .......: - The UDF uses OnAutoItExitRegister to call _GUIFrame_Exit to delete subclassed separator bars
;                   using the UDF created WndProc and to release the Callback on exit
;                 - If the script already has a WM_SIZE handler then do NOT use _GUIFrame_ResizeReg,
;                   but call _GUIFrame_SIZE_Handler from within the existing handler
; Author ........: Original UDF by Kip
; Modified ......; This version by Melba23 - using x64 compatible code drawn from Yashied's WinAPIEx library
; ====================================================================================================================
;#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
; #INCLUDES# =========================================================================================================
#include <WinAPI.au3>
; #GLOBAL VARIABLES# =================================================================================================
; Array to hold handles for each frame set
Global $aGF_HandleIndex[1][7]
; [0][0] = 0 ; Count of frames    [0][1] = Move registered flag
; [n][0] = Parent GUI handle        [n][4] = Original GUI handle
; [n][1] = First frame handle      [n][5] = Indices of first frame internal frames
; [n][2] = Second frame handle    [n][6] = Indices of second frame internal frames
; [n][3] = Separator bar handle
; Array to hold sizing percentages for each frame set
Global $aGF_SizingIndex[1][6]
; [n][0] = First frame min    [n][2] = X coord  [n][4] = Width
; [n][1] = Second frame min  [n][3] = Y coord   [n][5] = Height
; Array to hold other settings for each frame set
Global $aGF_SettingsIndex[1][3]
; [n][0] = Separator orientation (vert/horz = 0/1)
; [n][1] = Resizable frame flag (0/1)
; [n][2] = Separator size (default = 5)
; Array to hold WinProc handles for each separator
Global $aGF_SepProcIndex[1][2] = [[0, 0]]
; Store registered Callback handle
Global $hGF_RegCallBack = DllCallbackRegister("_GUIFrame_SepWndProc", "lresult", "hwnd;uint;wparam;lparam")
$aGF_SepProcIndex[0][1] = DllCallbackGetPtr($hGF_RegCallBack)
; #ONAUTOITEXIT FUNCTIONS# ===========================================================================================
OnAutoItExitRegister("_GUIFrame_Exit")
; #CURRENT# ==========================================================================================================
; _GUIFrame_Create:    Splits a GUI into 2 frames
; _GUIFrame_SetMin:    Sets minimum sizes for each frame
; _GUIFrame_ResizeSet:  Sets resizing flag for all or specified frame sets
; _GUIFrame_GetHandle:  Returns the handle of a frame element (required for further splitting)
; _GUIFrame_Switch:    Sets a frame element as current GUI
; _GUIFrame_GetSepPos:  Returns the current position of the separator
; _GUIFrame_SetSepPos:  Moves the separator bar to adjust frame sizes
; _GUIFrame_ResizeReg:  Registers WM_SIZE message for resizing
; _GUIFrame_SIZE_Handler: Called from a WM_SIZE message handler to resize frames using _GUIFrame_Move
; ====================================================================================================================
; #INTERNAL_USE_ONLY#=================================================================================================
; _GUIFrame_SepSubClass:   Sets new WndProc for frame separator bar
; _GUIFrame_SepWndProc: New WndProc for frame separator bar
; _GUIFrame_SepPassMsg: Passes Msg to original frame WndProc for action
; _GUIFrame_Move:         Moves and resizes frame elements and separator bars
; _GUIFrame_Exit:         Deletes all subclassed separator bars to free UDF WndProc and frees registered callback handle
; ====================================================================================================================
; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_Create
; Description ...: Splits a GUI into 2 frames
; Syntax.........: _GUIFrame_Create($hWnd, $iSepOrient = 0, $iSepPos = 0, $iSepSize = 5, $iX = 0, $iY = 0, $iWidth = 0, $iHeight = 0, $iStyle = 0, $iExStyle = 0)
; Parameters ....: $hWnd - Handle of GUI to split
;                 $iSepOrient - Orientation of separator bar: 0 = Vertical (default), 1 = Horizontal
;                 $iSepPos - Required initial position of separator (default = centre of frame GUI)
;                 $iSepSize - Size of separator bar (default = 5, min = 3, max = 9)
;                 $iX - Left of frame area (default = 0)
;                 $iY - Top of frame area (default = 0)
;                 $iWidth - Width of frame area (default = full width)
;                 $iHeight - Height of frame area (default = full height)
;                 SiStyle - Required style value for frame elements
;                 SiExStyle - Required extended style value for frame elements
; Requirement(s).: v3.3 +
; Return values .: Success:  Returns index number of frame/separator set
;                 Failure:  Returns 0 and sets @error as follows:
;                 1 = Child limit exceeded
;                 2 = GUI creation failed
;                 2 = Separator subclassing failed
; Author ........: Kip
; Modified ......: Melba23
; Remarks .......:
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_Create($hWnd, $iSepOrient = 0, $iSepPos = 0, $iSepSize = 5, $iX = 0, $iY = 0, $iOrg_Width = 0, $iOrg_Height = 0, $iStyle = 0, $iExStyle = 0)
    Local $iSeperator_Pos, $hSeparator, $hFirstFrame, $hSecondFrame
    ; Set separator size
    Local $iSeparatorSize = 5
    Switch $iSepSize
        Case 3 To 9
            $iSeparatorSize = $iSepSize
    EndSwitch
    ; Set default sizing if no parameters set
    Local $iWidth = $iOrg_Width
    Local $iHeight = $iOrg_Height
    Local $aFullSize = WinGetClientSize($hWnd)
    If Not $iOrg_Width Then $iWidth = $aFullSize[0]
    If Not $iOrg_Height Then $iHeight = $aFullSize[1]
    ; Create parent GUI within client area
    Local $hParent = GUICreate("FrameParent", $iWidth, $iHeight, $iX, $iY, BitOR(0x40000000, $iStyle), $iExStyle, $hWnd) ; $WS_CHILD
    GUISetState(@SW_SHOW, $hParent)
    ; Confirm size of frame parent client area
    Local $aSize = WinGetClientSize($hParent)
    $iWidth = $aSize[0]
    $iHeight = $aSize[1]
    If $iSepOrient = 0 Then
        ; Set initial separator position
        $iSeperator_Pos = $iSepPos
        ; Adjust position if not within GUI or default set (=0)
        If $iSepPos > $iWidth Or $iSepPos < 1 Then
            $iSeperator_Pos = Round(($iWidth / 2) - ($iSeparatorSize / 2))
        EndIf
        ; Create separator bar and force cursor change over separator
        $hSeparator = GUICreate("", $iSeparatorSize, $iHeight, $iSeperator_Pos, 0, 0x40000000, -1, $hParent) ;$WS_CHILD
        GUICtrlCreateLabel("", 0, 0, $iSeparatorSize, $iHeight, -1, 0x00000001) ; $WS_EX_DLGMODALFRAME
        GUICtrlSetCursor(-1, 13)
        GUISetState(@SW_SHOW, $hSeparator)
        ; Create the sizable frames
        $hFirstFrame = GUICreate("", $iSeperator_Pos, $iHeight, 0, 0, 0x40000000, -1, $hParent) ;$WS_CHILD
        GUISetState(@SW_SHOW, $hFirstFrame)
        $hSecondFrame = GUICreate("", $iWidth - ($iSeperator_Pos + $iSeparatorSize), $iHeight, $iSeperator_Pos + $iSeparatorSize, 0, 0x40000000, -1, $hParent) ;$WS_CHILD
        GUISetState(@SW_SHOW, $hSecondFrame)
    Else
        $iSeperator_Pos = $iSepPos
        If $iSepPos > $iHeight Or $iSepPos < 1 Then
            $iSeperator_Pos = Round(($iHeight / 2) - ($iSeparatorSize / 2))
        EndIf
        $hSeparator = GUICreate("", $iWidth, $iSeparatorSize, 0, $iSeperator_Pos, 0x40000000, -1, $hParent) ;$WS_CHILD
        GUICtrlCreateLabel("", 0, 0, $iWidth, $iSeparatorSize, -1, 0x01) ; $WS_EX_DLGMODALFRAME
        GUICtrlSetCursor(-1, 11)
        GUISetState(@SW_SHOW, $hSeparator)
        $hFirstFrame = GUICreate("", $iWidth, $iSeperator_Pos, 0, 0, 0x40000000, -1, $hParent) ;$WS_CHILD
        GUISetState(@SW_SHOW, $hFirstFrame)
        $hSecondFrame = GUICreate("", $iWidth, $iHeight - ($iSeperator_Pos + $iSeparatorSize), 0, $iSeperator_Pos + $iSeparatorSize, 0x40000000, -1, $hParent) ;$WS_CHILD
        GUISetState(@SW_SHOW, $hSecondFrame)
    EndIf
    ; Check for error creating GUIs
    If $hParent = 0 Or $hSeparator = 0 Or $hFirstFrame = 0 Or $hSecondFrame = 0 Then
        ; Delete all GUIs and return error
        GUICreate($hParent)
        GUIDelete($hSeparator)
        GUIDelete($hFirstFrame)
        GUICreate($hSecondFrame)
        Return SetError(2, 0, 0)
    EndIf
    ; Subclass the separator
    If _GUIFrame_SepSubClass($hSeparator) = 0 Then
        ; If Subclassing failed then delete all GUIs and return error
        GUICreate($hParent)
        GUIDelete($hSeparator)
        GUIDelete($hFirstFrame)
        GUICreate($hSecondFrame)
        Return SetError(3, 0, 0)
    EndIf
    ; Create new lines in the storage arrays for this frame set
    Local $iIndex = $aGF_HandleIndex[0][0] + 1
    ReDim $aGF_HandleIndex[$iIndex + 1][7]
    ReDim $aGF_SizingIndex[$iIndex + 1][6]
    ReDim $aGF_SettingsIndex[$iIndex + 1][3]
    ; Store this frame set handles/variables/defaults in the new lines
    $aGF_HandleIndex[0][0] = $iIndex
    $aGF_HandleIndex[$iIndex][0] = $hParent
    $aGF_HandleIndex[$iIndex][1] = $hFirstFrame
    $aGF_HandleIndex[$iIndex][2] = $hSecondFrame
    $aGF_HandleIndex[$iIndex][3] = $hSeparator
    $aGF_HandleIndex[$iIndex][4] = $hWnd
    $aGF_HandleIndex[$iIndex][5] = 0
    $aGF_HandleIndex[$iIndex][6] = 0
    $aGF_SizingIndex[$iIndex][0] = 0
    $aGF_SizingIndex[$iIndex][1] = 0
    $aGF_SettingsIndex[$iIndex][0] = $iSepOrient
    $aGF_SettingsIndex[$iIndex][1] = 0
    $aGF_SettingsIndex[$iIndex][2] = $iSeparatorSize
    ; Store this frame index in parent line if parent is an existing frame
    For $i = 1 To $aGF_HandleIndex[0][0] - 1
        If $aGF_HandleIndex[$i][1] = $hWnd Then
            If $aGF_HandleIndex[$i][5] = 0 Then
                $aGF_HandleIndex[$i][5] = $iIndex
            Else
                $aGF_HandleIndex[$i][5] &= "|" & $iIndex
            EndIf
            ExitLoop
        EndIf
        If $aGF_HandleIndex[$i][2] = $hWnd Then
            If $aGF_HandleIndex[$i][6] = 0 Then
                $aGF_HandleIndex[$i][6] = $iIndex
            Else
                $aGF_HandleIndex[$i][6] &= "|" & $iIndex
            EndIf
            ExitLoop
        EndIf
    Next
    ; Store coordinate and size fractions
    If $iX Then
        $aGF_SizingIndex[$iIndex][2] = $iX / $aFullSize[0]
    Else
        $aGF_SizingIndex[$iIndex][2] = 0
    EndIf
    If $iY Then
        $aGF_SizingIndex[$iIndex][3] = $iY / $aFullSize[1]
    Else
        $aGF_SizingIndex[$iIndex][3] = 0
    EndIf
    If $iOrg_Width Then
        $aGF_SizingIndex[$iIndex][4] = $iOrg_Width / $aFullSize[0]
    Else
        $aGF_SizingIndex[$iIndex][4] = 1
    EndIf
    If $iOrg_Height Then
        $aGF_SizingIndex[$iIndex][5] = $iOrg_Height / $aFullSize[1]
    Else
        $aGF_SizingIndex[$iIndex][5] = 1
    EndIf
    ; Switch back to main GUI
    GUISwitch($hWnd)
    ; Return the index for this frame
    Return $iIndex
EndFunc   ;==>_GUIFrame_Create
; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_SetMin
; Description ...: Sets minimum sizes for frames
; Syntax.........: _GUIFrame_SetMin($iFrame, $iFirstMin = 0, $iSecondMin = 0)
; Parameters ....: $iFrame - Index of frame set as returned by _GUIFrame_Create
;                 $iFirstMin - Min size of first (left/top) frame - max half size
;                 $iSecondMin - Min Size of second (right/bottom) frame - max half size
; Requirement(s).: v3.3 +
; Return values .: None
; Author ........: Melba23 based on some original code by Kip
; Modified ......:
; Remarks .......: If the frame is resized, these minima are adjusted accordingly
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_SetMin($iFrame, $iFirstMin = 0, $iSecondMin = 0)
    ; Check for valid frame index
    If $iFrame < 1 Or $iFrame > $aGF_HandleIndex[0][0] Then Return 0
    ; Get size of parent
    Local $aSize = WinGetClientSize($aGF_HandleIndex[$iFrame][0])
    ; Now check orientation and determine
    Local $iMax, $iFullSize
    If $aGF_SettingsIndex[$iFrame][0] = 0 Then
        $iMax = Floor(($aSize[0] / 2) - $aGF_SettingsIndex[$iFrame][2])
        $iFullSize = $aSize[0]
    Else
        $iMax = Floor(($aSize[1] / 2) - $aGF_SettingsIndex[$iFrame][2])
        $iFullSize = $aSize[1]
    EndIf
    ; Set minimums
    If $iFirstMin > $iMax Then
        $aGF_SizingIndex[$iFrame][0] = $iMax / $iFullSize
    Else
        $aGF_SizingIndex[$iFrame][0] = $iFirstMin / $iFullSize
    EndIf
    If $iSecondMin > $iMax Then
        $aGF_SizingIndex[$iFrame][1] = $iMax / $iFullSize
    Else
        $aGF_SizingIndex[$iFrame][1] = $iSecondMin / $iFullSize
    EndIf
EndFunc   ;==>_GUIFrame_SetMin
; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_ResizeSet
; Description ...: Sets resizing flag for frames
; Syntax.........: _GUIFrame_ResizeSet($iFrame = 0)
; Parameters ....: $iFrame - Index of frame set as returned by _GUIFrame_Create
;                 (Default - 0 = all existing frames)
; Requirement(s).: v3.3 +
; Return values .: Success: 2 - All existing frame flags set
;                          1 - Specified flag set
;                 Failure: 0 with @error set to 1 - Invalid frame specified
; Author ........: Melba23
; Modified ......:
; Remarks .......:
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_ResizeSet($iFrame = 0)
    Switch $iFrame
        Case 0 ; Set all frames
            For $i = 1 To $aGF_HandleIndex[0][0]
                $aGF_SettingsIndex[$i][1] = 1
            Next
            Return 2
        Case 1 To $aGF_HandleIndex[0][0] ; Only valid frames accepted
            $aGF_SettingsIndex[$iFrame][1] = 1
            Return 1
        Case Else ; Error
            Return SetError(1, 0, 0)
    EndSwitch
EndFunc   ;==>_GUIFrame_ResizeSet
; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_GetHandle
; Description ...: Returns the handle of a frame element (required for further splitting)
; Syntax.........: _GUIFrame_GetHandle($iFrame, $iElement)
; Parameters ....: $iFrame - Index of frame set as returned by _GUIFrame_Create
;                 $iElement - 1 = first (left/top) frame, 2 = second (right/bottom) frame
; Requirement(s).: v3.3 +
; Return values .: Success: Handle of frame
;                 Failure: 0 with @error set as follows
;                          1 - Invalid frame specified
;                          2 - Invalid element specified
; Author ........: Kip
; Modified ......: Melba23
; Remarks .......: _GUIFrame_Create requires a GUI handle as a parameter
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_GetHandle($iFrame, $iElement)
    ; Check valid frame index and element
    Switch $iFrame
        Case 1 To $aGF_HandleIndex[0][0]
            Switch $iElement
                Case 1, 2
                    ; Return handle
                    Return $aGF_HandleIndex[$iFrame][$iElement]
            EndSwitch
            Return SetError(2, 0, 0)
    EndSwitch
    Return SetError(1, 0, 0)
EndFunc   ;==>_GUIFrame_GetHandle
; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_Switch
; Description ...: Sets a frame element as current GUI
; Syntax.........: _GUIFrame_Switch($iFrame, $iElement)
; Parameters ....: $iFrame - Index of frame set as returned by _GUIFrame_Create
;                 $iElement - 1 = first (left/top) frame, 2 = second (right/bottom) frame
; Requirement(s).: v3.3 +
; Return values .: None
; Author ........: Kip
; Modified ......: Melba23
; Remarks .......: Subsequent controls are created in the specified frame element
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_Switch($iFrame, $iElement)
    ; Check valid frame index and element
    Switch $iFrame
        Case 1 To $aGF_HandleIndex[0][0]
            Switch $iElement
                Case 1, 2
                    ; Switch to specified element
                    Return GUISwitch($aGF_HandleIndex[$iFrame][$iElement])
            EndSwitch
            Return SetError(2, 0, 0)
    EndSwitch
    Return SetError(1, 0, 0)
EndFunc   ;==>_GUIFrame_Switch
; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_GetSepPos()
; Description ...: Returns the current position of the separator
; Syntax.........: _GUIFrame_GetSepPos($iFrame)
; Parameters ....: $iFrame - Index of frame set as returned by _GUIFrame_Create
; Requirement(s).: v3.3 +
; Return values .: Success: Position of separator
;                 Failure: -1 = Invalid frame specified
; Author ........: Melba23
; Remarks .......: This value can be stored and used as the initial separator position parameter in _GUIFrame_Create
;                 to restore exit position on restart
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_GetSepPos($iFrame)
    Local $iSepPos
    ; Check for valid frame index
    If $iFrame < 1 Or $iFrame > $aGF_HandleIndex[0][0] Then Return -1
    ; Get position of first frame
    Local $aFrame_Pos = WinGetPos($aGF_HandleIndex[$iFrame][1])
    ; Get position of separator
    Local $aSep_Pos = WinGetPos($aGF_HandleIndex[$iFrame][3])
    ; Check on separator orientation
    If $aGF_SettingsIndex[$iFrame][0] Then
        $iSepPos = $aSep_Pos[1] - $aFrame_Pos[1]
    Else
        $iSepPos = $aSep_Pos[0] - $aFrame_Pos[0]
    EndIf
    Return $iSepPos
EndFunc
; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_SetSepPos()
; Description ...: Moves the separator bar to adjust frame sizes
; Syntax.........: _GUIFrame_SetSepPos($iFrame, $iSepPos)
; Parameters ....: $iFrame - Index of frame set as returned by _GUIFrame_Create
;                 $iSepos - Position of separator bar within frame
; Requirement(s).: v3.3 +
; Return values .: Success: 1
;                 Failure: 0 with @error set as follows
;                          1 - Invalid frame specified
;                          2 - Invalid separator position (outside frame)
;                          3 - Invalid separator position (below frame minimum size)
; Author ........: Melba23
; Remarks .......: This value can be stored and used as the initial separator position parameter in _GUIFrame_Create
;                 to restore exit position on restart
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_SetSepPos($iFrame, $iSepPos)
    Local $iFirstMin, $iSecondMin
    ; Check for valid frame index
    If $iFrame < 1 Or $iFrame > $aGF_HandleIndex[0][0] Then Return SetError(1, 0, 0)
    ; Check separator actually needs to move
    If $iSepPos = _GUIFrame_GetSepPos($iFrame) Then Return 1
    ; Get frame GUI size
    Local $aWinPos = WinGetPos($aGF_HandleIndex[$iFrame][0])
    ; Depending on separator orientation
    If $aGF_SettingsIndex[$iFrame][0] Then
        ; Check sep position is valid
        If $iSepPos < 0 Or $iSepPos > $aWinPos[3] Then Return SetError(2, 0, 0)
        ; Determine minima for frames
        $iFirstMin = $aWinPos[3] * $aGF_SizingIndex[$iFrame][0]
        $iSecondMin = ($aWinPos[3] * (1 - $aGF_SizingIndex[$iFrame][1])) - $aGF_SettingsIndex[$iFrame][2]
        ; Check required value is valid
        If $iSepPos < $iFirstMin Or $iSepPos > $iSecondMin Then Return SetError(3, 0, 0)
        ; Move frames and seperator
        WinMove($aGF_HandleIndex[$iFrame][1], "", 0, 0, $aWinPos[2], $iSepPos)
        WinMove($aGF_HandleIndex[$iFrame][2], "", 0, $iSepPos + $aGF_SettingsIndex[$iFrame][2], $aWinPos[2], $aWinPos[3] - ($iSepPos + $aGF_SettingsIndex[$iFrame][2]))
        WinMove($aGF_HandleIndex[$iFrame][3], "", 0, $iSepPos, $aWinPos[2], $aGF_SettingsIndex[$iFrame][2])
    Else
        If $iSepPos < 0 Or $iSepPos > $aWinPos[2] Then Return SetError(2, 0, 0)
        $iFirstMin = $aWinPos[2] * $aGF_SizingIndex[$iFrame][0]
        $iSecondMin = ($aWinPos[2] * (1 - $aGF_SizingIndex[$iFrame][1])) - $aGF_SettingsIndex[$iFrame][2]
        If $iSepPos < $iFirstMin Or $iSepPos > $iSecondMin Then Return SetError(3, 0, 0)
        WinMove($aGF_HandleIndex[$iFrame][1], "", 0, 0, $iSepPos, $aWinPos[3])
        WinMove($aGF_HandleIndex[$iFrame][2], "", $iSepPos + $aGF_SettingsIndex[$iFrame][2], 0, $aWinPos[2] - ($iSepPos + $aGF_SettingsIndex[$iFrame][2]), $aWinPos[3])
        WinMove($aGF_HandleIndex[$iFrame][3], "", $iSepPos, 0, $aGF_SettingsIndex[$iFrame][2], $aWinPos[3])
    EndIf
    Return 1
EndFunc
; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_ResizeReg
; Description ...: Registers WM_SIZE message for resizing
; Syntax.........: _GUIFrame_ResizeReg()
; Parameters ....: None
; Requirement(s).: v3.3 +
; Return values .: Success: 1 - Message handler registered
;                 Failure: 0 with @error set to 1 - Message handler already registered
; Author ........: Melba23
; Modified ......:
; Remarks .......:
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_ResizeReg()
    ; Register the WM_SIZE message
    If $aGF_HandleIndex[0][1] = 0 Then
        Local $iRet = GUIRegisterMsg(0x05, "_GUIFrame_SIZE_Handler") ; $WM_SIZE
        If $iRet Then
            $aGF_HandleIndex[0][1] = 1
            Return 1
        EndIf
    EndIf
    Return SetError(1, 0, 0)
EndFunc   ;==>_GUIFrame_ResizeReg
; #FUNCTION# =========================================================================================================
; Name...........: _GUIFrame_SIZE_Handler
; Description ...: Used to resize frames when resizing of holding GUI occurs
; Syntax.........: _GUIFrame_SIZE_Handler($hWnd, $iMsg, $wParam, $lParam)
; Parameters ....: None
; Requirement(s).: v3.3 +
; Return values .: None
; Author ........: Melba23
; Modified ......:
; Remarks .......: If the script already has a WM_SIZE handler, then just call this function from within it
;                 and do NOT use the _GUIFrame_ResizeReg function
; Example........: Yes
;=====================================================================================================================
Func _GUIFrame_SIZE_Handler($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam
    Local $iIndex
    ; Get index of base frame GUI
    For $iIndex = 1 To $aGF_HandleIndex[0][0]
        If $aGF_HandleIndex[$iIndex][4] = $hWnd Then ExitLoop
    Next
    ; If handle not found
    If $iIndex > $aGF_HandleIndex[0][0] Then Return "GUI_RUNDEFMSG"
    ; Check if we should resize this set
    If $aGF_SettingsIndex[$iIndex][1] = 1 Then
        ; Get new base GUI size
        Local $aSize = WinGetClientSize($hWnd)
        ; Resize frames
        _GUIFrame_Move($iIndex, $aSize[0] * $aGF_SizingIndex[$iIndex][2], $aSize[1] * $aGF_SizingIndex[$iIndex][3], $aSize[0] * $aGF_SizingIndex[$iIndex][4], $aSize[1] * $aGF_SizingIndex[$iIndex][5])
        ; Adjust any resizeable internal frames - array elements are adjacent for ease of coding
        For $i = 0 To 1
            ; Adjust internal frames of first/second frame if any exist
            If $aGF_HandleIndex[$iIndex][5 + $i] <> 0 Then
                ; StringSplit the element content on "|"
                Local $aInternal = StringSplit($aGF_HandleIndex[$iIndex][5 + $i], "|")
                ; Then loop though the Number(values) found
                For $j = 1 To $aInternal[0]
                    Local $iIntIndex = Number($aInternal[$j])
                    ; Check if internal frame is resizable
                    If $aGF_SettingsIndex[$iIntIndex][1] = 1 Then
                        ; And change if so
                        _GUIFrame_SIZE_Handler($aGF_HandleIndex[$iIntIndex][4], $iMsg, $wParam, $lParam)
                    EndIf
                Next
            EndIf
        Next
    EndIf
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>_GUIFrame_SIZE_Handler
; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _GUIFrame_SepSubClass
; Description ...: Sets new WndProc for frame separator bar
; Author ........: Kip
; Modified.......: Melba23, using SetWindowLongPtr x64 compatible code drawn from Yashied's WinAPIEx library
; Remarks .......: This function is used internally by _GUIFrame_Create
; ===============================================================================================================================
Func _GUIFrame_SepSubClass($hWnd)
    Local $aRet
    ; Check separator has not already been used
    For $i = 1 To $aGF_SepProcIndex[0][0]
        If $aGF_SepProcIndex[$i][0] = $hWnd Then Return 0
    Next
    ; Store current WinProc handle in new array line
    Local $iIndex = $aGF_SepProcIndex[0][0] + 1
    ReDim $aGF_SepProcIndex[$iIndex + 1][2]
    $aGF_SepProcIndex[0][0] = $iIndex
    $aGF_SepProcIndex[$iIndex][0] = $hWnd
    ; Subclass separator bar
    If @AutoItX64 Then
        $aRet = DllCall('user32.dll', 'long_ptr', 'SetWindowLongPtrW', 'hwnd', $hWnd, 'int', -4, 'long_ptr', $aGF_SepProcIndex[0][1]) ; $GWL_WNDPROC
    Else
        $aRet = DllCall('user32.dll', 'long', 'SetWindowLongW', 'hwnd', $hWnd, 'int', -4, 'long', $aGF_SepProcIndex[0][1]) ; $GWL_WNDPROC
    EndIf
    ; Check for subclassing error
    If @error Or $aRet[0] = 0 Then Return 0
    ; Return success
    $aGF_SepProcIndex[$iIndex][1] = $aRet[0]
    Return 1
EndFunc   ;==>_GUIFrame_SepSubClass
; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _GUIFrame_SepWndProc
; Description ...: New WndProc for frame separator bar
; Author ........: Kip
; Modified.......: Melba23
; Remarks .......: This function is used internally by _GUIFrame_SepSubClass
; ===============================================================================================================================
Func _GUIFrame_SepWndProc($hWnd, $iMsg, $wParam, $lParam)
    Local $iSubtract
    If $iMsg = 0x0111 Then ; WM_COMMAND
        ; Check if hWnd is a Separator bar
        For $iIndex = 1 To $aGF_HandleIndex[0][0]
            If $aGF_HandleIndex[$iIndex][3] = $hWnd Then ExitLoop
        Next
        ; If not then pass message on to org WndProc
        If $iIndex > $aGF_HandleIndex[0][0] Then Return _GUIFrame_SepPassMsg($hWnd, $iMsg, $wParam, $lParam)
        ; Extract values from array
        Local $hParent = $aGF_HandleIndex[$iIndex][0]
        Local $hFirstFrame = $aGF_HandleIndex[$iIndex][1]
        Local $hSecondFrame = $aGF_HandleIndex[$iIndex][2]
        Local $hSeparator = $aGF_HandleIndex[$iIndex][3]
        Local $iFirstMin = $aGF_SizingIndex[$iIndex][0]
        Local $iSecondMin = $aGF_SizingIndex[$iIndex][1]
        Local $iSeparatorSize = $aGF_SettingsIndex[$iIndex][2]
        ; Get client size of the parent
        Local $aClientSize = WinGetClientSize($hParent)
        Local $iWidth = $aClientSize[0]
        Local $iHeight = $aClientSize[1]
        ; Get cursor info for the Separator
        Local $aCInfo = GUIGetCursorInfo($hSeparator)
        ; Depending on separator orientation
        If $aGF_SettingsIndex[$iIndex][0] = 0 Then
            ; Get Separator X-coord
            $iSubtract = $aCInfo[0]
            Do
                ; Get parent X-coord
                $aCInfo = GUIGetCursorInfo($hParent)
                Local $iCursorX = $aCInfo[0]
                ; Determine width of first frame
                Local $iFirstWidth = $iCursorX - $iSubtract
                ; And ensure it is at least minimum
                If $iFirstWidth < $iWidth * $iFirstMin Then $iFirstWidth = $iWidth * $iFirstMin
                If $iWidth - ($iFirstWidth + $iSeparatorSize) < $iWidth * $iSecondMin Then $iFirstWidth = $iWidth - ($iWidth * $iSecondMin) - $iSeparatorSize
                ; Move the GUIs to the correct places
                WinMove($hFirstFrame, "", 0, 0, $iFirstWidth, $iHeight)
                WinMove($hSecondFrame, "", $iFirstWidth + $iSeparatorSize, 0, $iWidth - ($iFirstWidth + $iSeparatorSize), $iHeight)
                WinMove($hSeparator, "", $iFirstWidth, 0, $iSeparatorSize, $iHeight)
                ; Do until the mouse button is released
            Until Not _WinAPI_GetAsyncKeyState(0x01)
        ElseIf $aGF_SettingsIndex[$iIndex][0] = 1 Then
            $iSubtract = $aCInfo[1]
            Do
                $aCInfo = GUIGetCursorInfo($hParent)
                Local $iCursorY = $aCInfo[1]
                Local $iFirstHeight = $iCursorY - $iSubtract
                If $iFirstHeight < $iHeight * $iFirstMin Then $iFirstHeight = $iHeight * $iFirstMin
                If $iHeight - ($iFirstHeight + $iSeparatorSize) < $iHeight * $iSecondMin Then $iFirstHeight = $iHeight - ($iHeight * $iSecondMin) - $iSeparatorSize
                WinMove($hFirstFrame, "", 0, 0, $iWidth, $iFirstHeight)
                WinMove($hSecondFrame, "", 0, $iFirstHeight + $iSeparatorSize, $iWidth, $iHeight - ($iFirstHeight + $iSeparatorSize))
                WinMove($hSeparator, "", 0, $iFirstHeight, $iWidth, $iSeparatorSize)
            Until Not _WinAPI_GetAsyncKeyState(0x01)
        EndIf
    EndIf
    ; Pass the message on to org WndProc
    Return _GUIFrame_SepPassMsg($hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_GUIFrame_SepWndProc
; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _GUIFrame_SepPassMsg
; Description ...: Passes Msg to frame parent WndProc for action
; Author ........: Kip
; Modified.......: Melba23
; Remarks .......: This function is used internally by _GUIFrame_SepWndProc
; ===============================================================================================================================
Func _GUIFrame_SepPassMsg($hWnd, $iMsg, $wParam, $lParam)
    For $i = 1 To $aGF_SepProcIndex[0][0]
        If $aGF_SepProcIndex[$i][0] = $hWnd Then Return _WinAPI_CallWindowProc($aGF_SepProcIndex[$i][1], $hWnd, $iMsg, $wParam, $lParam)
    Next
EndFunc   ;==>_GUIFrame_SepPassMsg
; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _GUIFrame_Move
; Description ...: Moves and resizes frame elements and separator bars
; Author ........: Kip
; Modified.......: Melba23
; Remarks .......: This function is used internally by _GUIFrame_SIZE_Handler
; ===============================================================================================================================
Func _GUIFrame_Move($iFrame, $iX, $iY, $iWidth = 0, $iHeight = 0)
    ; Check valid frame index
    If $iFrame < 1 Or $iFrame > $aGF_HandleIndex[0][0] Then Return 0
    Local $iSeparatorSize = $aGF_SettingsIndex[$iFrame][2]
    Local $iTotal
    ; Set size if not specified
    If Not $iWidth Then $iWidth = _WinAPI_GetWindowWidth($aGF_HandleIndex[$iFrame][0])
    If Not $iHeight Then $iHeight = _WinAPI_GetWindowHeight($aGF_HandleIndex[$iFrame][0])
    ; Move parent
    WinMove($aGF_HandleIndex[$iFrame][0], "", $iX, $iY, $iWidth, $iHeight)
    ; Get size of first frame depending on orientation
    Local $aWinPos = WinGetClientSize($aGF_HandleIndex[$iFrame][1])
    Local $iSize = $aWinPos[0]
    If $aGF_SettingsIndex[$iFrame][0] = 1 Then $iSize = $aWinPos[1]
    ; Set frame min percentages
    Local $iFirstMin = $aGF_SizingIndex[$iFrame][0]
    Local $iSecondMin = $aGF_SizingIndex[$iFrame][1]
    ; Depending on separator orientation
    If $aGF_SettingsIndex[$iFrame][0] = 0 Then
        ; Move frames and separator as required
        $iTotal = $iWidth
        If $iSize < $iWidth * $iFirstMin Then $iSize = $iWidth * $iFirstMin
        If $iTotal - $iSize - $iSeparatorSize < $iWidth * $iSecondMin Then $iSize = $iTotal - ($iWidth * $iSecondMin) - $iSeparatorSize
        WinMove($aGF_HandleIndex[$iFrame][1], "", 0, 0, $iSize, $iHeight)
        WinMove($aGF_HandleIndex[$iFrame][2], "", $iSize + $iSeparatorSize, 0, $iTotal - $iSize - $iSeparatorSize, $iHeight)
        WinMove($aGF_HandleIndex[$iFrame][3], "", $iSize, 0, $iSeparatorSize, $iHeight)
    ElseIf $aGF_SettingsIndex[$iFrame][0] = 1 Then
        $iTotal = $iHeight
        If $iSize < $iHeight * $iFirstMin Then $iSize = $iHeight * $iFirstMin
        If $iTotal - $iSize - $iSeparatorSize < $iHeight * $iSecondMin Then $iSize = $iTotal - ($iHeight * $iSecondMin) - $iSeparatorSize
        WinMove($aGF_HandleIndex[$iFrame][1], "", 0, 0, $iWidth, $iSize)
        WinMove($aGF_HandleIndex[$iFrame][2], "", 0, $iSize + $iSeparatorSize, $iWidth, $iTotal - $iSize - $iSeparatorSize)
        WinMove($aGF_HandleIndex[$iFrame][3], "", 0, $iSize, $iWidth, $iSeparatorSize)
    EndIf
EndFunc   ;==>_GUIFrame_Move
; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _GUIFrame_Exit()
; Description ...: Deletes all subclassed separator bars to free UDF WndProc and frees registered callback handle
; Author ........: Melba23
; Remarks .......: Called by OnAutoItExitRegister to delete all subclassed separator bars and to free the UDF created WndProc.
; Example........: Yes
;================================================================================================================================
Func _GUIFrame_Exit()
    ; Delete all subclassed separator bars
    For $i = $aGF_HandleIndex[0][0] To 1 Step -1
        GUIDelete($aGF_HandleIndex[$i][3])
    Next
    ; Free registered Callback handle
    DllCallbackFree($hGF_RegCallBack)
EndFunc   ;==>_GUIFrame_Exit

Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites



DicatoroftheUSA,

As you do not use GUISetAccelerators anywhere in that script I am somewhat at a loss to understand your problem. Do you want to set Accelerator keys for the menu and button controls? If so, then what keys do you want to use for each control? :)

M23

P.S. We will come on to the other problems in the script in due course. ;)


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

DicatoroftheUSA,

OK, after some experimentation I can see why you think that the Accelerator keys do not work. Each frame is a separate GUI and so you need to set the Accelerator keys for each frame independently. That means you need an array for each frame you create - I think "_EasyAccelerator" was not the function name to choose! ;)

I will see if I can develop something not too difficult for you, but first I have a question - if "I would rather give up go home and cry than use the mouse", how are you going to adjust the frames? :)

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

#4 ·  Posted (edited)

OK, maybe accelerator isn't the right term, I mean "Ampersand Shortcut".

I don't think it is an issue with multiple GUIs. Because even if you click the frame, to give focus to the frame, it still does not work.

Also I have other scripts, that launch separate GUIs, not as frames, and the "Ampersand Shortcuts" work fine with those.

OK, I will let the frames be adjusted by mouse :).

Edited by DicatoroftheUSA

Share this post


Link to post
Share on other sites

OK, after some experimentation I can see why you think that the Accelerator keys do not work. Each frame is a separate GUI and so you need to set the Accelerator keys for each frame independently. That means you need an array for each frame you create - I think "_EasyAccelerator" was not the function name to choose! Posted Image

I think it should help to declare the Frame-GUIs with WS_EX_CONTROLPARENT.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

DicatoroftheUSA,

I understand now. :)

It does seem that you cannot get the &letter to work with GUIFrames - I will investigate further. ;)

However, by pure coincidence Accelerator keys might be a solution: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include "GUIFrame.au3"
#include <Array.au3>
#include <Misc.au3>
#include<string.au3>

If _Singleton("Single", 1) = 0 Then ;only on instance running
    Exit
EndIf

_main()
Func _main()
    _GuiCreate()
EndFunc   ;==>_main

Func _GuiCreate()

    $hGUI = GUICreate("GUI_Frame Example 1", 500, 500, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX))

    $hMenu = GUICtrlCreateMenu("&Title")
    $hItem = GUICtrlCreateMenuItem("&Item", $hMenu)
    ; Create dummy control for the Accelerator Keys
    $hDummy_Button_1 = GUICtrlCreateDummy()
    $hDummy_Button_2 = GUICtrlCreateDummy()

    GUISetState()

    ; Set Accel keys to match the &letter of the buttons we create later <<<<<<<<<<<<<<<<<<<<<<<<<<<
    Global $aAccel[2][2] = [["!p", $hDummy_Button_1], ["!s", $hDummy_Button_2]]
    GUISetAccelerators($aAccel)

    ; Create a 1st level frame
    $iFrame_Main = _GUIFrame_Create($hGUI, 0, 200)
    _GUIFrame_SetMin($iFrame_Main, 50, 100)
    _GUIFrame_Switch($iFrame_Main, 2)
    $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_Main, 2))
    $hButton_1 = GUICtrlCreateButton("&Pos Sep 1", 10, 10, 80, 30)
    ; Create a 2nd level frame Left
    $iFrame_Left = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_Main, 1), 1, $aWinSize[1] * .7)
    GUISetBkColor(0x00FF00, _GUIFrame_GetHandle($iFrame_Left, 1))
    _GUIFrame_SetMin($iFrame_Left, 10, 10)
    _GUIFrame_Switch($iFrame_Left, 1)
    $hButton_2 = GUICtrlCreateButton("Pos &Sep 2", 10, 10, 80, 30)

    ; Create a 2nd level frame Left
    $iFrame_Right = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_Main, 2), 1)
    GUISetBkColor(0x00FF00, _GUIFrame_GetHandle($iFrame_Right, 1))
    _GUIFrame_SetMin($iFrame_Right, 10, 10)
    _GUIFrame_Switch($iFrame_Right, 2)

    _GUIFrame_ResizeSet(0)

    _GUIFrame_ResizeReg()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ; The UDF does all the tidying up as you exit
                Exit
            Case $hItem
                MsgBox(0, "", 'arg')
            Case $hButton_1, $hDummy_Button_1 ; Look for both button and dummy <<<<<<<<<<<<<<<<<<<<<<<
                MsgBox(0, "", "Oh nohz! You clicked button 1")
            Case $hButton_2, $hDummy_Button_2
                MsgBox(0, "", 'barf')
        EndSwitch
    WEnd
EndFunc   ;==>_GuiCreate

Any use? ;)

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

#7 ·  Posted (edited)

As I said, you should create all GUIs in the GUIFrame-UDF with the style WS_EX_CONTROLPARENT, this should be done anyway to allow Windows proper handling of messages and tab navigation.

@Melba23 only: By the way, there are some instances of GUICreate which should be GUIDelete in your UDF (e.g. GUICreate($hParent))

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

ProgAndy,

You should create all GUIs in the GUIFrame-UDF with the style WS_EX_CONTROLPARENT

Thank you for that - the & letters now work. I will release a new version this weekend. :)

there are some instances of GUICreate which should be GUIDelete

Oops! I will fix that too. ;)

M23

Edit: Sorry - missed the first post where you mentioned it. ;)

Edited by Melba23

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

DicatoroftheUSA,

New version of the UDF posted and this example shows it working for you: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include "GUIFrame.au3"

_main()

Func _main()
    _GuiCreate()
EndFunc   ;==>_main

Func _GuiCreate()

    $hGUI = GUICreate("GUI_Frame Ampersand Example", 500, 500, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
    GUISetState()

    $hMenu = GUICtrlCreateMenu("&Title")
    $hMenuItem = GUICtrlCreateMenuItem("&Item", $hMenu)

    ; Create a 1st level frame
    $iFrame_Main = _GUIFrame_Create($hGUI, 0, 200)
    _GUIFrame_SetMin($iFrame_Main, 50, 100)

    _GUIFrame_Switch($iFrame_Main, 2)
    $aWinSize = WinGetClientSize(_GUIFrame_GetHandle($iFrame_Main, 2))
    $hButton_1 = GUICtrlCreateButton("&Pos Sep 1", 10, 10, 80, 30)

    ; Create a 2nd level frame Left
    $iFrame_Left = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_Main, 1), 1, $aWinSize[1] * .7)
    GUISetBkColor(0x00FF00, _GUIFrame_GetHandle($iFrame_Left, 1))
    _GUIFrame_SetMin($iFrame_Left, 10, 10)
    _GUIFrame_Switch($iFrame_Left, 1)
    $hButton_2 = GUICtrlCreateButton("Pos &Sep 2", 10, 10, 80, 30)

    ; Create a 2nd level frame Left
    $iFrame_Right = _GUIFrame_Create(_GUIFrame_GetHandle($iFrame_Main, 2), 1)
    GUISetBkColor(0x00FF00, _GUIFrame_GetHandle($iFrame_Right, 1))
    _GUIFrame_SetMin($iFrame_Right, 10, 10)
    _GUIFrame_Switch($iFrame_Right, 2)
    $hButton_3 = GUICtrlCreateButton("Pos Sep &3", 10, 10, 80, 30)

    _GUIFrame_ResizeSet(0)

    _GUIFrame_ResizeReg()

    GUICtrlSetState($hButton_1, $GUI_FOCUS)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ; The UDF does all the tidying up as you exit
                Exit
            Case $hMenuItem
                MsgBox(0, "", "Menu Item")
            Case $hButton_1
                MsgBox(0, "", "Button 1")
            Case $hButton_2
                MsgBox(0, "", 'Button 2')
            Case $hButton_3
                MsgBox(0, "", 'Button 3')
        EndSwitch
    WEnd

EndFunc   ;==>_GuiCreate

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

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

    • mistersquirrle
      By mistersquirrle
      I'm making a little chat client, and I'm using Melbas GUIFrame ().

      I want it, so that when I re-size the window (with min/max sizes) it re-sizes the input and history boxes to match the new window size. That's working fine with re-sizing the whole GUI (using GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")), but when I try to move the frame separator bar, the history box (since it's made with _GUICtrlRichEdit instead of GUICtrlEdit) doesn't update until after you're finished moving the separator.

      Using the other GUIRegisterMsg, the history edit re-sizes instantly as you move the separator bar, but the other controls in the window don't change at all.

      Using both at once causes only the second one to work.

      Is there a way to have both things happen (re-size edits on window and separator bar re-size)?


      #include <GUIRichEdit.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <GUIEdit.Au3> #include "GUIFrame.au3" #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $GUIMINWID = 300, $GUIMINHT = 100 ;Min window sizes Local $GUIMAXWID = @DesktopWidth, $GUIMAXHT = @DesktopHeight ;Max window sizes $hGUI = GUICreate('MEOW', 500, 300, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetState(@SW_SHOW) $iFrames = _GUIFrame_Create($hGUI, 0, 200) ;Creation of the two GUI frames _GUIFrame_ResizeSet(0, 1) ;Required for proper resizing _GUIFrame_ResizeReg() ;Required for proper resizing _GUIFrame_SetMin($iFrames, 150, 200, True) ;Set frame min size _GUIFrame_Switch($iFrames, 2) ;Switch to second frame to create controls $History = _GUICtrlRichEdit_Create(_GUIFrame_Switch($iFrames, 2), 'adsfadsfasdf', 2, 2, 263, 255) $Input = GUICtrlCreateEdit('', 2, 272, 293, 20, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_BORDER), $WS_EX_STATICEDGE) GUICtrlSetFont(-1, 10, 400, 0, "Courier New") GUICtrlSetResizing(-1, 582) ;Resizing parameters GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") ;~ GUIRegisterMsg($WM_SIZE, "WM_SIZE") $SepPos = _GUIFrame_GetSepPos($iFrames) ;Get the seperator bars current position While 1 Sleep(10) If $SepPos <> _GUIFrame_GetSepPos($iFrames) Then History_Resize() Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($History) Exit EndSwitch WEnd Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam) $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tagMaxinfo, 7, $GUIMINWID) ; min X DllStructSetData($tagMaxinfo, 8, $GUIMINHT) ; min Y DllStructSetData($tagMaxinfo, 9, $GUIMAXWID); max X DllStructSetData($tagMaxinfo, 10, $GUIMAXHT) ; max Y History_Resize() Return 0 EndFunc ;==>WM_GETMINMAXINFO Func WM_SIZE($hwnd, $iMsg, $wParam, $lParam) History_Resize() EndFunc ;==>WM_SIZE Func History_Resize() $SepPos = _GUIFrame_GetSepPos($iFrames) $hGpos = WinGetPos($hGUI) $iPos = ControlGetPos($hGUI, '', 'Edit1') _WinAPI_MoveWindow($History, 2, 2, ($hGpos[2] - $SepPos) - 50, $hGpos[3] - $iPos[3] - 55, False) EndFunc ;==>History_Resize