mfc >> Mouse Position

by SGVjdG9yIE1hcnRpbmV6 » Mon, 24 Nov 2003 17:36:10 GMT


How can I get the mouse position, whenever I want. Can any one give some help

I'm new in MFC. Thanks in advantage.


mfc >> Mouse Position

by Paul Perkins » Mon, 24 Nov 2003 17:48:16 GMT





Hector,

CPoint point;

GetCursorPos (&point);


Should do the trick.

Have fun!

Paul.




mfc >> Mouse Position

by Ajay Kalra » Mon, 24 Nov 2003 18:08:28 GMT

GetCursorPos().

--
Ajay Kalra [MVP - VC++]
XXXX@XXXXX.COM




|
|
| How can I get the mouse position, whenever I want. Can any one give some help.
|
| I'm new in MFC. Thanks in advantage.



Mouse Position

by Joseph M. Newcomer » Tue, 25 Nov 2003 09:26:08 GMT

Note that the cursor position is in screen coordinates; if you need client coordinates you
will have to do ScreenToClient
joe

On Mon, 24 Nov 2003 01:36:10 -0800, Hector Martinez < XXXX@XXXXX.COM >



Joseph M. Newcomer [MVP]
email: XXXX@XXXXX.COM
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm


Similar Threads

1. TextBox: get text at/around mouse position

In a TextBox, I'm using a MouseMove  event to track the cursor position.

I want to get able to tell what text the current cursor position is at so I
can set the SelectionStart to that position.

private void textBox1_MouseMove(object sender, MouseEventArgs e)
{
        Point p = textBox1.PointToClient(new Point(e.X, e.Y));
        /* now what to do I do with Point to figure out the character
position in the text box??? */

        SelectionStart = ????
}

The only solution I can figure out so far is to call the Windows API
user.dll and send a click event.  This effectively sets the SelectionStart
position.  Is there a way to send a click all within .NET and not use the
API?

Better yet would just to be able to determine directly the current character
position in the (multi-line) TextBox.


2. Mouse Position While Dragging and Dropping - CSharp/C#

3. Capture mouse position during resizing header of ListView ?

Is it possible to obtain without WinAPi ?

Gawel


4. mouse position with respect to screen - CSharp/C#

5. inserting text at mouse position in text or rich edit box

Hi 
I have searched extensively for help on inserting text at the position of 
the mouse pointer in a text box as the final step of drag and drop process
What I have come with is listed below - the problem is that the SendMessage 
function doesn't seem to perform the expected operation of moving the caret 
to position in the textbox where the mouse is pointing to. (can be text or 
richtext box either is good - sample code is based of attemp with richtext)

I would be greatfull if someone could perhaps assist me by pointing out my 
error 
Thanks

my attempt:

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int 
lParam);

//DragOver event of the RichTextBox
private void txtMDXExpression_DragOver(object sender, 
System.Windows.Forms.DragEventArgs e)
{
    const int EM_SETSEL = 0x0400 + 177;
    txtMDXExpression.Focus();
    txtMDXExpression.SelectionLength = 0;

//make a point object from argument parameters
    Point mouseP = new Point(e.X,e.Y);
//get position of mouse within textbox
    Point scrPt = txtMDXExpression.PointToClient(mouseP);

    SendMessage(txtMDXExpression.Handle, EM_SETSEL,  scrPt.X, scrPt.X )
}

6. Setting Mouse Position - CSharp/C#

7. Mouse position without events

Hi,
I need to detect mouse position without events. In some places in code I need to get position but mouse didn't do anything(click,move...).

Thanks 

8. Mouse position - CSharp/C#