You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following a discussion in the comments the DelphiDabbler Blog post at
https://tinyurl.com/mrp76mdy it seems that was not a good idea to rely
upon handling WM_POWERBROADCAST's PBT_APMPOWERSTATUSCHANGE event to
restore the overview pane's tree view nodes to the expected state after
Windows has recreated the tree view in an invalid state.
So I've modified the code to only rely on the PBT_APMSUSPEND event of
WM_POWERBROADCAST and not PBT_APMPOWERSTATUSCHANGE. PBT_APMSUSPEND is
handled to prepare for hibernation by not only saving the tree view's
state (as per the previous fix) but also setting an event handler that
gets called only when the tree view's window gets recreated by Windows
AND the treeview contains nodes with nil IView pointers. When called,
the event handler rebuilds the tree view with nodes containing valid
IView references.
The problem is that the event needs to be triggered from the
TTreeView.CreateWnd method that gets called when Windows recreates the
tree view. Since TTreeView exposes no suitable events, the only way is
to inject a suitable event using a nasty hack. Not good practise.
Note that all the methods that depend on the hack have been given names
beginning with "_HACK_" to make it obvious where the naughtiness lies.
0 commit comments