I am writing a program that has two windows. One window draws the shapes you choose in window2 and saves them in a list. When clicking on the second window once the first shape is supposed to move to the spot clicked. If double clicking the second shape and so forth.

As of now everything is working besides for when double or triple clicking on the second window, I not only have the second or third shape moving to the spot clicked but the first as well.

Here is the code that executes when clicking on the second window(W2).

Thank you!

int ReportMousePositionW2(const Position &p)
{
    static int clicks=0;
    clicks++; 
    int counter=0;
    float x=p.GetXDistance(); 
    float y= p.GetYDistance();
    lst.IterBegin(); 
    while(lst.IterEnd()==false) 
    {
        lst.IterNext(); 
        counter++; 
    }
    while(counter<clicks) 
          clicks=clicks-counter;
    lst.IterBegin();
    for(int i=0;i<counter-clicks;i++)
        lst.IterNext();
    lst.getIter()->getInfo()->Erase();
    lst.getIter()->getInfo()->SetPosition(x,y); 
    lst.getIter()->getInfo()->Draw();

    return 1;
}

Recommended Answers

All 5 Replies

If you're using CLR and the .net librairies, you've come across one of the behavioural quirks of .net. When you handle the click and the double-click events for the same control, and the user double-clicks, the click and the double-click events are fired.

One option, to overcome this, is to roll back the single click action in the double-click event handler. In your case remove the first shape.

Is there another option? I cannot remove shapes according to the guidlines of the project.

You might be able able to do something with the mouse down event and build your own code to check for single click or double click. This article gives a sample on how to do that.

I appreciate the article but it doesn't seem to be something I can use with Ezwin. I am up for any other suggestions. I was thinking of maybe some type of timer that will wait and count the clicks until a certain period of time passes. Lets say it would count 30 seconds before reacting to the clicks but am not sure how to go about putting that into code.

Since the code in that article does what you want, and Ezwin is a third party library, you've basically got 2 choices, follow the comments in that sample and create your code from that, or see if you can find a forum specifically for Ezwin.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.