Trying to see if the left mouse button was clicked?

#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <iostream>
#include <stdlib.h>
#include <windows.h>
using namespace std;

#define MOUSEEVENTF_LEFTDOWN


int main(){
DWORD GuessLeft;
GuessLeft= MOUSEEVENTF_LEFTDOWN;
if(GuessLeft){
cout << "Worked" << endl;
}
}

}


I am sure it is simple, what is the problem?
Do not sk why there are all the random headers, its just a test project.
I am sure it is simple, what is the problem?

No idea.

Basically because I have no idea what you think you code should do.

Do not sk why there are all the random headers, its just a test project.

Posting a load of (irelevant?) random headers does not help. If they were meaningful they might help other peoplen diagnose your problem.

As it stands, we have no idea if you're trying to write a Win32 console app that handles mouse clicks, or a Glut GUI app, or even a severely failed attempt at a Win32 GUI app. And the Glut case is not a Windows-related issue, as Glut is a cross-platform toolkit.

Also, where did you find MOUSEEVENTF_LEFTDOWN ??

Andy
Last edited on
When typing in Codeblocks Mouse it pops up as a preprocessor so I did some research on it, and tried to implement it into the code, also its a cross between win32, because that is what this preprocessor is in(I think), and the headers will become useful later on.
Have you tried goolging for MOUSEEVENTF_LEFTDOWN ???

Andy
Yeah, I couldn't find much on it, although I have a pretty weird search engine....
Well it looks like you are writing a console app' and as such there won't be any windows events fireing off. So you won't be able to detect when the left or right mouse buttons are pressed.
Thanks ajh!
This is where...

#1 Things are complicated by Glut...

Like other cross-platform GUI toolkits (e.g. Qt, wxWidgets, and FLTK), Glut provides its own WinMain for Windows apps. which forwards to main(). This means that the same code can be compiled for Linux, etc as well as Windows. So a Glut app does use main.

Glut also provides its own event routing mechanism which hides away the Windows messages.

OpenGL/GLUT example
http://www-graphics.stanford.edu/courses/cs248-01/OpenGLHelpSession/code_example.html

#2 And console event handling...

Mouse handling is possible for Windows console apps, but using ReadConsoleInput and related functions, rather than the normal Windows messages.

Reading Input Buffer Events
http://msdn.microsoft.com/en-us/library/windows/desktop/ms685035%28v=vs.85%29.aspx

Of course, the more normal route on Windows is the standard messaging approach (WM_LBUTTONDOWN, WM_MOUSEMOVE, etc.) used by GUI apps. Either directly or via a nessage map (if you use MFC.)

Finally, MOUSEEVENTF_LEFTDOWN is one of the constants used with SendInput which is for generating input events (keyboard and mouse), generally for testing purposes.

SendInput function
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx

Andy
Last edited on
Topic archived. No new replies allowed.