CTreeCtrl TVN_SELCHANGED not being fired when item is clicked - mfc

I have an existing MFC application installed on many computers (000's). One user installed the current version and reports symptoms that indicate that the TVN_SELCHANGED event is not being fired when selecting items in the tree control. There is nothing odd about the computer configuration (latest Windows 7 with latest patches etc) and all else seems to work as designed.
Of importance is that the application was working fine up until a system restart a few days ago. The application is completely stand-alone (MFC statically linked), no runtime DLL's or COM components.
The Question: Can anyone shed any light as to why the TVN_SELCHANGED event might not be fired on some computer configurations (i.e A specific version of MS Office, or IE, or .NET Framework being present, not being present, common controls manifest versions etc?)
Any help would be appreciated.

If you really think that TVN_SELCHANGED is not being fired try running Spy++ and see what is being reported. Are other programs which use treeviews working?
My guess is that something as basic as TVN_SELCHANGED is working just fine but that something else in the app is not working (ie the developers code) and just making it LOOK like a sel changed is not happening.

Related

Detect dark application style/theme of currently used desktop in Qt

The bounty expires in 7 days. Answers to this question are eligible for a +50 reputation bounty.
codeling wants to draw more attention to this question:
Give concise information (and ideally code) on how to detect dark theme on KDE and Gnome desktop environments using Qt, or if there is no direct way with Qt, using plain C++ (or at least as little additional libraries as possible).
In our Qt-based C++ application, I'm trying to automatically switch application styles based on whether the user has configured dark or bright theme.
I have figured out the notification of when a change happens (see below, for other's reference).
My main problem is the reliable detection of whether currently a dark or bright theme is used on linux (for windows see below); on XFCE, the check for QPalette color roles as mentioned in this answer works, but this does not work on Gnome and KDE Plasma for me (tested under both Ubuntu 22.04 and Fedora 36, my app built against Qt versions 6.5beta2 and 6.4.2, respectively); there the colors still seem to be taken from what I've set as XFCE theme on the same machine (and when starting xfce4-appearance-settings and changing the theme there, my app picks up the change). I would however like to adapt to the current desktop's dark mode setting.
So, my question is: How do I reliably detect application dark mode of the currently used desktop on Qt? I'm not averse to implementing a little custom platform-specific code if nothing is available directly in Qt, but it would be great if it would work without using additional libraries.
A note I saw for QApplication::setPalette I thought might be relevant here, namely "Some styles do not use the palette for all drawing, for instance, if they make use of native theme engines.", what are these all about? I did not see a link to a documentation for this feature, and a quick search for the term "qt native theme engine" also didn't seem to yield any useful results.
Since on Linux, some events are reliably triggered whenever a system theme change happens (see below), I suppose Qt can detect the theme change, it just doesn't expose data about it publicly?
Getting notified of theme changes
On Linux: via listening for QEvent::StyleChange events of the application's QMainWindow; two caveats and one side note:
That event does, despite QWidget::changeEvent documentation explicitly mentioning it, not trigger a changeEvent (for me), but has to be caught via the more generic QWidget::event
StyleChange only seems to be triggered since some Qt 6.4 version (in my tests, it was not triggered by 5.15.2 and 6.3.1, but triggered for 6.4.2 and 6.5.0beta2).
I've also noticed that there's a ThemeChange event that is also triggered (at the same time as the StyleChange; not sure what the difference is between these two though, and in what case one would be triggered but not the other... I suppose StyleChange is used for any change to the style of a widget, so that it's also called when applying some style sheet settings, while ThemeChange really indicates a change of the system theme? Though ThemeChange seems to be considered a non-public Event type, at least it doesn't appear in the documentation (marked \omitvalue)
On Windows, via checking for changes to the registry key HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize (the StyleChange unfortunately isn't triggered there at all - a Qt bug?). .
Detecting dark theme on Windows
Application bright/dark mode determined by registry key HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize\AppsUseLightTheme (1 for bright, 0 for dark). This check is also done in Qt's plugins/platforms/windows/qwindowstheme (queryDarkMode`), but I think this is not exposed publicly as generic interface anywhere?

Windows 10 C++ NetworkExplorerPlugins context menu handler example

I have numerous ESP8266 / ESP32 / STM32 IOT devices, running my own firmware. One of the functions is a uPNP/SSDP provider which allows remote control from Amazon Echo devices and/or anything that can "speak" SSDP. I managed to find enough info to get these devices automatically added to the Windows network "Home Automation" view by tweaking the registry:
My next step is to have what I think is a "context menu handler" so I can right-click the relevant device and have on/off/toggle options that then send the relevant SOAP envelop to the device to switch on etc. I'd also like to either change the icon (or add an overlay) in-flight to show the on/off state of the device, but that is icing on the cake.
I am having having serious difficulty finding an example C++ framework I can cut and paste to start me off that is relevant, accurate and modern. Every example I find is either for an explorer file menu, or in C#, or literally decades out of date: no doubt much is similar but it is "hooking" the thing in to the Network Pane of Windows 10 that I simply can't find how to do. Even on the MS developer site the information talks mostly about Vista and even XP(!) and is generally quite incomprehensible. The clearest site I could find (dated 2018) recommended a book on Windows Shell programming that was published in...wait for it...1998!
I know I'm going to have to build a DLL - I'm fine with that, I just need a good "leg-up".
"NetworkExplorerPlugins" brings up precisely 0 hits here.
I have been searching unsuccessfully for weeks - can anybody point me to a recent Windows 10-specific C++ example or tutorial that will get me started?

How to shell to another app and have it appear in a Borland VCL form (c++)

I'm actually in charge of a FIP networking c++ application, working for the first time with Embarcadero C++ Builder XE5.
The app is nearly finished, but I can't find how to implement the last feature...
I wanted to open an external Windows HyperTerminal in order to see what happen on a given COM port, for this purpose I'm using ShellExecute() to launch it from my application but it's a bit ugly since there is 2 different windows.
I was wondering if it was possible to integrate this newly opened HyperTerminal into an existing form (Panel for instance). I couldn't find nothing related excepted this =>
Delphi style, but i don't understand a byte of #mghie answer since it's delphi.
If anyone have a clue I'm really interested, even the most basic clue!
For almost all of my projects where COM port interaction is needed I use AsyncPro. The project is very well documented with a ~1000 page reference manual.
Reference Manual
Developer's Guide
For this case, the package provides a VCL terminal that simply drops onto a form. It's quite flexible with a lot of options to configure its behaviour.
I wanted something similar in past but with no success.
1.The only thing I was able to do is the exact opposite.
dock my VCL window inside another (not VCL app) but that solved my problems
If you terminal is console window then I doubt even this can be done.
anyway find handle of desired window
find handle to a dockable subcomponent
set the parent of your subwindow to it / or use manual dock
2.maybe you can do some funny stuff
like hide terminal somewhere
and continuoslly copy its graphics to your window
newer done that hide thing
but copy the contents is doable (although on windows a little unstable sometimes)
done it once to feed my App with IR-camera feed from different App
while 'focus' stays on hidden terminal it should work
also you can try to post messages to it somehow if you need the focus ...
Sorry for a vague answer but at least you see some approaches of mine
maybe someone has a better way to do this

Debugging GUI Applications in C++

Background: I'm currently debugging an application written over a custom-built GUI framework in C++. I've managed to pin down most bugs, but the bugs I'm having the most trouble with tend to have a common theme.
All of them seem to be to do with the screen refreshing, redrawing or updating to match provided data. This is a pain to debug, because I can't break on every refresh, and most of this stuff is time-sensitive, so breakpoints occasionally "fix" the bug.
Q: Does anyone have any tips for debugging Windows-based GUIs, especially regarding the refreshing of individual components?
I agree with dual monitors or even remote debugging to reduce interfering with the messages.
I also highly recommend Spy utilities. These let you see what messages are being sent in the system. One such program is Winspector.
http://www.windows-spy.com/
This may not help, but I've found using dual monitors useful in this scenario. I have the debugger on one screen and the application on another. I can then step thru the code and see the application refreshing or doing whatever it is on the other screen.
There is still issues with focus doing this way, but at least I can see when it repaints.
Logging is pretty much the only answer. Without knowing your framework I can't give an exact answer but basically open a file and append messages in the various procedures of interest. Finally close it.
In the message include the values of the variable that you are interested in.
Also using the window Message Box is useful to see if you are in the correct branch or procedure. This has minimal effect on over all flow.
Finally try downloading any of the express version of .NET and use Winforms to try to make test of particularly problematical areas. While Winform is it own framework there is a high degree of correspondence between it's control and the ones provided by Windows.
I maintain a simulation of the Project Mercury Capsule as an add-on for the Orbiter Space Simulator. It is written in C++ and has to use Win32 directly for some of the panels and dialogs. There were times I fired up VB6 (VB.NET later) to work out some complex interaction and then translated it over to it's Win32 equivalent in C++.
However this is a last resort.
Having a dual screen really help when debugging refresh/redraw problem for Windows controls and UI.
Having the application on the second screen will not have the debugger generate "invalidate" on the main UI screens when it breaks for a debugging breakpoint.
If you cannot have a second screen, try to have both application side-by-side so that the application and the debugger will not interfere.

Change Windows Mobile 6.1 Theme Programmatically

I am trying to figure out the proper procedure for applying a new tsk based theme file in windows mobile 6.1.
I have tried working off of the page http://www.pocketpcdn.com/articles/changetodaytheme.html But this only changes the background, not the system colors for things such as the top and bottom bars on the screen.
wceload.exe seems to work perfectly for some tsk's and partially for others.
Does anyone know more about tsk files and applying them programmatically in Windows Mobile 6.1?
My application is an open source application, the code is avail;able via read only svn, feel free to check it out # google code
I ended up finding a solution, I don't think it is a universal solution though.
Calling "\Windows\cusTSK.exe \Windows\ThemeName.tsk" changes the top and bottom bars, but does not change all apsects of the theme... so calling wceload.exe and then calling cuTSK.exe in that order seems to be able to change the theme using all tsk files that I have tested.
The cusTSK.exe binary does not exist on the Windows Mobile 6.1 Professional emulator image that you can download from msdn, so I think that this file that exists on custom roms and HTC made devices, that is why I do not think this is a universal solution, but it works for my purposes