SetDoubleClickTime(!-KABOOM-!)

This is a discussion on SetDoubleClickTime(!-KABOOM-!) within the Windows Programming forums, part of the Platform Specific Boards category; Just discovered a bug in the SetDoubleClickTime() function. If you pass it the value of 1, a divide by zero ...

  1. #1
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708

    SetDoubleClickTime(!-KABOOM-!)

    Just discovered a bug in the SetDoubleClickTime() function. If you pass it the value of 1, a divide by zero exception occurs. Though the error may not cause the program to crash, later you will notice that any attempt to click on a folder icon in windows explorer will cause an illegal operation, and you have to reboot.

    Compile and run this to see for yourself:


    Code:
    #include <windows.h>
    
    int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    {
     SetDoubleClickTime(1);
     return 0;
    }
    Then just click on - say, the MyComputer icon...KABOOM!
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Not surprising seeing the time is in milliseconds and the default is 500.

    The OS probably can't distinguish 1 millisec in it timer, 5 millisec being ambitious.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Nope. It only happens when the value is one. In fact, this was how I verified the bug:


    This code runs fine:

    for(int i = 0; i < 10000; i++)
    if(i != 1)
    SetDoubleClickTime(i);


    This dies:

    for(int i = 0; i < 10000; i++)
    //if(i != 1)
    SetDoubleClickTime(i);

    My guess it that internally to the function, a simple mathematical oversight leads to divide by zero when the value is 1. Has to be.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    OK.....

    Try adding a call to Get the set value. See if it accepts the low values ie 2.

    This just adds to the list of errors.
    TAB controls adding the wrong styles, database functions with misleading help, that if followed will cause your app to fail ect.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    BMJ
    BMJ is offline
    Banal internet user BMJ's Avatar
    Join Date
    Aug 2002
    Location
    Chicagoland
    Posts
    1,380
    It didn't crash at all for me. No strange errors, no strange behavior, other than the double-click time is set waaaay too low for me to make it respond

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21