Jump to content


mouse clicking windows library


4 replies to this topic

#1 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2258 posts

Posted 19 September 2008 - 11:54 AM

just a quick question thanks ->

GetCursorPos(&pos);

that gets the cursor position, but using the windows library, how do you
detect for mouse clicks?

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4782 posts
  • LocationBellevue, WA

Posted 19 September 2008 - 04:59 PM

You receive a WM_LBUTTONDOWN message with your window.

You can also use SetCapture() to make Windows route all mouse clicks to your window whether they were actually on your window or not. But you still need to have a window.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2258 posts

Posted 19 September 2008 - 05:46 PM

thankyou

#4 z80

    Valued Member

  • Members
  • PipPipPip
  • 104 posts

Posted 19 September 2008 - 09:48 PM

I think SetCapture() works only when you are dragging outside the window.. If you release the mousebutton the trap is lost.

#5 marek-knows.com

    Valued Member

  • Members
  • PipPipPip
  • 189 posts
  • LocationOntario, Canada

Posted 20 September 2008 - 10:08 PM

You can do everything just by watching windows messages.

WM_LBUTTONDOWN //When left mouse button is pressed down
WM_LBUTTONUP //When left mouse button is released

WM_MOUSEMOVE //When the mouse is moved

POINT pt;
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);

this will give you mouse x,y coordinate


ClientToScreen(m_hWnd, &pt);

this will convert the coordinate to screen space
3D OpenGL, C++ Game Development Video Tutorials @
www.marek-knows.com





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users