Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
how can i use mouse in visual studio c++ win 32 console application?
Posted
Comments
Ron Beyer 11-Dec-13 14:25pm    
By making an MFC application with a GUI. Why do you need the mouse in a console application? Almost by definition console applications only interact with the screen and keyboard, not since the days of DOS do people use a mouse in a console application...
Sergey Alexandrovich Kryukov 11-Dec-13 15:22pm    
Mouse is used in console for mark/copy/paste. It actually can be used in a console application (you can set and retrieve its position), but not effectively communicate with console. Just a wrong idea.
—SA
Ron Beyer 11-Dec-13 15:49pm    
Mark/Copy/Paste is a console window feature, not a console one :) I remember using mouse emulation in QBasic some time ago, it was clunky to say the least, for the trouble I'd just do MFC. Since the console became more like a command window than an actual console, I'm not sure where to even begin anymore capturing the mouse...
Sergey Alexandrovich Kryukov 11-Dec-13 16:07pm    
Yes, of course, this is what I tried to say: this is not what can be used by an application.

However, using a mouse in a console application is possible. Look at FAR Manager; I suspect it does something like that. You can set a local Windows Hook or find a consoles HWND through a current process and inject handling it it. This is not even too difficult. And console has API for absolute addressing (character, its position and background/foreground color).

I don't think messing with it has any practical sense, even if it looks funny... :-)

—SA
Sergey Alexandrovich Kryukov 11-Dec-13 16:12pm    
Yes, of course, this is what I'm trying to say, this is not you use in the console application. There are applications doing something like that, I suspect, FAR Manager does something like that, so it's possible... You can find out the console's window by processes and inject handling in it, or use local Windows Hook, and Console has API for absolute addressing (of characters and colors). I don't think messing up with such things makes any practical sense, even if it looks funny.
—SA

1 solution

You probably want to learn event handling

http://www.benryves.com/tutorials/winconsole/[^]
 
Share this answer
 

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