Jump to content

Need help synchronizing MDI (WS_EX_MDICHILD) window with Child Window (WS_CHILD)


Go to solution Solved by pixelsearch,

Recommended Posts

Posted (edited)

@pixelsearch I have a question regarding the following code:

Case $LVN_ENDSCROLL
    Local Static $tagNMLVSCROLL = $tagNMHDR & ";int dx;int dy"
    Local $tNMLVSCROLL = DllStructCreate($tagNMLVSCROLL, $lParam)
    If $tNMLVSCROLL.dy = 0 Then ; ListView horizontal scrolling
        _resizeHeaderItems()
    EndIf

 

The horizontal scrolling is very smooth. However, I notice occasionally that vertical scrolling can cause some flicker. Now, there is no need to resize headers when vertical scrolling, of course. However, if we can run _changeExStyles() when vertical scrolling is detected, I am pretty confident that it will get rid of any vertical scrolling flicker.

Is there a way to run that function when vertical scrolling is detected?

Thank you. :)

 

EDIT:  I ended up figuring it out thanks to you already having the structure in place. Thanks again. :)

Case $LVN_ENDSCROLL
    Local Static $tagNMLVSCROLL = $tagNMHDR & ";int dx;int dy"
    Local $tNMLVSCROLL = DllStructCreate($tagNMLVSCROLL, $lParam)
    If $tNMLVSCROLL.dy = 0 Then ; ListView horizontal scrolling
        _resizeHeaderItems()
    EndIf
    If $tNMLVSCROLL.dx = 0 Then ; ListView vertical scrolling
        ConsoleWrite("vertical scrolling detected" & @CRLF)
    EndIf

 

Edited by WildByDesign
Posted (edited)
1 hour ago, WildByDesign said:

I ended up figuring it out thanks to you already having the structure in place. Thanks again. :)

Yes but please be careful, $LVN_ENDSCROLL shouldn't be the right place to run _changeExStyles() , I would place it when $LVN_BEGINSCROLL is detected (for vertical scrolling only)

Here is a WM_NOTIFY function (just for test purpose) . It indicates how many times each notification occurs. From all notifications found in the function, only 4 are triggered a lot of times (when others are triggered only once. These 4 frequent notifications are : $HDN_TRACK, $HDN_TRACKW, $LVN_BEGINSCROLL, $LVN_ENDSCROLL

As you suggested, I added _changeExStyles() in the $LVN_BEGINSCROLL part (when vertical scroll begins). As $LVN_BEGINSCROLL / $LVN_ENDSCROLL are constantly triggered when the scrollbars are moved, you'll have to check on your computer if calling _changeExStyles() so frequently creates an issue... or not.
Good luck :)

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

    Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    Local $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hHeader
            Switch $iCode
                Case $HDN_TRACK, $HDN_TRACKW
                    Local Static $iHDN_TRACK = 0
                    $iHDN_TRACK += 1
                    ConsoleWrite("$iHDN_TRACK #" & $iHDN_TRACK & @crlf)
                    Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    Local $iHeaderItem = $tNMHEADER.Item
                    Local $tHDITEM = DllStructCreate($tagHDITEM, $tNMHEADER.pItem)
                    Local $iHeaderItemWidth = $tHDITEM.XY
                    _GUICtrlHeader_SetItemWidth($g_hHeader, $iHeaderItem, $iHeaderItemWidth)
                    _resizeLVCols() ; <========================
                    Return False ; to continue tracking the divider

                Case $HDN_BEGINTRACK, $HDN_BEGINTRACKW
                    Local Static $iHDN_BEGINTRACK = 0
                    $iHDN_BEGINTRACK += 1
                    ConsoleWrite("$iHDN_BEGINTRACK #" & $iHDN_BEGINTRACK & @crlf)
                    Return False ; To allow tracking of the divider

                Case $HDN_ENDTRACK, $HDN_ENDTRACKW
                    Local Static $iHDN_ENDTRACK = 0
                    $iHDN_ENDTRACK += 1
                    ConsoleWrite("$iHDN_ENDTRACK #" & $iHDN_ENDTRACK & @crlf)

                Case $HDN_BEGINDRAG
                    Local Static $iHDN_BEGINDRAG = 0
                    $iHDN_BEGINDRAG += 1
                    ConsoleWrite("$iHDN_BEGINDRAG #" & $iHDN_BEGINDRAG &@crlf)
                    Return False ; To allow the header control to automatically manage drag-and-drop operations

                Case $HDN_ENDDRAG
                    Local Static $iHDN_ENDDRAG = 0
                    $iHDN_ENDDRAG += 1
                    ConsoleWrite("$iHDN_ENDDRAG #" & $iHDN_ENDDRAG & @crlf)
                    $g_bHeaderEndDrag = True ; <========================
                    Return False ; to allow the control to automatically place and reorder the item

                Case $HDN_ITEMCLICK, $HDN_ITEMCLICKW
                    Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    Local $iHeaderItem = $tNMHEADER.Item
                    ConsoleWrite("Item " & $iHeaderItem & " clicked"  & @crlf)

                Case $HDN_DIVIDERDBLCLICK, $HDN_DIVIDERDBLCLICKW
                    Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
                    Local $iHeaderItem = $tNMHEADER.Item
                    ConsoleWrite("Divider " & $iHeaderItem & " double clicked"  & @crlf)
            EndSwitch

        Case $g_hListView
            Switch $iCode
                Case $LVN_BEGINSCROLL, $LVN_ENDSCROLL
                    Local Static $iLVN_BEGINSCROLL_H = 0, $iLVN_ENDSCROLL_H = 0, $iLVN_BEGINSCROLL_V = 0, $iLVN_ENDSCROLL_V = 0
                    Local Static $tagNMLVSCROLL = $tagNMHDR & ";int dx;int dy"
                    Local $tNMLVSCROLL = DllStructCreate($tagNMLVSCROLL, $lParam)
                    If $tNMLVSCROLL.dy = 0 Then ; ListView horizontal scrolling
                        Switch $iCode
                            Case $LVN_BEGINSCROLL
                                $iLVN_BEGINSCROLL_H += 1
                                ConsoleWrite("$iLVN_BEGINSCROLL_H #" & $iLVN_BEGINSCROLL_H & @crlf)
                            Case Else ; $LVN_ENDSCROLL
                                $iLVN_ENDSCROLL_H += 1
                                ConsoleWrite("$iLVN_ENDSCROLL_H #" & $iLVN_ENDSCROLL_H & @crlf)
                                _resizeHeaderItems() ; <========================
                        EndSwitch
                    Else ; ListView vertical scrolling
                        Switch $iCode
                            Case $LVN_BEGINSCROLL
                                $iLVN_BEGINSCROLL_V += 1
                                ConsoleWrite("$iLVN_BEGINSCROLL_V #" & $iLVN_BEGINSCROLL_V & @crlf)
                                _changeExStyles() ; <========================
                            Case Else ; $LVN_ENDSCROLL
                                $iLVN_ENDSCROLL_V += 1
                                ConsoleWrite("$iLVN_ENDSCROLL_V #" & $iLVN_ENDSCROLL_V & @crlf)
                        EndSwitch
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

 

Edited by pixelsearch
typo

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Posted (edited)
22 minutes ago, pixelsearch said:

you'll have to check on your computer if calling _changeExStyles() so frequently creates an issue... or not

Realistically, I should figure out a way to limit how often it gets called. I have to find a way to track that and keep a variable of the time difference.

Since the Adlib stays active for 3 seconds before reverting styles, the _changeExStyles() technically only needs to be called every 2 seconds maybe.

I actually tried to track this time diff earlier but failed miserably. I’ll have to try again though because it would be important for performance and efficiency.

Edited by WildByDesign
Posted

For the record, calling  _changeExStyles() from $LVN_BEGINSCROLL behaves badly on my computer (vertical scrolling down and up, which calls _changeExStyles() dozen of times in a few ms, when the function adds/removes styles to the GUI/LV with a timer each 3s . This is the wrong display I got now :

issuecalling_changeExStylestoooften.png.83546a48259608a3260398165b74d6e8.png

 

11 minutes ago, WildByDesign said:

I’ll have to try again though because it would be important for performance and efficiency.

Hope you'll find a way. Good luck :)

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Posted
19 hours ago, pixelsearch said:

For the record, calling  _changeExStyles() from $LVN_BEGINSCROLL behaves badly on my computer (vertical scrolling down and up, which calls _changeExStyles() dozen of times in a few ms, when the function adds/removes styles to the GUI/LV with a timer each 3s . This is the wrong display I got now :

I just wanted to confirm that I get those glitches with $LVN_BEGINSCROLL as well. It seems to be guaranteed to be problematic. For whatever reason, I don't know, but having it in $LVN_ENDSCROLL seems to work 100% for me. No issues there.

 

19 hours ago, pixelsearch said:

Hope you'll find a way. Good luck :)

I had been trying many overly complicated methods which failed. I ended up going with a high precision timer which was more simplistic but works very well. Initially I had the timer for 3 seconds to match the adlib but it would cause an occasional flicker in between. So I switched the timer to 2 seconds while the adlib is at 3 seconds to allow some overlap.

In this case, the function does a Return immediately if it was already called less than 2 seconds prior. If it's between 2-3 seconds, it will call it again and also reset the 3 second adlib timer.

So while that all works well and efficiently, I'm trying some other ideas at the moment.

Posted
On 12/5/2025 at 9:55 PM, ioa747 said:

and,  after a little observation, I noticed that after each change of _GUIFrame, it updates the GUI with Msg 4, so

By the way, how did you find out the possible Msg numbers?

Do you know if there is a Msg related to starting the movement of the separator? As opposed to after it has moved?

Posted
2 hours ago, WildByDesign said:

By the way, how did you find out the possible Msg numbers?

as I said, after a little observation  :)
 

after reading the index

; #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_ResizeState:  Returns the resize state of the frames
; _GUIFrame_ResizeReg:    Registers WM_SIZE message for resizing
; _GUIFrame_SIZE_Handler: 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
; ====================================================================================================================

I noticed the _GUIFrame_SepPassMsg:    Passes Msg to original frame WndProc for action
and then I put it

While True
    Local $iMsg = GUIGetMsg()
    Switch $iMsg
        ...
        
        Case Else
            If $iMsg <> 0 Then ConsoleWrite("$iMsg=" & $iMsg & @CRLF)
            
    EndSwitch
WEnd

to see

 

I know that I know nothing

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
×
×
  • Create New...