취소
다음에 대한 결과 표시 
다음에 대한 검색 
다음을 의미합니까? 

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 포인트
1/9 메시지
4,219 조회수

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 포인트
2/9 메시지
4,210 조회수

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 포인트
3/9 메시지
4,208 조회수

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 포인트
4/9 메시지
4,206 조회수

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 포인트
5/9 메시지
4,203 조회수

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 포인트
6/9 메시지
4,199 조회수

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 포인트
7/9 메시지
4,197 조회수

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 포인트
8/9 메시지
4,154 조회수

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 포인트
9/9 메시지
4,138 조회수