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

    • Meta (Facebook) tends to make horribly designed apps, which not sure if its deliberate or just plain poor design, maybe due to incompetence. For a huge internationally and well known company, this is baffling, they are getting bad PR but I guess they are tok big and super popular and seemingly can get away from any gov thus they are getting away with these blunders. Example their Facebook Stories, when mobile OS uses gestures for years to go back to previous menu, it just tends to swipe to previous or next stories instead of exiting the UI. I have to make sure I swipe from the very edge. This really bad UX but Facebook doesnt car about the bad UI practices. Is this deliberate, malice? Idk, maybe for force engagement, or just somebody never tested their products well about the issue, maybe they think user should know better and just arrogant to thing we are using it wrong?
    • This is insane for a tech focused site tbh. I cant understand anyone who would want this let alone anyone interested in tech or pc's. I understand the want to push stack deals but this is a terrible deal. I have bought a few deals through neowins stack before, they were good deals but this....
    • Its really apparent that these features and how they treat new Outlook now to be only web based to call these features "Offline mode". Like before we just gain features without them being called offline mode feature, but now here it is. It feels like if these codes bugged, we might left with app that is just useless liece kf codes when PC isnt connected to internet, especially laptops and tablets/convertibles.
    • Amazon Deal: Sony 65 inch 4K Bravia 5 2025 Mini LED TV with Dolby Vision/Atmos is $200 off by Sayan Sen Recently, we covered soundbar home theatre deals from Samsung and JBL for under $1000. Those are still selling for their best prices and you can check them out in their respective articles linked above. Obviously, for a home theatre, you also need a display, and depending on the kind of setup and room you have, you could choose a fairly premium projector like Valerion's StreamMaster Plus2 4K that is currently $300 off on Amazon US, or you could look for a TV. If you are looking for something for under $1500 then Sony has a great deal at the moment. The company's Bravia 5 mini LED 65-inch TV is on sale for $1298 thanks to a $200 discount (purchase link under the specs list below). Mini LEDs, unlike LEDs, promise much better precision in terms of backlighting which should lead to better contrasts with deeper blacks and brighter whites without being overblown either way. The full specs of the Bravia 5 are given below: Display Resolution: 3840 x 2160 (4K UHD) Panel Type: LCD with Mini LED backlight Backlight Dimming: XR Backlight Master Drive with local dimming for enhanced contrast Panel Refresh Rate: 120 Hz HDR Compatibility: Supports HDR10, HLG, and Dolby Vision Color & Image Processing: XR Triluminos Pro™ with Live Color™ technology, XR Clear Image, and XR Motion Clarity™ Connectivity & Ports: HDMI Inputs: 4 side-mounted (supports HDMI 2.1 features including 4K at 120Hz, eARC, VRR, ALLM, and SBTM) HDCP: Version 2.3 on all HDMI ports USB Ports: 2 side ports (supports FAT16, FAT32, exFAT, and NTFS formats) Other Ports: RS-232C Input: 1 (side) Digital Audio Output: 1 (side) RF (Terrestrial/Cable) Input: 1 (side) LAN Input: 1 (side) Wireless & Smart Features: Wi‑Fi: Dual‑band (2.4 GHz/5 GHz) with support for Wi‑Fi Certified 802.11 and Wi‑Fi 6 Bluetooth: Version 5.3 (compatible with A2DP, HID, HOGP, SPP, and AVRCP) Built‑in Chromecast: Yes Operating Platform: Google TV Smart Connectivity: Features BRAVIA Sync (with HDMI‑CEC), Apple HomeKit, and Apple AirPlay Get it at the link below: Sony BRAVIA 5 65 Inch TV, Mini LED, 4K120hz Television with Dolby Vision/Atmos, Exclusive Features for PlayStation®5, K-65XR50, 2025 Model: $1298.00 (Shipped and Sold by Amazon US) This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
  • Recent Achievements

    • Explorer
      Case_f went up a rank
      Explorer
    • Conversation Starter
      Jamie Smith earned a badge
      Conversation Starter
    • First Post
      NeoToad777 earned a badge
      First Post
    • Week One Done
      JoeV earned a badge
      Week One Done
    • One Month Later
      VAT Services in UAE earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      523
    2. 2
      ATLien_0
      231
    3. 3
      +FloatingFatMan
      150
    4. 4
      +Edouard
      142
    5. 5
      Michael Scrip
      109
  • Tell a friend

    Love Neowin? Tell a friend!