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

    • Switch to another OS if you're into tinfoil hat mentality, or just uninstall the app. Oh, wait, even after uninstalling it, can Microsoft still be looking at everything? We'll never know, so, yeah, that's that. If you use Windows, you need to live with those options.
    • Minecraft Chase the Skies update and Vibrant Visuals graphics overhaul lands next week by Pulasthi Ariyasinghe The second major game update of the year for Minecraft is almost here. Mojang today announced that its next Game Drop, Chase the Skies, is landing on June 17. Alongside it, the highly anticipated graphics overhaul, dubbed Vibrant Visuals, will be available too, making the day a rather big occasion for Minecraft fans. The Chase the Skies update has a large number of gameplay features and content, but one of the biggest is the expansion of the Ghast. Now, players will be able to find Happy Ghasts as a tameable mob, letting up to five players ride them on journeys across the skies. To get one, players will have to find small, dehydrated Ghasts near fossil structures in the Nether, then bring it to the overworld and feed it plenty of water. It is also possible to craft dried Ghasts from Nether materials. Other features of this update include a handy player locator bar, better leads functionality, craftable saddles, a new music disc, and more. As for the Vibrant Visuals upgrade, Mojang is touting a visual refresh that lets players witness how lights and shadows affect the Minecraft world. "Fly high with your happy ghast to watch the sunrise reflect on the rippling ocean, make art with shifting shadows, descend into dark depths, or simply sit back and enjoy the vivid beauty of each biome," says the studio. "With updated in-game visuals you’ll see how light and shadow transform the Overworld – water reflects, forests become shaded, fog drifts, and waterfalls glimmer in the light." The currently supported devices for Vibrant Visuals include Xbox Series X|S, Xbox One, PlayStation 4, PlayStation 5, PC, as well as Android (Android: Adreno 640, Mali-G68, Mali-G77, or Xclipse 530 or higher) and iOS (A12 or M1 or higher.)   Unfortunately, the Vibrant Visuals upgrade will only be available on the Bedrock Edition of Minecraft, at least for now. Mojang has said that it plans to bring the visual overhaul to the Java Edition of Minecraft at a later date, but no information or release window has been announced just yet.
    • Once people get use to the square-ish case, they'll probably switch the display to square as well.
    • Why would you think it's not enabled all the time? Because they said so?
  • Recent Achievements

    • One Month Later
      POR2GAL4EVER earned a badge
      One Month Later
    • One Year In
      Orpheus13 earned a badge
      One Year In
    • One Month Later
      Orpheus13 earned a badge
      One Month Later
    • Week One Done
      Orpheus13 earned a badge
      Week One Done
    • Week One Done
      serfegyed earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      560
    2. 2
      ATLien_0
      255
    3. 3
      +Edouard
      163
    4. 4
      +FloatingFatMan
      158
    5. 5
      Michael Scrip
      110
  • Tell a friend

    Love Neowin? Tell a friend!