views:

47

answers:

1

Ok so I'm working with vectors today yaya!
well im also working with getcursorpos() and i get weird results.
here is the code:

VOID fRegularShot(HDC hdc, HWND hWnd)
{
    Graphics graphics(hdc);
    Image shot(L"RegularShots.png");
    long index=0;
    while(index<=(long)pRegularShots.size())
    {
        index+=2;
        int x=pRegularShots.at(index);
        int y1=index+1;
        int y=pRegularShots.at(y1);
        graphics.DrawImage(&shot, x, y);
    }
}
///////////////////////////////////////////////////
event
case WM_LBUTTONDOWN:
    iRegularShots=0;
    POINT pt;
    GetCursorPos(&pt);
    pRegularShots.insert(pRegularShots.begin()+1, pt.y);
    pRegularShots.insert(pRegularShots.begin()+1, pt.x);
    InvalidateRect(hWnd, rect, false);
    break;

Well basically function fregularshots() get called and use the vector elements which contains the positions of the cursor than draws the image on the cursor positions.
but it doesn't seem to draw it on the cursor positions.
any ideas?

A: 
Alex Farber
already tried both, they didn't work
Ramiz Toma
Didn't work - what do you mean? Did something changed? Give more information. For example, click in the left window corner, x and y int WM_LBUTTONDOWN should be some small values. What values do you have in fRegularShot? Where image is drawn? Also, to make the program logic clear, use vector<POINT> instead of vector<int>. You have some problems with vectot indexes.
Alex Farber
ok well it compiles, but nothing changes still gives wrong coordinates. that what it should do, cursor x = 150 and y = 20. than image will be drawen and its position is x = 150 and y = 20 but im getting wrong coordiantes
Ramiz Toma
@Ramiz Toma: Do you mean the coordinates are flipped (x=20, y=150) or completely wrong? If you haven't done it yet, I think you should take Alex advice on changing the vector from `vector<int>` to `vector<PointF>` (PointF is defined in GDI+) If you have an IDE that can debug, could you put a breakpoint in when you draw it and check the values in your vector?
Default
ok i couldn't go with your idea or his bout <po>........... but i went with your idea with using breakpoint... on the first left mouse button is down i get x= something and y=0 totally not true.....
Ramiz Toma
I just read your conversation (`"they didn't work"`) in these comments and wondered whether I accidentally opened the browser tab for our internal customer support system. :-)
Frerich Raabe
@Ramiz Toma: right so now debug your program and check (put a breakpoint) when you add the values to the vector. Do you add the corect values to the vector?
Default