Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,120 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,001 people online right now. Registration is fast and FREE... Join Now!




mouse co-ordinates capturing

 
Reply to this topicStart new topic

mouse co-ordinates capturing

didgy58
post 23 Oct, 2007 - 11:37 AM
Post #1


D.I.C Head

**
Joined: 23 Oct, 2007
Posts: 170



Thanked 1 times
My Contributions


hi guys new here and im a novie when it comes to C ++ done some visual basic before but its been so long. so anyway im trying to create a simple program that allows me to click onto the form and then it draws a coil design its simple really.

its a mfc, MDI if ive got that correct thats the way i setup the project when i created it.

the code is as follows

CODE


void Ccoils2View::OnLButtonDown(UINT nFlags,CPoint point)
{
CView::OnLButtonDown(nFlags, point);
CDC * pDC=GetDC();

Ccoils2DOC* pDoc= GetDocument ();
ASSERT_VALID(pDoc);
if (!pDoc)
return;

//The bit i get stuck around is here;

int angle,x,y,z;

x=20;
y=0;
z=0;

for(angle=0; angle<90; angle++)
{
z=z++;
pDC->MoveTo(x+100+angle,y+100);
y=20*sin(angle*6.28/30);
x=20*cos(angle*6.28/30);
pDC->LineTo(x+100+angle,y+z+100);
}
}


ok so im stuck being that i have to manually enter the 1st x and y co ordinate at the beginning where i would like to click somewhere on the screen and then grab that co-ordinate and place it into the formula and draw from that point.

i hope this helps and makes any sense to anybody out there and hopefully you could help

ive tried to do the following

CODE


int x=LOWORD(lParam);
int y=HIWORD(lParam);



and also
CODE

x=GET_X_LPARAM(lParam);
Y=GET_Y_LPARAM(lParam);


and it comes up with lParam undeclared identifier but how do i identify it as a interger at the beginning with x and y or somewhere else. it has been a long time since ive really done anything in programming and im very rusty and im very sorry if this sounds reaelly stupid question and easily answered but it would be a great help. thanks very much again and hope to get a answer

dan.

User is offlineProfile CardPM

Go to the top of the page

jpw1991
post 26 Oct, 2007 - 12:30 AM
Post #2


New D.I.C Head

*
Joined: 13 Aug, 2007
Posts: 33


My Contributions


I wrote an autoclicker a while ago that outputted the coords of the mouse where it clicked. I've rewritten the screen-coords part of it for you here.

What this program does is it reports the screen coordinates of the mouse every 2.5 seconds. You should be able to learn from this and modify it to your needs.

I hope this helps you, and I hope it is what you're after.

CODE
#include <iostream>
#include <windows.h>
using namespace std;

int main()
{
    POINT cursor;
    HDC dcScr = GetDC(NULL);
    while(!(GetAsyncKeyState(VK_ESCAPE)))
    {
                                         GetCursorPos(&cursor);
                                         dcScr = GetWindowDC(WindowFromPoint(cursor));
                                         cout << "(" << cursor.x << "," << cursor.y << ")" << endl;
                                         Sleep(2500);
    }
    return 0;
}
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/21/08 10:56AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month