i'm a begginer in C++ so plz forgive my lack of knowledge. I've been trying for 3days now to understand how to manage mouse events in C++ but in vain. i've tried searching the web but almost everything was out of date with headers no longer in use and mainly dealing with the possition of the mouse rather than the clicks. i even tried the msdn tutorials with no luck there either...i want to make a program that counts the 3 mouse buttons clicks but i don't even know how to count the left button clicks so... can someone provide me with the needed knowledge. eventually the final program would be a form that counts clicks and return some results based on them. for any further info plz let me know. thanks in advance for your time!!!
Are you programming for Windows? In the WIN32 API there are three mouse events that indicate when a mouse button has been pressed - WM_LBUTTONDOWN, WM_MBUTTONDOWN and WM_RBUTTONDOWN. These are received through the main windowproc function.
Yes, i'm aware of these commands i've seen them in msdn, but i dont know how to use them right, what headers to include etc. can you please be a little bit more enlightening...
Yes, i'm aware of these commands i've seen them in msdn, but i dont know how to use them right, what headers to include etc. can you please be a little bit more enlightening...
You're asking how to write Windows programs in a forum. The reply is usually found in books containing 1,000 pages or more. I'd suggest you start with one of them,
oh, come on don't be so mean... this should take less than 3 min to someone who is familiar with this kind of things. I just want the right direction and help since i'm new in this and i don't understand msdn tutorials on mouse events. if you think that you can't help me it's ok.thanks for you time mate!!! if some one has a similar program with comments that would help me just enought!
oh, come on don't be so mean... this should take less than 3 min to someone who is familiar with this kind of things. I just want the right direction and help since i'm new in this and i don't understand msdn tutorials on mouse events. if you think that you can't help me it's ok.thanks for you time mate!!! if some one has a similar program with comments that would help me just enought!
I am familiar with "this kind of things", and I'm serious. The reason you don't understand the tutorials is because you don't understand Windows programming in general and it takes more than three minutes to explain and learn Windows programming. I'm not being mean, I'm being honest.
oh, come on don't be so mean... this should take less than 3 min to someone who is familiar with this kind of things.
Now try to think about the situation from my standpoint. Yes, I'm familiar with this kind of things. But I know nothing about you. I can compose a demo at least three different ways (and BTW none of those would take less than 30 minutes, trust me as I know the subject and I'm not a magician). As I said, I know nothing about how much you're prepared to perceive any, so you definitely make me guess, which I hate to do without serious reasons for that. Finally, I'm facing with the choice between posting something that is going to be most probably useless to the ultimate purpose, or just suggest you to learn basics of asking questions unambiguous way (what knowledge comes along with gaining experience, learning subject, technical vocabulary, etc.) Guess what my choice would be.
Now try to think about the situation from my standpoint. Yes, I'm familiar with this kind of things. But I know nothing about you. I can compose a demo at least three different ways (and BTW none of those would take less than 30 minutes, trust me as I know the subject and I'm not a magician). As I said, I know nothing about how much you're prepared to perceive any, so you definitely make me guess, which I hate to do without serious reasons for that. Finally, I'm facing with the choice between posting something that is going to be most probably useless to the ultimate purpose, or just suggest you to learn basics of asking questions unambiguous way (what knowledge comes along with gaining experience, learning subject, technical vocabulary, etc.) Guess what my choice would be.
ok, i understand that what i said about the 3 mins was excessive. i take it back, even thought i didn't ask anyone to write the code for me (that would be at least crazy) but to point me to the right directions. if you do that and realize that i'm not trying to understand and just waiting for the answer to come with no efford you can stop helping. but i believe that some code (even not the exact solution) is better than no code.
ok, i understand that what i said about the 3 mins was excessive. i take it back, even thought i didn't ask anyone to write the code for me (that would be at least crazy) but to point me to the right directions. if you do that and realize that i'm not trying to understand and just waiting for the answer to come with no efford you can stop helping. but i believe that some code (even not the exact solution) is better than no code.
There are two hurdles, not just one.
First, you must be competent in C or C++ programming, regardless of whether you want to process keystrokes. In other words, if you're coming back to CodeGuru asking basic C/C++ questions, then you're really not competent enough to tackle Windows programming. Sorry to be blunt about it, but that's the way it is. Reading and understanding the Windows API assumes you know how to use the C++ language already. In this forum, we come across too many people who do not know C++ properly, and screw up the most basic Windows program due to lack of knowledge of C++ itself.
Second, even if you are competent in C/C++ programming, heck, you could be a professional programmer in these languages for decades, that does not make you a Windows programmer. This is the point that is being made by the others here. Learning Windows programming, even for a professional, non-Windows programmer, takes time to learn. That's why the Windows programming books are hundreds, if not thousands of pages, and are not 3 or 4 page pamphlets or cheat sheets you would find for, say, HTML commands.
If Bjarne Stroustrup (the inventor of C++) never coded a Windows application, even he would need to read books on how to get started in writing one.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; February 7th, 2013 at 11:24 AM.
Create Windows Application using Visual Studio Application Wizard. Find WindowProc or WndProc function in the code generated by the Wizard. This is the function that handles Windows messages. It contains several "case WM_..." lines. Add your own lines for WM_LBUTTONDOWN, WM_MBUTTONDOWN and WM_RBUTTONDOWN messages and increment click counters there. If something goes wrong, ask another, more specific question, post the code you have and describe what is the problem exactly.
GCDEF is not being mean. The most simple Win32 program to just display a window and nothing else takes about 40 lines of code by the time you have registered a class, created the window, have the mesage pump and the callback function for the windows messages. How to do this must be learnt - not from a forum like this. If you have problems with some code that you post here we will most certainly try to help - but we can't write the programs for you from scratch.
Within the windows callback function you need something like this
Unless you're a real masochist, I wouldn't recommend learning old-school Windows style programming. MFC at least hides some of the really ugly stuff from you. .Net hides even more. I've never written an app using nothing but the API, and I don't think I've missed much.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.