Getting pixel color under mouse cursor 
Author Message
 Getting pixel color under mouse cursor

HI, all,

I am trying to write a small graphics program in SCREEN 12 which requires that an irregular-shaped area must be identified when the mouse cursor is over it and the left
button is clicked. I have a problem seeing the button click and picking up the pixel color. The only way I can reliably retieve the button click and the color is to move
the mouse slightly while holding down the left button. Of course, I need to get the proper response without moving the mouse after pressing the button.

This is the relevant code:

   DEFINT A-Z
   SCREEN 12

...some code

   WHILE NOT INSTAT                                                          
      Call MsStatus( Button, Row, Column )                                    
      IF( Button = 1 ) AND ( HitFlag = %TRUE ) THEN                          
         DRAW "BM"+STR$( Row )+","+STR$( Column )                            
         LOCATE 30, 45                                                                
         PRINT POINT( Column, Row );                                                  
         IF( POINT( Column, Row ) = %YELLOW ) OR (_                          
             POINT( Column, Row ) = %DARKGRAY ) THEN                          
...some code
         END IF                                                              
      END IF                                                                  
...some code
   WEND

...some code

Can anybody spot my problem or tell me a better way to do this?

Is the DRAW statement necessary? I cannot tell.

TIA for any help, Doug



Sun, 11 Mar 2001 03:00:00 GMT  
 Getting pixel color under mouse cursor

Quote:

>HI, all,

>I am trying to write a small graphics program in SCREEN 12 which requires that an irregular-shaped area must be identified when the mouse cursor is over it and the left
>button is clicked. I have a problem seeing the button click and picking up the pixel color. The only way I can reliably retieve the button click and the color is to move
>the mouse slightly while holding down the left button. Of course, I need to get the proper response without moving the mouse after pressing the button.

Hi Doug,

  I'm not sure if you mean that the button has been released over the area or
if it is down while over the area.

How/what does MsStatus return?
How does it report on button action?
Where is 'HitFlag' coming from?
The DRAW statement seems to be out of place.

C'ya,

  ____    _    ____      ____  _____
 |  _ \  / \  / ___) __ | ___)(_   _) Don Schullian

 |____//_/ \_\(____/\__/|_|     |_|     www.DASoftVSS.com
 ___________________________________     www.basicguru.com
     Vertical Software Solutions



Mon, 12 Mar 2001 03:00:00 GMT  
 Getting pixel color under mouse cursor

Quote:


> >HI, all,

> >I am trying to write a small graphics program in SCREEN 12 which requires that an irregular-shaped area must be identified when the mouse cursor is over it and the left
> >button is clicked. I have a problem seeing the button click and picking up the pixel color. The only way I can reliably retieve the button click and the color is to move
> >the mouse slightly while holding down the left button. Of course, I need to get the proper response without moving the mouse after pressing the button.

> Hi Doug,

>   I'm not sure if you mean that the button has been released over the area or
> if it is down while over the area.

The button is up before the area is reached, the button is pressed while on the area, and the button is then released.

Quote:
> How/what does MsStatus return?

MsStatus returns the condition of the mouse buttons (1 when the button is pressed) and X,Y for the cursor position.

Quote:
> How does it report on button action?

The button action is reported as 0 then 1 then 0 as the left button is clicked.

Quote:
> Where is 'HitFlag' coming from?

"HitFlag" is just a flag generated in prior code to prevent multiple returns of the mouse conditions, since only one report is wanted. It simply acts as an enabling toggle.

Quote:
> The DRAW statement seems to be out of place.

The DRAW statement is there to force an update of the LPR. I thought it might help, even though I had doubts.

As a simplification of what I am trying to do:
    Imagine a yellow disk with a dark gray spot on it. This disk flashes (I use TIMER() to get the flashing action) between yellow and black, and I want to click on it while
it is yellow and not while it is black..  Actually, there are several such disks flashing at random, and the object is to click the mouse button on only the one which happens
to be yellow at the moment.

I guess I may have asked the wrong question, now that I think more about it. What I really want is a way to determine the color of the pixel under the mouse cursor when I
click the left button.

I have no trouble getting the proper action with a rectangular area when I only compare the cursor position with the X1,Y1,X2,Y2 coordinates of the rectangle, but I want to
be able to handle irregular shapes without a lot of calculation. Even a disk requires more time to calculate than I want to spend. The color of the pixel looked to me to be
the fastest way to do this. Do you have a better suggestion?

Thanks for your interest and help, Doug.



Mon, 12 Mar 2001 03:00:00 GMT  
 Getting pixel color under mouse cursor


Quote:



>> >HI, all,

>> >I am trying to write a small graphics program in SCREEN 12 which requires

that an irregular-shaped area must be identified when the mouse cursor is over
it and the left
Quote:
>> >button is clicked. I have a problem seeing the button click and picking up

the pixel color. The only way I can reliably retieve the button click and the
color is to move
Quote:
>> >the mouse slightly while holding down the left button. Of course, I need

to get the proper response without moving the mouse after pressing the button.
Quote:

>> Hi Doug,

>>   I'm not sure if you mean that the button has been released over the area
or
>> if it is down while over the area.

>The button is up before the area is reached, the button is pressed while on

the area, and the button is then released.
Quote:

>> How/what does MsStatus return?

>MsStatus returns the condition of the mouse buttons (1 when the button is

pressed) and X,Y for the cursor position.
Quote:

>> How does it report on button action?

>The button action is reported as 0 then 1 then 0 as the left button is
clicked.

>> Where is 'HitFlag' coming from?

>"HitFlag" is just a flag generated in prior code to prevent multiple returns

of the mouse conditions, since only one report is wanted. It simply acts as an
enabling toggle.
Quote:

>> The DRAW statement seems to be out of place.

>The DRAW statement is there to force an update of the LPR. I thought it might

help, even though I had doubts.
Quote:

>As a simplification of what I am trying to do:
>    Imagine a yellow disk with a dark gray spot on it. This disk flashes (I

use TIMER() to get the flashing action) between yellow and black, and I want
to click on it while
Quote:
>it is yellow and not while it is black..  Actually, there are several such

disks flashing at random, and the object is to click the mouse button on only
the one which happens
Quote:
>to be yellow at the moment.

>I guess I may have asked the wrong question, now that I think more about it.

What I really want is a way to determine the color of the pixel under the
mouse cursor when I
Quote:
>click the left button.

>I have no trouble getting the proper action with a rectangular area when I

only compare the cursor position with the X1,Y1,X2,Y2 coordinates of the
rectangle, but I want to
Quote:
>be able to handle irregular shapes without a lot of calculation. Even a disk

requires more time to calculate than I want to spend. The color of the pixel
looked to me to be

Quote:
>the fastest way to do this. Do you have a better suggestion?

>Thanks for your interest and help, Doug.

what your probably looking for is:

  p=POINT(column,row)

where p equals the color of the pixil.

hope this helps.
Fred



Mon, 12 Mar 2001 03:00:00 GMT  
 Getting pixel color under mouse cursor

Quote:

> what your probably looking for is:

>   p=POINT(column,row)

> where p equals the color of the pixil.

> hope this helps.
> Fred

Thanks, Fred, for the suggestion, but I had included that (virtually) in the
original code. However, you make me think that it might be useful to include this
explicitly, anyway.

I appreciate your comment, Doug.



Tue, 13 Mar 2001 03:00:00 GMT  
 Getting pixel color under mouse cursor
This is just to report that I have found the answer--Win95!!!!! :-(

I had neglected to report that I had opened a dos window in win95 to do
this programming, and that was the cause of my problem. Everything
worked fine with dos 6.2.

MS screws us again!!!

Doug.

Quote:

> HI, all,

> I am trying to write a small graphics program in SCREEN 12 which requires that an irregular-shaped area must be identified when the mouse cursor is over it and the left
> button is clicked. I have a problem seeing the button click and picking up the pixel color. The only way I can reliably retieve the button click and the color is to move
> the mouse slightly while holding down the left button. Of course, I need to get the proper response without moving the mouse after pressing the button.

> This is the relevant code:

>    DEFINT A-Z
>    SCREEN 12

> ...some code

>    WHILE NOT INSTAT
>       Call MsStatus( Button, Row, Column )
>       IF( Button = 1 ) AND ( HitFlag = %TRUE ) THEN
>          DRAW "BM"+STR$( Row )+","+STR$( Column )
>          LOCATE 30, 45
>          PRINT POINT( Column, Row );
>          IF( POINT( Column, Row ) = %YELLOW ) OR (_
>              POINT( Column, Row ) = %DARKGRAY ) THEN
> ...some code
>          END IF
>       END IF
> ...some code
>    WEND

> ...some code

> Can anybody spot my problem or tell me a better way to do this?

> Is the DRAW statement necessary? I cannot tell.

> TIA for any help, Doug



Fri, 04 May 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Color mouse cursor in 256 color mode

2. Getting pixel values under cursor

3. mouse cursor color

4. Move mouse-cursor and send mouse-click

5. Setting color for mouse color (text)

6. Mouse click/Pixel Grab

7. problem with mouse and pixels

8. please help: problem with mouse and pixels

9. Find Out the color of a pixel

10. find out the color of a pixel

11. The color of the pixel I click? (retry)

12. The color of the pixel I click?

 

 
Powered by phpBB® Forum Software