Click here to Skip to main content
15,906,766 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Currently I learning how to build a native windows app using Win32 API along with Direct2D API.

I was successfully built my component-based UI in my app. However, the big problem is I don't know how to check whether a button is clicked and not the other button (UI hit-testing).

In short, how do I implement UI hit testing for my app?

Any help such as reference to the specification/manual, blogs, tutorials, etc will be appreciated!

Regards, thebluetropics.

What I have tried:

I've never tried something to implement the UI hit-testing, as I don't know how to do that. But I tried my best to search in the internet for help, yet encounter big problem because the google only sends me IOS "Hit-testing", that's not what I mean.

Also currently trying to solve this on my own (implement and think on my own).
Posted
Comments
Richard MacCutchan 29-Aug-22 3:34am    
When a button is clicked in a Windows application you should get a WM_COMMAND message with the details of the button that posted the hit.
thebluetropics 1-Sep-22 0:28am    
I am using Direct2D, so all components are basically "bitmap", that's why I implement my own UI Component.
Richard MacCutchan 1-Sep-22 3:15am    
Try capturing WM_LBUTTONDOWN message (Winuser.h) - Win32 apps | Microsoft Docs[^] (and similar) messages and see what information it provides.
TheNewbieProgrammer 14-Jul-23 13:38pm    
Check the mouse position in WM_LBUTTONDOWN to see if it is within your bitmap bounds. The first solution I provided works, but for my self I'd create a custom control for each component to easily handle any type of event, which is again how I implement my UI components, So if you don't like mine, you can use the first solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900