FileFront Forums

FileFront Forums (http://forums.filefront.com/)
-   Tech Discussion (http://forums.filefront.com/tech-discussion-398/)
-   -   Mouse Cursor (http://forums.filefront.com/tech-discussion/30758-mouse-cursor.html)

Mark Carlson June 25th, 1999 04:02 PM

Mouse Cursor
 
I'm using Win32, and I have a cursor I want to use in my program. How do I get it so show up so I can see it and capture clicks from it?

Mark

Falcon[imported] June 26th, 1999 10:53 AM

: I'm using Win32, and I have a cursor I want to use in my program. How do I get it so show up so I can see it and capture clicks from it?

: Mark

A cursor is drawn using GDI calls. As the Voodoo 1 and 2 are 3D only, they do not support GDI, so you'll have to draw your own cursor (just use a textured rectangle)
The current position of the mouse can be found by intercepting the WM_MOUSE_MOVE event in the Windows Callback routine (often called WndProc)
The X coordinate is LOWORD(LParam), Y = HIWORD(LParam), where LParam is the last parameter of the callback routine.

The event WM_LBUTTONDOWN and WM_RBUTTONDOWN can be used to intercept clicks.

Tanok June 26th, 1999 02:53 PM

If you’re interested in creating a window’s program. These functions may help.

LoadImage function loads an icon, cursor, or bitmap.
Or
LoadCursorFromFile function creates a cursor based on data contained in a file. The file is specified by its name or by a system cursor identifier. The function returns a handle to the newly created cursor. Files containing cursor data may be in either cursor (.CUR) or animated cursor (.ANI) format.

SetCursor function establishes the cursor shape (after it has been loaded).

ClipCursor function confines the cursor to a rectangular area on the screen (i.e. inside your window or within the screen).

ShowCursor function displays or hides the cursor.

GetCursorPos function retrieves the cursor’s position, in screen coordinates.

That should enable you to load the cursor, view it and get its location. As for getting mouse clicks; in the WndProc function include the case statements:

case WM_LBUTTONDOWN:
// your code for when the left mouse button was pressed

case WM_RBUTTONDOWN:
// your code for when the right mouse button was pressed

And that should do it. On the other hand, if you’re making a game, I’d recommend using DirectInput (it’s easiest DirectX component to use). I’ve built a <a href=” http://members.home.net/tyler.brandon/tinput.html”>wrapper</a> for DirectInput that makes it even easier to use. The wrapper still needs to be tested, but you’re welcome to give it a try.

You can convert your cursor image to a texture map using Texus (3Dfx’s utility to convert ‘tga’ images to ‘3df’ texture maps). Using the DirectInput wrapper or DirectInput itself to get mouse input, you can then draw your cursor on the screen, like Falcon said, by rendering a texture mapped rectangle.

Hope that helps.

Tanok

Mark Carlson June 26th, 1999 11:04 PM

Thanks for the input. I spent a lot of today learning DirectInput, so it looks like I will be using it to get the location of the mouse cursor, though I hate to have to actively poll the DirectInputDevice. I may go ahead and use the normal windows messages, since I have that pumping anyway.

Thanks for the input,
Mark

PS tanok-that link to your wrapper does not work. I would like to take a look at it though.

Tanok June 27th, 1999 08:19 AM


Sorry, about that broken link. Here it is ...

<a href="http://members.home.net/tyler.brandon/tinput.html">wrapper</a>
Or
http://members.home.net/tyler.brandon/tinput.html

Tanok


All times are GMT -7.

Powered by vBulletin®
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.