Question

I'm really annoyed right now. I'm trying for days to figure this out and I've got to the conclusion that I definitely need to post a question or two here.

So, I'm trying to make an application in C++ with the win32 api that has just one tray icon and no window, but I still want the message pump working in the background because I want to handle events from my synaptics touchpad. I think I figured out how the synaptics SDK works, but I'm still struggling with this win32.

What may the neowin community suggest?

8 answers to this question

Recommended Posts

  • 0

Most events are only going to be delivered to your window via the message pump when your application is in the foreground. Since you have no window, that will be almost never.

I definitely understand your struggle with WIN32. It's not the most user friendly interface, which even Microsoft recognizes. There have been many attempts at C++ wrappers around the windowing portion of the WIN32 API to make it easier to use. Microsoft themselves once promoted MFC, but that has been long since depreciated. I'm not sure what Microsoft's current recommendation for WIN32 in C++ is; maybe Asik or one of the other pros around here can tell you. My understanding is that Microsoft is pushing C# and .NET for traditional desktop applications and is not really focused on providing and easy C++ wrapper anymore.

Personally I have used SmartWin++ for many years. It is a very lightweight, clean object-oriented wrapper around the WIN32 API that melds the power of WIN32 with ease-of-use. In case you are interested in extending its functionality, SmartWin++ is also designed to be highly module and provides extensive examples and documentation for all aspects of development within and without. Unfortunately the project died in 2008. However, I still use it extensively in my own Windows programs. I have maintained my own fork of the last released version of SmartWin++ to which I have added support for newer compilers (mostly GCC/MinGW, I don't really care about MSVC), an enhanced build system, more widgets, many bug fixes, and extended documentation. My fork is not publicly available, but you should have no difficulty using the last official version of SmartWin++ if you so choose.

  • 0

what you're looking for is "windows hooks".

http://msdn.microsof...9(v=vs.85).aspx

what these allow you to do is intercept messages of system wide processes,or they can be thread specific.

for example,you install a system wide mouse hook , and you get system wide mouse messages. this is actually how a lot of keyloggers work. they install a keyboard system hook,and receive every character typed. you can do the same with the mouse. since only foreground windows receive mouse or keyboard messages, you will receive all mouse message no matter which app is open,and again you can make it thread specific if you want.

  • 0
  On 28/04/2013 at 01:14, vcfan said:

what you're looking for is "windows hooks".

http://msdn.microsof...9(v=vs.85).aspx

what these allow you to do is intercept messages of system wide processes,or they can be thread specific.

for example,you install a system wide mouse hook , and you get system wide mouse messages. this is actually how a lot of keyloggers work. they install a keyboard system hook,and receive every character typed. you can do the same with the mouse. since only foreground windows have an active message loop, you will receive all mouse message no matter which app is open,and again you can make it thread specific if you want.

THAT. IS. COOL. I had no idea that was even possible! Thanks for the explanation. Hopefully it helps the OP too.

  • 0
  On 28/04/2013 at 01:16, xorangekiller said:

THAT. IS. COOL. I had no idea that was even possible! Thanks for the explanation. Hopefully it helps the OP too.

yep,and there are other ways to do it too. you could use DLL injection into whatever process you want to spy on its messages, get the class name, modify the function pointer to the windows procedure in the class structure to your own windows procedure. In your windows procedure, call up the original processes windows procedure for everything but mouse messages, and handle mouse messages yourself.

  • 0

It should be noted that hooks have a system-wide performance cost as long as they're active, so they should be used sparingly. They can also make it difficult to break execution in a debugger, I've seen them cause very long stalls.

  On 28/04/2013 at 00:30, xorangekiller said:
I'm not sure what Microsoft's current recommendation for WIN32 in C++ is; maybe Asik or one of the other pros around here can tell you. My understanding is that Microsoft is pushing C# and .NET for traditional desktop applications and is not really focused on providing and easy C++ wrapper anymore.
.NET + P/Invoke from Win32 what isn't exposed in .NET is pretty much the way to go today; MFC and ATL are quite dead as far as I'm aware.
  • 0

Synaptics SDK suggests that you can do without message loop. Create a global named event, SetEventNotification for it and then WaitForSingleObject for this very event in an infinite loop and process each SynPacket as it comes.

It does make it troublesome for tray icon, but then again - what's it for?

  • 0

You need to create a blank window with nothing in it. 0 size and make sure it's invisible. Use CreateWindow().

And on top of that empty nothingness window, enable the tray Icon.

Play around with the flags until you get a window that's not visible in the task bar but is visible in the systray. Then play around with the window messages that are sent when someone clicks or double clicks. Just make the code ignore any handling of the messages to make sure that it doesn't fall back to the default window proc that's automatically executed for unhandled messages, if you make your window message loop the right way.

This is at least how I did it a few years back. Certain window types are not visible in the task bar. I think this is how it's meant to be done. But I could be wrong.

This topic is now closed to further replies.
  • Posts

    • Wall cabinet: Fiber connection (1Gbps) Patch panel 2.5Gbps Router A mini PC with Ryzen 5800H CPU and 32GB DDR4 RAM, for network related tools (Portainer, Pi-Hole, Cloudflared, Tailscale, Uptime Kuma, Wetty) A headless server running Proxmox: AMD Ryzen 9 9950X CPU, 96GB DDR5, RTX 3090 24GB GPU, 10Gbps NIC, and a bunch of NVMs, SATA SSDs, HDDs A VM with TrueNAS for backups and media server via Jellyfin, passing through the SATA storage controller A VM with an Ubuntu server acting as a web and a GPU server for AI workloads, and a TeamCity build/deploy agent for my personal projects This setup has evolved many times for the last 2 years, I have not gone completely crazy, yet (I think), but still experimenting, still learning, it is a fun and rewarding experience having a home lab!
    • Microsoft PC Manager 3.17.4.0 (Offline Installer) by Razvan Serea With Microsoft PC Manager, users can easily perform basic computer maintenance and enhance the speed of their devices with just one click. This app offers a range of features, including disk cleanup, startup app management, virus scanning, Windows Update checks, process monitoring, and storage management. Microsoft PC Manager key features: Storage Manager- easily uninstall infrequently used apps, manage large files, perform a cleanup, and set up Storage Sense to automatically clear temporary files. Health Checkup feature -scans for potential problems, viruses, and startup programs to turn off. It helps you identify unnecessary items to remove, optimizing your system's performance. Pop-up Management - block pop-up windows from appearing in apps. Windows Update - scans your system for any pending updates. Startup Apps - enable or disable startup apps on your PC, allowing you to optimize your system's startup performance. Browser Protection - rest assured that harmful programs cannot alter your default browser. Also enables you to change your default browser. Process Management - allows you to conveniently terminate any active process, ensuring optimal system performance and resource utilization. Anti-virus protection - Fully integrated with Windows Security. Safeguard your PC anytime. Quick Steps: Download Microsoft PC Manager Offline Installer (APPX/MSIX) with Adguard Adguard serves as a third-party online service, offering a user-friendly method for directly downloading appx, appxbundle, and msixbundle files from the Microsoft Store. Official download links will be generated for both the app's various versions and its dependency packages. How to download Microsoft PC Manager Offline Installer (APPX/MSIX) 1. Initially, you must find the app URL within the Microsoft Store. Access the Microsoft Store via your browser and search for "Microsoft PC Manager". Once located, copy the app URL, which includes the product ID, either from the address bar or from the provided link below. https://apps.microsoft.com/detail/9PM860492SZD 2. Now paste the app URL into the designated area, then click the check mark button to produce a direct download link. 3. To download, right-click the relevant link and select “Save link as…” from your browser's menu. Occasionally, Microsoft Edge may flag the download as insecure. In such cases, consider utilizing alternative browsers such as Google Chrome or Firefox to successfully complete the download. Microsoft PC Manager is a completely free tool optimized exclusively for use on Windows 10 (version 1809 or newer) and Windows 11. Download: Microsoft PC Manager 3.17.4.0 | from Microsoft Store View: Microsoft PC Manager Home Page Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • You might want to update to 1TB drive.  They are not very expensive these days, there are plenty of options - simple look I would think you could find a 1TB ssd or even nvme somewhere between 50 and 100 bucks. when I have moved to larger ssds in laptop in the past, you can just connect the drive via usb - image.  Then take the old drive out, put in the new drive and there you go..  If your concerned about how much space you have left this prob your best bet..   
    • I see! Wasn’t aware of that. Even though they started off with desktop app for Mac before Windows. Should be on it’s way soon! 🤞
    • support.microsoft.com/en-us/topic/microsoft-defender-update-for-windows-operating-system-installation-images-1c89630b-61ff-00a1-04e2-2d1f3865450d
  • Recent Achievements

    • First Post
      Johnny Mrkvička earned a badge
      First Post
    • Week One Done
      viraltui earned a badge
      Week One Done
    • One Month Later
      serfegyed earned a badge
      One Month Later
    • Dedicated
      firey earned a badge
      Dedicated
    • Dedicated
      fettermanj earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      644
    2. 2
      ATLien_0
      226
    3. 3
      Michael Scrip
      223
    4. 4
      Xenon
      153
    5. 5
      +FloatingFatMan
      144
  • Tell a friend

    Love Neowin? Tell a friend!