LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

problem with GetRelativeMouseState

Hello all!

 

I'm having troubles with GetRelativeMouseState(). Somewhy left\right remains 0 and cause my program not to work.

Why is it happening?

If anyone can write how this command works, it can also help me.

 

int CVICALLBACK start (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    switch (event)
    {
        case EVENT_COMMIT:
            GetRelativeMouseState (panel, control, NULL, NULL, &left, &right, NULL);
            SetCtrlAttribute (panelHandle, PANEL_TIMER, ATTR_ENABLED, 1);
            controlnum=control;
            break;
    }
    return 0;
}

 

Thanks!

0 Kudos
Message 1 of 9
(3,593 Views)

Hi!

 

In such cases a good idea is to try the examples provided with CVI to check if and how these are working. In this case, you can have a look at userint\moustate.cws

In general, you may use the example finder in the menu Help / Find Examples. For this particular case, typing mouse in the search field will return the above result.

 

You may try it and compare the code with yours.

 

Good luck!

0 Kudos
Message 2 of 9
(3,584 Views)

Thank you for answering!

 

I tried it already - no success. I searched in "canvas.cws" and "mousestate.cws" and didnt find an answer..  😞

 

Thanks anyway!

0 Kudos
Message 3 of 9
(3,582 Views)

I never tried to use the function in a similar way as yours, but some general rule may apply. In a windows environment a button commit event is fired when your release the button, so I'd expect to receive '0' as 'left button pressed'. Similarly, it's not clear to me how you can fire a commit event with a mouse right click.

 

Could trapping EVENT_LEFT_CLICK and EVENT_RIGHT_CLICK events instead of commit event help you solving your problems?

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 9
(3,580 Views)

Unfortunately not.

 

I'm writting a program that simulates Minesweeper and GetRelativeMouseState is the only command in which I can trap clicking both left\right simultaneously.

 

If you have some other ideas, I'll be glad to hear!

 

Thank you!

0 Kudos
Message 5 of 9
(3,577 Views)

hm..., so why don't you skip the case event and check if left and right are true? Something like

 

int CVICALLBACK start (int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
    GetRelativeMouseState (panel, control, NULL, NULL, &left, &right, NULL);
    if ( left && right )

    {    

        SetCtrlAttribute (panelHandle, PANEL_TIMER, ATTR_ENABLED, 1);
        controlnum=control;
    }
    return 0;
}

0 Kudos
Message 6 of 9
(3,573 Views)

I also tried it.

left\right are static int in the main and according to them the program knows if the specific control (cell) should be revealed, been flaged or to expose every control around it. The only problem is that i just cant make this command work properly  😞

0 Kudos
Message 7 of 9
(3,571 Views)

Progress: after checking my program I can say with confidence that the function work!

 

But, in order it to work, the click on the button should be lonnnggggggggg......... why is that?

 

I searched over the net and didnt find answers..

 

Thank you!

 

0 Kudos
Message 8 of 9
(3,528 Views)

Hi ehud83,

 

I made up a little project to test a different approach (trapping EVENT_LEFT_CLICK / EVENT_RIGHT_CLICK): on my machine I have no need to press the buttons for a long time. Instead, I noticed that trapping the mouse clicks heavily depends on mouse settings in control panel; specifically, the double-click speed determines how two subsequent mouse clicks are interpreted: if the double click speed setting is low (as it was on my laptop) you cannot discriminate two fast clicks as left clicks (the system sends a click + a double click event); reducing that mouse setting permits you to discriminate individual clicks faster.

 

In the project I also tested how to use that system on controls different from command buttons (specifically some text messages) using a panel callback.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 9 of 9
(3,512 Views)