Jump to content

Two problems: Scrollbars and Focus loss


mpower
 Share

Go to solution Solved by mpower,

Recommended Posts

Hi guys,

So I'm still working on my GUI which is nearly complete, but there are a couple of issues I am facing.

I have a side 'panel' in my GUI that can be expanded/collapsed. It's working fine, but there are a couple of user experience issues:

Firstly, a scrollbar/resizing issue... Let me try to illustrate this with screenshots.

When I click to expand the side panel it works as expected however there are is no horizontal scrollbar on the listview:

zscbr.png

When I resize the gui even by one pixel, the horizontal scroll bar magically appears on the listview......:

IkzN.png

I guess it would be a much smoother experience if the scrollbar appeared right away without having to resize the gui.

 

The second issue is to do with loss of focus..... when I click an input field on the side panel the main gui loses focus, as you can see below the main gui is slightly lighter ... i.e. it doesnt have focus...

qsgjy.png

It should really look like this, regardless of whether you click on side panel or not:

gZAJd.png

 

 

I hope I have illustrated and explained the issues well enough for someone to have a look into possible solutions. I've been wrecking my brain for a while and can't seem to get past these two issues.

The example file is attached (it includes the Icon DLLs and the UDFs I used in the include folder).

To get the listview and side panel to appear simply click on New and then "Standard...".

Thanks heaps!

example.zip

Edited by mpower
Link to comment
Share on other sites

  • Moderators

mpower,

You can fix the scrollbar problem by forcing a WinMove when you display the side panel: ;)

Case $hidepanellbl
    If $hidesidepanel = False Then ;hide
        HideSidePanel()
    Else ;unhide
        ShowSidePanel()
        $aPos = WinGetPos($maingui)
        WinMove($maingui, "", $aPos[0], $aPos[1], $aPos[2] + 1, $aPos[3] + 1)
        WinMove($maingui, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3])
    EndIf
I will look into the focus problem this afternoon. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

mpower,

Searching for an answer to the "focus" problem led me to this old thread of yours which sounds very similar. Had you forgotten about it? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

mpower,

You can fix the scrollbar problem by forcing a WinMove when you display the side panel: ;)

Case $hidepanellbl
    If $hidesidepanel = False Then ;hide
        HideSidePanel()
    Else ;unhide
        ShowSidePanel()
        $aPos = WinGetPos($maingui)
        WinMove($maingui, "", $aPos[0], $aPos[1], $aPos[2] + 1, $aPos[3] + 1)
        WinMove($maingui, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3])
    EndIf
I will look into the focus problem this afternoon. :)

M23

 

 

That's perfect thanks!!

 

mpower,

Searching for an answer to the "focus" problem led me to this old thread of yours which sounds very similar. Had you forgotten about it? :huh:

M23

 

I have tried to adopt the same approach but haven't been successful.. :(

Link to comment
Share on other sites

Focus. Maybe you can solve the problem in this way:

 

GUIRegisterMsg( $WM_NCACTIVATE, "WM_NCACTIVATE" )

; Prevent child windows in making GUI title bar dimmed
Func WM_NCACTIVATE( $hWnd, $iMsg, $wParam )
  If $hWnd = $maingui Then
    If Not $wParam Then Return 1
  EndIf
  Return $GUI_RUNDEFMSG
EndFunc
Link to comment
Share on other sites

mpower,

You can fix the scrollbar problem by forcing a WinMove when you display the side panel: ;)

Case $hidepanellbl
    If $hidesidepanel = False Then ;hide
        HideSidePanel()
    Else ;unhide
        ShowSidePanel()
        $aPos = WinGetPos($maingui)
        WinMove($maingui, "", $aPos[0], $aPos[1], $aPos[2] + 1, $aPos[3] + 1)
        WinMove($maingui, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3])
    EndIf
I will look into the focus problem this afternoon. :)

M23

 

 

Focus. Maybe you can solve the problem in this way:

 

GUIRegisterMsg( $WM_NCACTIVATE, "WM_NCACTIVATE" )

; Prevent child windows in making GUI title bar dimmed
Func WM_NCACTIVATE( $hWnd, $iMsg, $wParam )
  If $hWnd = $maingui Then
    If Not $wParam Then Return 1
  EndIf
  Return $GUI_RUNDEFMSG
EndFunc

Zomg, you guys are the best!!!!

Link to comment
Share on other sites

hi guys,

so I'm adding another feature here, but it doesn't seem to work properly with the way resizing is currently handled..

essentially, I am adding autosuggest feature to the sidepanel inputbox (just like, for example, if you type 'o' into google search box it suggests popular words that start with 'o')

the problem is when the list is resized it triggers WM_SIZE and the whole gui breaks until you manually resize it....

Here's the updated code:

#Region ### includes ###
#include-once
#NoTrayIcon
#AutoIt3Wrapper_Outfile=example.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Ribbonsbar.au3>
#include <GuiListView.au3>
#include <GuiMenu.au3>
#include <EditConstants.au3>
#include <GuiListBox.au3>
#EndRegion ### includes ###

Opt("GUIResizeMode", 802)
Global $appname = 'Example', $appver = '1.0', $additemsgui_W = 400, $additemsgui_H = 150, $hidesidepanel = True, $highlightsidepanellbl = False, $sCurr_Input, $iCurrIndex
;check for Aero and set transparency increment accordingly
Global Const $hDwmApiDll = DllOpen("dwmapi.dll"), $sChkAero = DllStructCreate("int;")
DllCall($hDwmApiDll, "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($sChkAero))
Global $bAero = DllStructGetData($sChkAero, 1)
Global $fStep = 0.1
If Not $bAero Then $fStep = 1.25
$testarray = StringSplit("oranges|orchids|ordinal|ordinarily|ordinariness", '|')

#Region ### $maingui ###
$maingui = GUICreate($appname & ' ' & $appver, @DesktopWidth, 600, -1, -1, BitOr($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
_WinAPI_SetClassLongEx($maingui, -26, BitAND(_WinAPI_GetClassLongEx($maingui, -26), BitNOT(1), BitNOT(2)))
$hBar = _RibbonsBar_Create( $maingui, 0, 0, 0, 0, 'blue')
$hTab_Home = _RibbonsBar_Create_Tab($hBar, 'Home')
$hItem_FileOps = _RibbonsBar_Create_TabItem($hTab_Home, 'File operations' , 225 )
$hGrandButton_New = _RibbonsBar_Create_GrandButton($hItem_FileOps,'',412,'New',52, True )
$hDropDownNew = _RibbonsBar_Create_ContextMenu($hGrandButton_New)
$hDropDownNew_1 = _GUICtrlCreateODMenuItem("Standard ...", $hDropDownNew, "smallIcons.dll", 261)
$hDropDownNew_2 = _GUICtrlCreateODMenuItem("Manual ...", $hDropDownNew, "smallIcons.dll", 382)
$hGrandButton_Open = _RibbonsBar_Create_GrandButton($hItem_FileOps,'',453,'Open',52, False )
$hGrandButton_Save = _RibbonsBar_Create_GrandButton($hItem_FileOps,'',514,'Save',52, True )
_RibbonsBar_GrandButtons_Enable($hGrandButton_Save, 0)
$hDropDownSave = _RibbonsBar_Create_ContextMenu($hGrandButton_Save)
$hDropDownSave_1 = _GUICtrlCreateODMenuItem("Save", $hDropDownSave, "smallIcons.dll", 287)
$hDropDownSave_2 = _GUICtrlCreateODMenuItem("Save As ...", $hDropDownSave, "smallIcons.dll", 286)
$hGrandButton_Export = _RibbonsBar_Create_GrandButton($hItem_FileOps,'',337,'Export',62, True )
_RibbonsBar_GrandButtons_Enable($hGrandButton_Export, 0)
$hDropDownExport = _RibbonsBar_Create_ContextMenu($hGrandButton_Export)
$hDropDownExport_1 = _GUICtrlCreateODMenuItem("To Excel", $hDropDownExport, "smallIcons.dll", 1243)
$hItem_ItemOps = _RibbonsBar_Create_TabItem ( $hTab_Home, 'Item operations' , 170 )
$hGrandButton_AddItems = _RibbonsBar_Create_GrandButton($hItem_ItemOps,'',301,'Add item(s)',72, True )
$hDropDownAddItems = _RibbonsBar_Create_ContextMenu($hGrandButton_AddItems)
_RibbonsBar_GrandButtons_Enable($hGrandButton_AddItems, 0)
$hDropDownAddItems_1 = _GUICtrlCreateODMenuItem("From Catalogue", $hDropDownAddItems, "smallIcons.dll", 173)
$hDropDownAddItems_2 = _GUICtrlCreateODMenuItem("From Quote", $hDropDownAddItems, "smallIcons.dll", 143)
$hDropDownAddItems_3 = _GUICtrlCreateODMenuItem("Bulk Paste", $hDropDownAddItems, "smallIcons.dll", 9)
$hGrandButton_DelItems = _RibbonsBar_Create_GrandButton($hItem_ItemOps,'',615,'Delete item(s)',82, False )
_RibbonsBar_GrandButtons_Enable($hGrandButton_DelItems, 0)

$hItem_InfoOps = _RibbonsBar_Create_TabItem($hTab_Home, 'Administrative operations', 150)
$hGrandButton_SPADetails = _RibbonsBar_Create_GrandButton($hItem_InfoOps, '', 17, 'Document Details', 80, False)
_RibbonsBar_GrandButtons_Enable($hGrandButton_SPADetails, 0)
$SmallButton_Undo = _RibbonsBar_Create_SmallButton($hItem_InfoOps,'',728,1,'Undo',60)
_RibbonsBar_SmallButtons_Enable($SmallButton_Undo, 0)
$SmallButton_Redo = _RibbonsBar_Create_SmallButton($hItem_InfoOps,'',194,2,'Redo',60)
_RibbonsBar_SmallButtons_Enable($SmallButton_Redo, 0)

$hTab_Help = _RibbonsBar_Create_Tab( $hBar, 'Help' )
$hItem_Information = _RibbonsBar_Create_TabItem ( $hTab_Help, 'Information' , 120 )
$hGrandButton_About = _RibbonsBar_Create_GrandButton($hItem_Information,'',631,'Help','',False)
$hGrandButton_About = _RibbonsBar_Create_GrandButton($hItem_Information,'',644,'About','',False)
_RibbonsBar_Tab_SetState($hTab_Home)
GUISwitch($maingui)
WinMove($maingui, "", Default, Default, 800, Default)
$wPos = WinGetPos($maingui)
WinMove($maingui, "", @DesktopWidth/2 - $wPos[2]/2, @DesktopHeight/2 - $wPos[3]/2, Default, Default)
$wPos = WinGetPos($maingui)
$mainlistview = GUICtrlCreateListView('Col 1|Col 2|Col 3|Col 4|Col 5|Col 6', -2, 120, _
                $wPos[2], $wPos[3], Default, 0x200)
_GUICtrlListView_SetExtendedListViewStyle($mainlistview, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES, $LVS_EX_FLATSB))
_GUICtrlListView_SetColumnWidth($mainlistview, 0, 120)
_GUICtrlListView_SetColumnWidth($mainlistview, 1, 250)
_GUICtrlListView_SetColumnWidth($mainlistview, 2, 50)
_GUICtrlListView_SetColumnWidth($mainlistview, 3, 100)
_GUICtrlListView_SetColumnWidth($mainlistview, 4, 100)
_GUICtrlListView_SetColumnWidth($mainlistview, 5, 50)
GUICtrlSetState(-1, $GUI_HIDE)
$hidepanellbl = GUICtrlCreateLabel('|', $wPos[2] - 300, 121, 10, $wPos[3] - 120, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, Default, Default, Default, "Wingdings 3")
GUICtrlSetBkColor(-1, 0xf2f8ff)
GUICtrlSetCursor(-1, 0)
GUICtrlSetState(-1, $GUI_HIDE)
#EndRegion ### $maingui ###

#Region ### $sidepanel ###
$sidepanel = GUICreate("", 290, 715, $wPos[2] - 312, 116, $WS_POPUP, BitOR($WS_EX_MDICHILD, 0x08000000), $maingui)
GUISetBkColor(0xf2f8ff)
GUICtrlCreateLabel("Document details:", 0, 8, 290, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlCreateLabel(" - Some details - ", 0, 40, 290, 17, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlCreateLabel("Test:", 5, 64, 45, 17)
$testinput = GUICtrlCreateInput("", 62, 60, 218, 21)
#EndRegion ### $sidepanel ###

#Region ### $list_gui ###
$list_gui = GUICreate('', 218, 107, 0, 0, $WS_POPUP, BitOR($WS_EX_MDICHILD, 0x08000000), $sidepanel)
$list = GUICtrlCreateList('', 0, 0, 218, 107, $WS_VSCROLL)
GUICtrlSetLimit(-1, 20)
#EndRegion ### $list_gui ###

#Region ### $additemsgui ###
$additemsgui = GUICreate('Add item(s) from Catalogue', $additemsgui_W, $additemsgui_H, 0, 0, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX), $WS_EX_MDICHILD, $maingui)
GUISetBkColor(0xf2f8ff)
GUISetFont(10, 400)
$additems_addlabel = GUICtrlCreateLabel('Start typing below to add item(s) from catalogue (min 2 chars):', 10, 15, $additemsgui_W - 20, 21)
$additemsinput = GUICtrlCreateInput('', 10, 45, $additemsgui_W - 20, Default)
GUICtrlSendMsg(-1, $EM_SETCUEBANNER, False, 'Enter a part number here')
$additemsbn_add = GUICtrlCreateButton('Add', 10, 85, 110, 40)
$hUP_add = GUICtrlCreateDummy()
$hDOWN_add = GUICtrlCreateDummy()
Dim $AccelKeys[3][2]=[["{UP}", $hUP_add], ["{DOWN}", $hDOWN_add], ["{ENTER}", $additemsbn_add]]

#EndRegion ### $additemsgui ###

#Region ### $additems_status_gui ###
$additems_status_gui = GUICreate('', 100, 63, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $additemsgui)
GUISetBkColor(0xf2f8ff)
$additems_status_pic = GUICtrlCreatePic('', 26, 0, 48, 48)
$additems_status_lbl = GUICtrlCreateLabel('', 0, 48, 100, 15, $SS_CENTER)
#EndRegion ### $additemslist_gui ###

GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUIRegisterMsg($WM_NCACTIVATE, "WM_NCACTIVATE")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUISetState(@SW_SHOW, $maingui)

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[1]
        Case $maingui
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $hDropDownAddItems_1
                    GUISetState(@SW_DISABLE, $maingui)
                    $mPos = WinGetPos($maingui)
                    WinMove($additemsgui, '', $mPos[0] + (($mPos[2]/2) - ($additemsgui_W/2)), $mPos[1] + (($mPos[3]/2) - ($additemsgui_H/2)))
                    GUICtrlSetData($additemsinput, '')
                    GUISetState(@SW_SHOW, $additemsgui)
                    _WinAPI_SetFocus(ControlGetHandle('', '', $additems_addlabel))
                    GUISetAccelerators($AccelKeys)
                Case $hDropDownNew_1
                    GUICtrlSetState($mainlistview, $GUI_SHOW)
                    GUICtrlSetState($hidepanellbl, $GUI_SHOW)
                    _RibbonsBar_GrandButtons_Enable($hGrandButton_New, 1)
                    _RibbonsBar_GrandButtons_Enable($hGrandButton_Save, 1)
                    _RibbonsBar_GrandButtons_Enable($hGrandButton_Export, 1)
                    _RibbonsBar_GrandButtons_Enable($hGrandButton_AddItems, 1)
                    _RibbonsBar_GrandButtons_Enable($hGrandButton_DelItems, 1)
                    _RibbonsBar_GrandButtons_Enable($hGrandButton_Open, 1)
                    _RibbonsBar_GrandButtons_Enable($hGrandButton_SPADetails, 1)
                    _WinAPI_RedrawWindow($maingui)
                    ShowSidePanel()
                Case $hDropDownNew_2
                Case $hidepanellbl
                    If $hidesidepanel = False Then  ;hide
                        HideSidePanel()
                    Else                            ;unhide
                        ShowSidePanel()
                    EndIf
            EndSwitch
        Case $additemsgui
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    GUISetState(@SW_ENABLE, $maingui)
                    GUISetState(@SW_HIDE, $additems_status_gui)
                    GUISetState(@SW_HIDE, $additemsgui)
                Case $hUP_add
                    ConsoleWrite('$hUP_add... (from add)'&@CRLF)
                Case $hDOWN_add
                    ConsoleWrite('$hDOWN_add... (from add)'&@CRLF)
                Case $additemsbn_add
                    If GUICtrlread($additemsinput) <> '' Then
                        ConsoleWrite('item will be added'&@CRLF)
                    EndIf
            EndSwitch
    EndSwitch

    Switch _RibbonsBar_GetMsg()
        Case $hGrandButton_Open
            ConsoleWrite('open file dialogue goes here...'&@CRLF)
        Case $SmallButton_Undo
            If _RibbonsBar_SmallButtons_GetState($SmallButton_Undo) = 1 Then
                ConsoleWrite('undo...'&@CRLF)
            EndIf
        Case $SmallButton_Redo
            If _RibbonsBar_SmallButtons_GetState($SmallButton_Redo) = 1 Then
                ConsoleWrite('redo...'&@CRLF)
            EndIf
        Case $hGrandButton_SPADetails
            If _RibbonsBar_GrandButtons_GetState($hGrandButton_SPADetails) = 1 Then
                If $hidesidepanel = False Then
                    HideSidePanel()
                Else
                    ShowSidePanel()
                EndIf
            EndIf
        Case $hTab_Home
            _RibbonsBar_Tab_SetState($hTab_Home)
        Case $hGrandButton_Export
            _RibbonsBar_ContextMenu_SetState($hDropDownExport)
        Case $hGrandButton_Save
            _RibbonsBar_ContextMenu_SetState($hDropDownSave)
        Case $hGrandButton_AddItems
            _RibbonsBar_ContextMenu_SetState($hDropDownAddItems)
        Case $hGrandButton_New
            _RibbonsBar_ContextMenu_SetState($hDropDownNew)
        Case $hTab_Help
            _RibbonsBar_Tab_SetState($hTab_Help)
    EndSwitch

    $cPos = GUIGetCursorInfo($maingui)
    If $cPos[4] = $hidepanellbl And $highlightsidepanellbl = False Then
        GUICtrlSetBkColor($hidepanellbl, 0xE2EFFD)
        $highlightsidepanellbl = True
    ElseIf $cPos[4] <> $hidepanellbl And $highlightsidepanellbl = True Then
        GUICtrlSetBkColor($hidepanellbl, 0xf2f8ff)
        $highlightsidepanellbl = False
    EndIf
WEnd

Func CheckInputText()
    $sPartialData = '|'
    Local $sInput = GUICtrlRead($testinput), $iMatch_Count
    If $sInput <> '' Then
        $iMatch_Count = 0
        For $i = 0 To Ubound($testarray) - 1
            If StringInStr($testarray[$i], $sInput) <> 0 Then
                $sPartialData &= $testarray[$i] & '|'
                $iMatch_Count += 1
            EndIf
        Next
        GUICtrlSetData($list, $sPartialData)
        $iList_Height = $iMatch_Count * (_GUICtrlListBox_GetItemHeight($list) + 2)
        If $iList_Height <= 15 Then $iList_Height = 20
        If $iList_Height > 200 Then $iList_Height = 200
        If $iList_Height = 20 Then
            WinMove($list_gui, "", Default, Default, Default, $iList_Height - (2 * $iMatch_Count))
            GUICtrlSetPos($list, Default, Default, Default, $iList_Height)
        Else
            WinMove($list_gui, "", Default, Default, Default, $iList_Height)
            GUICtrlSetPos($list, Default, Default, Default, $iList_Height)
        EndIf
    EndIf
EndFunc

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    Local $iCode = BitShift($wParam, 16)
    Local $nIDFrom = BitAND($wParam, 0xFFFF)

    Switch $hWnd
        Case $sidepanel
            Switch $nIDFrom
                Case $testinput
                    Switch $iCode
                        Case $EN_KILLFOCUS
                            If WinGetState($list_gui) = 7 Then GUISetState(@SW_HIDE, $list_gui)
                        Case $EN_CHANGE
                            If GUICtrlRead($testinput) <> $sCurr_Input Then
                                CheckInputText()
                                $sCurr_Input = GUICtrlRead($testinput)
                            EndIf
                            If StringLen(GUICtrlRead($testinput)) > 1 Then
                                $txt = GUICtrlRead($testinput)
                                For $n = 1 To UBound($testarray) - 1
                                    If StringCompare(StringLeft($testarray[$n], StringLen($txt)), $txt) = 0 Then
                                        If GUICtrlRead($testinput) Then
                                            $aPos = WinGetPos($sidepanel)
                                            WinMove($list_gui, '', $aPos[0] + 62, $aPos[1] + 80)
                                            GUISetState(@SW_SHOWNOACTIVATE, $list_gui)
                                            _GUICtrlListBox_SetCurSel($list, $iCurrIndex)
                                        Else
                                            $iCurrIndex = -1
                                            _GUICtrlListBox_SetCurSel($list, $iCurrIndex)
                                            GUISetState(@SW_HIDE, $list_gui)
                                        EndIf
                                        ExitLoop
                                    EndIf
                                Next
                            EndIf
                    EndSwitch
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc  ;==>ED_WM_COMMAND



Func HideSidePanel()
    $wPos = WinGetPos($maingui)
    GUISetState(@SW_HIDE, $sidepanel)
    GUICtrlSetData($hidepanellbl, '|')
    GUICtrlSetPos($hidepanellbl, $wPos[2] - 28, Default, Default, $wPos[3] - 158)
    _WinAPI_SetWindowPos(GUICtrlGetHandle($mainlistview), 0, 0, 0, $wPos[2] - 27, $wPos[3] - 120, BitOR($SWP_NOMOVE, $SWP_NOZORDER))
    $hidesidepanel = True
EndFunc

Func ShowSidePanel()
    GUICtrlSetData($hidepanellbl, '}')
    $wPos = WinGetPos($maingui)
    WinMove($sidepanel, '', $wPos[0] + $wPos[2] - 300, $wPos[1] + 152, 290, $wPos[3] - 162)
    _WinAPI_SetWindowPos(GUICtrlGetHandle($mainlistview), 0, 0, 0, $wPos[2] - 316, $wPos[3] - 120, BitOR($SWP_NOMOVE, $SWP_NOZORDER))
    GUICtrlSetPos($hidepanellbl, $wPos[2] - 317, Default, Default, $wPos[3] - 158)
    GUISetState(@SW_SHOWNOACTIVATE, $sidepanel)
    $hidesidepanel = False
    $aPos = WinGetPos($maingui)
    WinMove($maingui, "", $aPos[0], $aPos[1], $aPos[2] + 1, $aPos[3] + 1)
    WinMove($maingui, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3])
EndFunc

Func WM_SIZE($hwnd, $uMsg, $wParam, $lParam)
    If $hidesidepanel = False Then
        $wPos = WinGetPos($maingui)
        _WinAPI_SetWindowPos(GUICtrlGetHandle($mainlistview), 0, 0, 0, _WinAPI_LoWord($lParam) - 300, _WinAPI_HiWord($lParam) - 119, BitOR($SWP_NOMOVE, $SWP_NOZORDER))
        GUICtrlSetPos($hidepanellbl, _WinAPI_LoWord($lParam) - 301, Default, Default, $wPos[3] - 158)
        WinMove($sidepanel, '', $wPos[0] + $wPos[2] - 300, $wPos[1] + 152, Default, $wPos[3] - 160)
    ElseIf $hidesidepanel = True Then
        $wPos = WinGetPos($maingui)
        GUICtrlSetPos($hidepanellbl, _WinAPI_LoWord($lParam) - 11, Default, Default, $wPos[3] - 158)
        _WinAPI_SetWindowPos(GUICtrlGetHandle($mainlistview), 0, 0, 0, _WinAPI_LoWord($lParam) - 10, _WinAPI_HiWord($lParam) - 119, BitOR($SWP_NOMOVE, $SWP_NOZORDER))
    EndIf
    Return 1
EndFunc

Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam)
    If $hWnd = $maingui Then
        $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
        DllStructSetData($tagMaxinfo, 7,  800) ; W (min size)
        DllStructSetData($tagMaxinfo, 8,  600) ; H (min size)
;~         DllStructSetData($tagMaxinfo, 9,  800) ; W (max size)
;~         DllStructSetData($tagMaxinfo, 10, 600) ;  H (max size)
        Return 0
    EndIf
EndFunc   ;==>WM_GETMINMAXINFO

; Prevent child windows in making GUI title bar dimmed
Func WM_NCACTIVATE( $hWnd, $iMsg, $wParam )
  If $hWnd = $maingui Then
    If Not $wParam Then Return 1
  EndIf
  Return $GUI_RUNDEFMSG
EndFunc

I suspect the problem lies here, but I havent been able to get around it:

Func CheckInputText()
    $sPartialData = '|'
    Local $sInput = GUICtrlRead($testinput), $iMatch_Count
    If $sInput <> '' Then
        $iMatch_Count = 0
        For $i = 0 To Ubound($testarray) - 1
            If StringInStr($testarray[$i], $sInput) <> 0 Then
                $sPartialData &= $testarray[$i] & '|'
                $iMatch_Count += 1
            EndIf
        Next
        GUICtrlSetData($list, $sPartialData)
        $iList_Height = $iMatch_Count * (_GUICtrlListBox_GetItemHeight($list) + 2)
        If $iList_Height <= 15 Then $iList_Height = 20
        If $iList_Height > 200 Then $iList_Height = 200
        If $iList_Height = 20 Then
            WinMove($list_gui, "", Default, Default, Default, $iList_Height - (2 * $iMatch_Count))
            GUICtrlSetPos($list, Default, Default, Default, $iList_Height)
        Else
            WinMove($list_gui, "", Default, Default, Default, $iList_Height)
            GUICtrlSetPos($list, Default, Default, Default, $iList_Height)
        EndIf
    EndIf
EndFunc
Link to comment
Share on other sites

  • Moderators

mpower,

When you resize the list, the parameters in the handler refer to that GUI and not the main one - hence the ListView vanishing as it was redrawn outside the main GUI. All you need do is check which GUI sent the SIZE message and ignore those from the list GUI: ;)

Func WM_SIZE($hwnd, $uMsg, $wParam, $lParam)
    If $hWnd <> $maingui Then Return 0
[...]
M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

mpower,

When you resize the list, the parameters in the handler refer to that GUI and not the main one - hence the ListView vanishing as it was redrawn outside the main GUI. All you need do is check which GUI sent the SIZE message and ignore those from the list GUI: ;)

Func WM_SIZE($hwnd, $uMsg, $wParam, $lParam)
    If $hWnd <> $maingui Then Return 0
[...]
M23

 

 

Thanks M23, perfection! - its always the simplest solutions that get looked over.... :)

Link to comment
Share on other sites

Hmm, so I've got one more small problem... if I add multiple auto-suggests in my GUI - e.g. another auto-suggest for the Add Items window, the list that pops up steals focus when clicked on and greys out both the Add Items gui and the main gui. This doesnt seem to happen with the sidepanel list popup (i.e. when i click on any suggestion on the sidepanel list popup the main gui doesnt lose focus).

Here's the code....

#Region ### includes ###
#include-once
#NoTrayIcon
#AutoIt3Wrapper_Outfile=example.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Ribbonsbar.au3>
#include <GuiListView.au3>
#include <GuiMenu.au3>
#include <EditConstants.au3>
#include <GuiListBox.au3>
#EndRegion ### includes ###

Opt("GUIResizeMode", 802)
Global $appname = 'Example', $appver = '1.0', $additemsgui_W = 400, $additemsgui_H = 150, $hidesidepanel = True, $highlightsidepanellbl = False, $sCurr_Input, $iCurrIndex
;check for Aero and set transparency increment accordingly
Global Const $hDwmApiDll = DllOpen("dwmapi.dll"), $sChkAero = DllStructCreate("int;")
DllCall($hDwmApiDll, "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($sChkAero))
Global $bAero = DllStructGetData($sChkAero, 1)
Global $fStep = 0.1
If Not $bAero Then $fStep = 1.25
$testarray = StringSplit("oranges|orchids|ordinal|ordinarily|ordinariness", '|')
$testarray_additems = StringSplit("apples|appliances|applications|appropriate|appearances", '|')

#Region ### $maingui ###
$maingui = GUICreate($appname & ' ' & $appver, @DesktopWidth, 600, -1, -1, BitOr($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
_WinAPI_SetClassLongEx($maingui, -26, BitAND(_WinAPI_GetClassLongEx($maingui, -26), BitNOT(1), BitNOT(2)))
$hBar = _RibbonsBar_Create( $maingui, 0, 0, 0, 0, 'blue')
$hTab_Home = _RibbonsBar_Create_Tab($hBar, 'Home')
$hItem_FileOps = _RibbonsBar_Create_TabItem($hTab_Home, 'File operations' , 225 )
$hGrandButton_New = _RibbonsBar_Create_GrandButton($hItem_FileOps,'',412,'New',52, True )
$hDropDownNew = _RibbonsBar_Create_ContextMenu($hGrandButton_New)
$hDropDownNew_1 = _GUICtrlCreateODMenuItem("Standard ...", $hDropDownNew, "smallIcons.dll", 261)
$hDropDownNew_2 = _GUICtrlCreateODMenuItem("Manual ...", $hDropDownNew, "smallIcons.dll", 382)
$hGrandButton_Open = _RibbonsBar_Create_GrandButton($hItem_FileOps,'',453,'Open',52, False )
$hGrandButton_Save = _RibbonsBar_Create_GrandButton($hItem_FileOps,'',514,'Save',52, True )
_RibbonsBar_GrandButtons_Enable($hGrandButton_Save, 0)
$hDropDownSave = _RibbonsBar_Create_ContextMenu($hGrandButton_Save)
$hDropDownSave_1 = _GUICtrlCreateODMenuItem("Save", $hDropDownSave, "smallIcons.dll", 287)
$hDropDownSave_2 = _GUICtrlCreateODMenuItem("Save As ...", $hDropDownSave, "smallIcons.dll", 286)
$hGrandButton_Export = _RibbonsBar_Create_GrandButton($hItem_FileOps,'',337,'Export',62, True )
_RibbonsBar_GrandButtons_Enable($hGrandButton_Export, 0)
$hDropDownExport = _RibbonsBar_Create_ContextMenu($hGrandButton_Export)
$hDropDownExport_1 = _GUICtrlCreateODMenuItem("To Excel", $hDropDownExport, "smallIcons.dll", 1243)
$hItem_ItemOps = _RibbonsBar_Create_TabItem ( $hTab_Home, 'Item operations' , 170 )
$hGrandButton_AddItems = _RibbonsBar_Create_GrandButton($hItem_ItemOps,'',301,'Add item(s)',72, True )
$hDropDownAddItems = _RibbonsBar_Create_ContextMenu($hGrandButton_AddItems)
_RibbonsBar_GrandButtons_Enable($hGrandButton_AddItems, 0)
$hDropDownAddItems_1 = _GUICtrlCreateODMenuItem("From Catalogue", $hDropDownAddItems, "smallIcons.dll", 173)
$hDropDownAddItems_2 = _GUICtrlCreateODMenuItem("From Quote", $hDropDownAddItems, "smallIcons.dll", 143)
$hDropDownAddItems_3 = _GUICtrlCreateODMenuItem("Bulk Paste", $hDropDownAddItems, "smallIcons.dll", 9)
$hGrandButton_DelItems = _RibbonsBar_Create_GrandButton($hItem_ItemOps,'',615,'Delete item(s)',82, False )
_RibbonsBar_GrandButtons_Enable($hGrandButton_DelItems, 0)

$hItem_InfoOps = _RibbonsBar_Create_TabItem($hTab_Home, 'Administrative operations', 150)
$hGrandButton_SPADetails = _RibbonsBar_Create_GrandButton($hItem_InfoOps, '', 17, 'Document Details', 80, False)
_RibbonsBar_GrandButtons_Enable($hGrandButton_SPADetails, 0)
$SmallButton_Undo = _RibbonsBar_Create_SmallButton($hItem_InfoOps,'',728,1,'Undo',60)
_RibbonsBar_SmallButtons_Enable($SmallButton_Undo, 0)
$SmallButton_Redo = _RibbonsBar_Create_SmallButton($hItem_InfoOps,'',194,2,'Redo',60)
_RibbonsBar_SmallButtons_Enable($SmallButton_Redo, 0)

$hTab_Help = _RibbonsBar_Create_Tab( $hBar, 'Help' )
$hItem_Information = _RibbonsBar_Create_TabItem ( $hTab_Help, 'Information' , 120 )
$hGrandButton_About = _RibbonsBar_Create_GrandButton($hItem_Information,'',631,'Help','',False)
$hGrandButton_About = _RibbonsBar_Create_GrandButton($hItem_Information,'',644,'About','',False)
_RibbonsBar_Tab_SetState($hTab_Home)
GUISwitch($maingui)
WinMove($maingui, "", Default, Default, 800, Default)
$wPos = WinGetPos($maingui)
WinMove($maingui, "", @DesktopWidth/2 - $wPos[2]/2, @DesktopHeight/2 - $wPos[3]/2, Default, Default)
$wPos = WinGetPos($maingui)
$mainlistview = GUICtrlCreateListView('Col 1|Col 2|Col 3|Col 4|Col 5|Col 6', -2, 120, _
                $wPos[2], $wPos[3], Default, 0x200)
_GUICtrlListView_SetExtendedListViewStyle($mainlistview, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES, $LVS_EX_FLATSB))
_GUICtrlListView_SetColumnWidth($mainlistview, 0, 120)
_GUICtrlListView_SetColumnWidth($mainlistview, 1, 250)
_GUICtrlListView_SetColumnWidth($mainlistview, 2, 50)
_GUICtrlListView_SetColumnWidth($mainlistview, 3, 100)
_GUICtrlListView_SetColumnWidth($mainlistview, 4, 100)
_GUICtrlListView_SetColumnWidth($mainlistview, 5, 50)
GUICtrlSetState(-1, $GUI_HIDE)
$hidepanellbl = GUICtrlCreateLabel('|', $wPos[2] - 300, 121, 10, $wPos[3] - 120, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, Default, Default, Default, "Wingdings 3")
GUICtrlSetBkColor(-1, 0xf2f8ff)
GUICtrlSetCursor(-1, 0)
GUICtrlSetState(-1, $GUI_HIDE)
#EndRegion ### $maingui ###

#Region ### $sidepanel ###
$sidepanel = GUICreate("", 290, 715, $wPos[2] - 312, 116, $WS_POPUP, BitOR($WS_EX_MDICHILD, 0x08000000), $maingui)
GUISetBkColor(0xf2f8ff)
GUICtrlCreateLabel("Document details:", 0, 8, 290, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlCreateLabel(" - Some details - ", 0, 40, 290, 17, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlCreateLabel("Test:", 5, 64, 45, 17)
$testinput = GUICtrlCreateInput("", 62, 60, 218, 21)
#EndRegion ### $sidepanel ###

#Region ### $list_gui ###
$list_gui = GUICreate('', 218, 107, 0, 0, $WS_POPUP, BitOR($WS_EX_MDICHILD, 0x08000000), $sidepanel)
$list = GUICtrlCreateList('', 0, 0, 218, 107, $WS_VSCROLL)
GUICtrlSetLimit(-1, 20)
#EndRegion ### $list_gui ###

#Region ### $additemsgui ###
$additemsgui = GUICreate('Add item(s) from Catalogue', $additemsgui_W, $additemsgui_H, 0, 0, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX), $WS_EX_MDICHILD, $maingui)
GUISetBkColor(0xf2f8ff)
GUISetFont(10, 400)
$additems_addlabel = GUICtrlCreateLabel('Start typing below to add item(s) from catalogue (min 2 chars):', 10, 15, $additemsgui_W - 20, 21)
$additemsinput = GUICtrlCreateInput('', 10, 45, $additemsgui_W - 20, Default)
GUICtrlSendMsg(-1, $EM_SETCUEBANNER, False, 'Enter a part number here')
$additemsbn_add = GUICtrlCreateButton('Add', 10, 85, 110, 40)
$hUP_add = GUICtrlCreateDummy()
$hDOWN_add = GUICtrlCreateDummy()
Dim $AccelKeys[3][2]=[["{UP}", $hUP_add], ["{DOWN}", $hDOWN_add], ["{ENTER}", $additemsbn_add]]
#EndRegion ### $additemsgui ###

#Region ### $additemslist_gui ###
$additemslist_gui = GUICreate('', $additemsgui_W - 20, 107, 0, 0, $WS_POPUP, BitOR($WS_EX_MDICHILD, 0x08000000), $additemsgui)
$additemslist = GUICtrlCreateList('', 0, 0, $additemsgui_W - 20, 107, $WS_VSCROLL)
#EndRegion ### $partnerinfolist_gui ###

#Region ### $additems_status_gui ###
$additems_status_gui = GUICreate('', 100, 63, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $additemsgui)
GUISetBkColor(0xf2f8ff)
$additems_status_pic = GUICtrlCreatePic('', 26, 0, 48, 48)
$additems_status_lbl = GUICtrlCreateLabel('', 0, 48, 100, 15, $SS_CENTER)
#EndRegion ### $additemslist_gui ###

GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO")
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUIRegisterMsg($WM_NCACTIVATE, "WM_NCACTIVATE")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUISetState(@SW_SHOW, $maingui)

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[1]
        Case $maingui
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $hDropDownAddItems_1
                    GUISetState(@SW_DISABLE, $maingui)
                    $mPos = WinGetPos($maingui)
                    WinMove($additemsgui, '', $mPos[0] + (($mPos[2]/2) - ($additemsgui_W/2)), $mPos[1] + (($mPos[3]/2) - ($additemsgui_H/2)))
                    GUICtrlSetData($additemsinput, '')
                    GUISetState(@SW_SHOW, $additemsgui)
                    _WinAPI_SetFocus(ControlGetHandle('', '', $additems_addlabel))
                    GUISetAccelerators($AccelKeys)
                Case $hDropDownNew_1
                    GUICtrlSetState($mainlistview, $GUI_SHOW)
                    GUICtrlSetState($hidepanellbl, $GUI_SHOW)
                    _RibbonsBar_GrandButtons_Enable($hGrandButton_New, 1)
                    _RibbonsBar_GrandButtons_Enable($hGrandButton_Save, 1)
                    _RibbonsBar_GrandButtons_Enable($hGrandButton_Export, 1)
                    _RibbonsBar_GrandButtons_Enable($hGrandButton_AddItems, 1)
                    _RibbonsBar_GrandButtons_Enable($hGrandButton_DelItems, 1)
                    _RibbonsBar_GrandButtons_Enable($hGrandButton_Open, 1)
                    _RibbonsBar_GrandButtons_Enable($hGrandButton_SPADetails, 1)
                    _WinAPI_RedrawWindow($maingui)
                    ShowSidePanel()
                Case $hDropDownNew_2
                Case $hidepanellbl
                    If $hidesidepanel = False Then  ;hide
                        HideSidePanel()
                    Else                            ;unhide
                        ShowSidePanel()
                    EndIf
            EndSwitch
        Case $additemsgui
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    GUISetState(@SW_ENABLE, $maingui)
                    GUISetState(@SW_HIDE, $additems_status_gui)
                    GUISetState(@SW_HIDE, $additemsgui)
                Case $hUP_add
                    ConsoleWrite('$hUP_add... (from add)'&@CRLF)
                Case $hDOWN_add
                    ConsoleWrite('$hDOWN_add... (from add)'&@CRLF)
                Case $additemsbn_add
                    If GUICtrlread($additemsinput) <> '' Then
                        ConsoleWrite('item will be added'&@CRLF)
                    EndIf
            EndSwitch
    EndSwitch

    Switch _RibbonsBar_GetMsg()
        Case $hGrandButton_Open
            ConsoleWrite('open file dialogue goes here...'&@CRLF)
        Case $SmallButton_Undo
            If _RibbonsBar_SmallButtons_GetState($SmallButton_Undo) = 1 Then
                ConsoleWrite('undo...'&@CRLF)
            EndIf
        Case $SmallButton_Redo
            If _RibbonsBar_SmallButtons_GetState($SmallButton_Redo) = 1 Then
                ConsoleWrite('redo...'&@CRLF)
            EndIf
        Case $hGrandButton_SPADetails
            If _RibbonsBar_GrandButtons_GetState($hGrandButton_SPADetails) = 1 Then
                If $hidesidepanel = False Then
                    HideSidePanel()
                Else
                    ShowSidePanel()
                EndIf
            EndIf
        Case $hTab_Home
            _RibbonsBar_Tab_SetState($hTab_Home)
        Case $hGrandButton_Export
            _RibbonsBar_ContextMenu_SetState($hDropDownExport)
        Case $hGrandButton_Save
            _RibbonsBar_ContextMenu_SetState($hDropDownSave)
        Case $hGrandButton_AddItems
            _RibbonsBar_ContextMenu_SetState($hDropDownAddItems)
        Case $hGrandButton_New
            _RibbonsBar_ContextMenu_SetState($hDropDownNew)
        Case $hTab_Help
            _RibbonsBar_Tab_SetState($hTab_Help)
    EndSwitch

    $cPos = GUIGetCursorInfo($maingui)
    If $cPos[4] = $hidepanellbl And $highlightsidepanellbl = False Then
        GUICtrlSetBkColor($hidepanellbl, 0xE2EFFD)
        $highlightsidepanellbl = True
    ElseIf $cPos[4] <> $hidepanellbl And $highlightsidepanellbl = True Then
        GUICtrlSetBkColor($hidepanellbl, 0xf2f8ff)
        $highlightsidepanellbl = False
    EndIf
WEnd

Func CheckInputText($from)
    Local $listdata = '|', $matches = 0, $listheight, $listPos, $searchtext

    If $from = 'SidePanel' Then
        $searchtext = GUICtrlRead($testinput)
    ElseIf $from = 'AddItems' Then
        $searchtext = GUICtrlRead($additemsinput)
    EndIf

    If $searchtext <> '' Then
        If $from = 'SidePanel' Then
            For $i = 0 To Ubound($testarray) - 1
                If StringInStr($testarray[$i], $searchtext) <> 0 Then
                    $listdata &= $testarray[$i] & '|'
                    $matches += 1
                EndIf
            Next
            StringTrimRight($listdata, 1)
            GUICtrlSetData($list, $listdata)
            $listheight = $matches * _GUICtrlListBox_GetItemHeight($list)
        ElseIf $from = 'AddItems' Then
            For $i = 0 To Ubound($testarray_additems) - 1
                If StringInStr($testarray_additems[$i], $searchtext) <> 0 Then
                    $listdata &= $testarray_additems[$i] & '|'
                    $matches += 1
                EndIf
            Next
            StringTrimRight($listdata, 1)
            GUICtrlSetData($additemslist, $listdata)
            $listheight = $matches * _GUICtrlListBox_GetItemHeight($additemslist)
        EndIf

        If $listheight <= 26 And $listheight > 13 Then
            $listheight = 30
        ElseIf $listheight <= 13 Then
            $listheight = 17
        ElseIf $listheight > 200 Then
            $listheight = 200
        EndIf

        If $from = 'SidePanel' And $matches >= 1 Then
            GUICtrlSetPos($list, Default, Default, Default, $listheight + 1)
            $listPos = ControlGetPos($list_gui, '', $list)
            WinMove($list_gui, '', Default, Default, Default, $listPos[3])
        ElseIf $from = 'AddItems' And $matches >= 1 Then
            GUICtrlSetPos($additemslist, Default, Default, Default, $listheight)
            $listPos = ControlGetPos($additemslist_gui, '', $additemslist)
            WinMove($additemslist_gui, '', Default, Default, Default, $listPos[3])
        ElseIf $matches = 0 Then
            If $from  = 'AddItems' Then GUISetState(@SW_HIDE, $additemslist_gui)
            If $from  = 'SidePanel' Then GUISetState(@SW_HIDE, $list_gui)
        EndIf
    EndIf
EndFunc

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    Local $iCode = BitShift($wParam, 16)
    Local $nIDFrom = BitAND($wParam, 0xFFFF)

    Switch $hWnd
        Case $sidepanel
            Switch $nIDFrom
                Case $testinput
                    Switch $iCode
                        Case $EN_KILLFOCUS
                            If WinGetState($list_gui) = 7 Then GUISetState(@SW_HIDE, $list_gui)
                        Case $EN_CHANGE
                            If GUICtrlRead($testinput) <> $sCurr_Input Then
                                CheckInputText('SidePanel')
                                $sCurr_Input = GUICtrlRead($testinput)
                                If StringLen(GUICtrlRead($testinput)) >= 1 Then
                                    $txt = GUICtrlRead($testinput)
                                    For $n = 1 To UBound($testarray) - 1
                                        If StringCompare(StringLeft($testarray[$n], StringLen($txt)), $txt) = 0 Then
                                            If GUICtrlRead($testinput) Then
                                                $aPos = WinGetPos($sidepanel)
                                                WinMove($list_gui, '', $aPos[0] + 62, $aPos[1] + 80)
                                                GUISetState(@SW_SHOWNOACTIVATE, $list_gui)
                                                _GUICtrlListBox_SetCurSel($list, $iCurrIndex)
                                            Else
                                                $iCurrIndex = -1
                                                _GUICtrlListBox_SetCurSel($list, $iCurrIndex)
                                                GUISetState(@SW_HIDE, $list_gui)
                                            EndIf
                                            ExitLoop
                                        EndIf
                                    Next
                                Else
                                    $iCurrIndex = -1
                                    _GUICtrlListBox_SetCurSel($list, $iCurrIndex)
                                    GUISetState(@SW_HIDE, $list_gui)
                                EndIf
                            EndIf
                    EndSwitch
            EndSwitch
        Case $additemsgui
            Switch $nIDFrom
                Case $additemsinput
                    Switch $iCode
                        Case $EN_KILLFOCUS
                            If WinGetState($additemslist_gui) = 7 Then GUISetState(@SW_HIDE, $additemslist_gui)
                        Case $EN_CHANGE
                            If GUICtrlRead($additemsinput) <> $sCurr_Input Then
                                CheckInputText('AddItems')
                                $sCurr_Input = GUICtrlRead($additemsinput)
                                If StringLen(GUICtrlRead($additemsinput)) >= 1 Then
                                    $txt = GUICtrlRead($additemsinput)
                                    For $n = 1 To UBound($testarray_additems) - 1
                                        If StringCompare(StringLeft($testarray_additems[$n], StringLen($txt)), $txt) = 0 Then
                                            If GUICtrlRead($additemsinput) Then
                                                $aPos = WinGetPos($additemsgui)
                                                WinMove($additemslist_gui, '', $aPos[0] + 13, $aPos[1] + 90)
                                                GUISetState(@SW_SHOWNOACTIVATE, $additemslist_gui)
                                                _GUICtrlListBox_SetCurSel($additemslist, $iCurrIndex)
                                            Else
                                                $iCurrIndex = -1
                                                _GUICtrlListBox_SetCurSel($additemslist, $iCurrIndex)
                                                GUISetState(@SW_HIDE, $additemslist_gui)
                                            EndIf
                                            ExitLoop
                                        EndIf
                                    Next
                                Else
                                    $iCurrIndex = -1
                                    _GUICtrlListBox_SetCurSel($additemslist, $iCurrIndex)
                                    GUISetState(@SW_HIDE, $additemslist_gui)
                                EndIf
                            EndIf
                    EndSwitch
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc  ;==>ED_WM_COMMAND


Func HideSidePanel()
    $wPos = WinGetPos($maingui)
    GUISetState(@SW_HIDE, $sidepanel)
    GUICtrlSetData($hidepanellbl, '|')
    GUICtrlSetPos($hidepanellbl, $wPos[2] - 28, Default, Default, $wPos[3] - 158)
    _WinAPI_SetWindowPos(GUICtrlGetHandle($mainlistview), 0, 0, 0, $wPos[2] - 27, $wPos[3] - 120, BitOR($SWP_NOMOVE, $SWP_NOZORDER))
    $hidesidepanel = True
EndFunc

Func ShowSidePanel()
    GUICtrlSetData($hidepanellbl, '}')
    $wPos = WinGetPos($maingui)
    WinMove($sidepanel, '', $wPos[0] + $wPos[2] - 300, $wPos[1] + 152, 290, $wPos[3] - 162)
    _WinAPI_SetWindowPos(GUICtrlGetHandle($mainlistview), 0, 0, 0, $wPos[2] - 316, $wPos[3] - 120, BitOR($SWP_NOMOVE, $SWP_NOZORDER))
    GUICtrlSetPos($hidepanellbl, $wPos[2] - 317, Default, Default, $wPos[3] - 158)
    GUISetState(@SW_SHOWNOACTIVATE, $sidepanel)
    $hidesidepanel = False
    $aPos = WinGetPos($maingui)
    WinMove($maingui, "", $aPos[0], $aPos[1], $aPos[2] + 1, $aPos[3] + 1)
    WinMove($maingui, "", $aPos[0], $aPos[1], $aPos[2], $aPos[3])
EndFunc

Func WM_SIZE($hwnd, $uMsg, $wParam, $lParam)
    If $hwnd <> $maingui Then Return 0
    If $hidesidepanel = False Then
        $wPos = WinGetPos($maingui)
        _WinAPI_SetWindowPos(GUICtrlGetHandle($mainlistview), 0, 0, 0, _WinAPI_LoWord($lParam) - 300, _WinAPI_HiWord($lParam) - 119, BitOR($SWP_NOMOVE, $SWP_NOZORDER))
        GUICtrlSetPos($hidepanellbl, _WinAPI_LoWord($lParam) - 301, Default, Default, $wPos[3] - 158)
        WinMove($sidepanel, '', $wPos[0] + $wPos[2] - 300, $wPos[1] + 152, Default, $wPos[3] - 160)
    ElseIf $hidesidepanel = True Then
        $wPos = WinGetPos($maingui)
        GUICtrlSetPos($hidepanellbl, _WinAPI_LoWord($lParam) - 11, Default, Default, $wPos[3] - 158)
        _WinAPI_SetWindowPos(GUICtrlGetHandle($mainlistview), 0, 0, 0, _WinAPI_LoWord($lParam) - 10, _WinAPI_HiWord($lParam) - 119, BitOR($SWP_NOMOVE, $SWP_NOZORDER))
    EndIf
    Return 1
EndFunc

Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam)
    If $hWnd = $maingui Then
        $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
        DllStructSetData($tagMaxinfo, 7,  800) ; W (min size)
        DllStructSetData($tagMaxinfo, 8,  600) ; H (min size)
;~         DllStructSetData($tagMaxinfo, 9,  800) ; W (max size)
;~         DllStructSetData($tagMaxinfo, 10, 600) ;  H (max size)
        Return 0
    EndIf
EndFunc   ;==>WM_GETMINMAXINFO

; Prevent child windows in making GUI title bar dimmed
Func WM_NCACTIVATE($hWnd, $iMsg, $wParam)
    If $hWnd = $maingui Then
        If Not $wParam Then Return 1
    ElseIf $hWnd = $sidepanel Then
        If WinGetState($additemsgui) = 7 Then
            WinActivate($additemsgui)
            Return 1
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

I have a feeling that the solution will be somewhere here, however I don't really understand this function properly.... can anyone possibly elaborate on how this functions works and whether it can indeed solve my problem of the $additemslist_gui stealing focus when items are clicked in the $additemslist control?

Func WM_NCACTIVATE($hWnd, $iMsg, $wParam)
    If $hWnd = $maingui Then
        If Not $wParam Then Return 1
    ElseIf $hWnd = $sidepanel Then
        If WinGetState($additemsgui) = 7 Then
            WinActivate($additemsgui)
            Return 1
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

Really appreciate all the help peeps!

Edited by mpower
Link to comment
Share on other sites

Replace first line in WM_NCACTIVATE with this:

If $hWnd = $maingui Or $hWnd = $additemsgui Then
You can use a Switch-statement if you have many GUI's.

The code in WM_NCACTIVATE decides whether a focus loss should have a visual effect or not. Google WM_NCACTIVATE for more info.

Link to comment
Share on other sites

  • Solution

mpower,

When you resize the list, the parameters in the handler refer to that GUI and not the main one - hence the ListView vanishing as it was redrawn outside the main GUI. All you need do is check which GUI sent the SIZE message and ignore those from the list GUI: ;)

Func WM_SIZE($hwnd, $uMsg, $wParam, $lParam)
    If $hWnd <> $maingui Then Return 0
[...]
M23

 

 

Replace first line in WM_NCACTIVATE with this:

If $hWnd = $maingui Or $hWnd = $additemsgui Then
You can use a Switch-statement if you have many GUI's.

The code in WM_NCACTIVATE decides whether a focus loss should have a visual effect or not. Google WM_NCACTIVATE for more info.

 

 

You guys are, once again, really awesome, thank you! The community of this forum is simply amazing. 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...