Announcement

Collapse
No announcement yet.

Show mouse location in graphics window

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Show mouse location in graphics window

    This may be a stupid question, why won't this program show the mouse location? Is there a book on learning to program in PBCC?
    ' Sorry, could not get code in a window, Lynn
    Code:
    Code:
    #COMPILE EXE 'Sudoku_Graphic.bas 2/6/08
    #DIM ALL
    DECLARE SUB Make_Sudoku_Grid
    FUNCTION PBMAIN AS LONG
    LOCAL i AS STRING
    LOCAL x AS LONG
    Make_Sudoku_Grid
    x = 1
    DO
    MOUSE ON
    MOUSE 3, DOUBLE, DOWN
    GRAPHIC SET POS(x,1)
    INCR x
    i = WAITKEY$
    GRAPHIC PRINT MOUSEY;",";MOUSEX 'Print mouse location down left side of screen
    LOOP UNTIL i = $ESC
    GRAPHIC WINDOW END
    END FUNCTION
    SUB Make_Sudoku_Grid
    LOCAL hwin AS DWORD
    LOCAL x AS LONG
    LOCAL i AS STRING
    'GRAPHIC WINDOW "Sudoku Puzzle", Horiz_start , Vert_start, Width, Height
    GRAPHIC WINDOW "Sudoku Puzzle", 0 , 0, 1018, 706 TO hWin 'window location
    GRAPHIC ATTACH hwin, 0
    GRAPHIC WIDTH 3
    SLEEP 50
    GRAPHIC BOX (300, 150) - (700, 500)
    'GRAPHIC BOX (Upper Left horiz corner, Upper Left vert corner)
    '(Lower Right horiz corner, Lower Right vert corner)
    SLEEP 50
    GRAPHIC LINE (430,499)-(430,150) 'Vert Line 3
    GRAPHIC LINE (570,499)-(570,150) 'Vert Line 6
    GRAPHIC LINE (300,270)-(700,270) 'Horiz line 3
    GRAPHIC LINE (300,390)-(700,390) 'Horiz line 6
    GRAPHIC WIDTH 1
    GRAPHIC LINE (345,499)-(345,150) 'Vert Line 1
    GRAPHIC LINE (390,499)-(390,150) 'Vert Line 2
    GRAPHIC LINE (480,499)-(480,150) 'Vert Line 4
    GRAPHIC LINE (525,499)-(525,150) 'Vert Line 5
    GRAPHIC LINE (615,499)-(615,150) 'Vert Line 7
    GRAPHIC LINE (660,499)-(660,150) 'Vert Line 8
    GRAPHIC LINE (300,190)-(700,190) 'Horiz line 1
    GRAPHIC LINE (300,230)-(700,230) 'Horiz line 2
    GRAPHIC LINE (300,310)-(700,310) 'Horiz line 4
    GRAPHIC LINE (300,350)-(700,350) 'Horiz line 5
    GRAPHIC LINE (300,427)-(700,427) 'Horiz line 7
    GRAPHIC LINE (300,462)-(700,462) 'Horiz line 8
    'Top boxes
    'GRAPHIC BOX (Upper Left horiz corner, Upper Left vert corner)
    '(Lower Right horiz corner, Lower Right vert corner)
    GRAPHIC BOX (60, 60) - (100, 100),20
    GRAPHIC BOX (160, 60) - (200, 100),20
    GRAPHIC BOX (260, 60) - (300, 100),20
    GRAPHIC BOX (360, 60) - (400, 100),20
    GRAPHIC BOX (460, 60) - (500, 100),20
    GRAPHIC BOX (560, 60) - (600, 100),20
    GRAPHIC BOX (660, 60) - (700, 100),20
    GRAPHIC BOX (760, 60) - (800, 100),20
    GRAPHIC BOX (860, 60) - (900, 100),20
    'Bottom boxes
    'GRAPHIC BOX (Upper Left horiz corner, Upper Left vert corner)
    '(Lower Right horiz corner, Lower Right vert corner)
    GRAPHIC BOX (60, 600) - (100, 640),20
    GRAPHIC BOX (160, 600) - (200, 640),20
    GRAPHIC BOX (260, 600) - (300, 640),20
    GRAPHIC BOX (360, 600) - (400, 640),20
    GRAPHIC BOX (460, 600) - (500, 640),20
    GRAPHIC BOX (560, 600) - (600, 640),20
    GRAPHIC BOX (660, 600) - (700, 640),20
    GRAPHIC BOX (760, 600) - (800, 640),20
    GRAPHIC BOX (860, 600) - (900, 640),20
    GRAPHIC SET POS (240,20)
    GRAPHIC FONT "Times New Roman", 18, 7 'size = 18 points, bold + Italic + underline = (1+2+4)
    GRAPHIC PRINT "Click on a number then click on the Sudoku grid"
    GRAPHIC SET POS (220,650)
    GRAPHIC PRINT "Click on a number nd irint that numbers possibilities"
    GRAPHIC FONT "Times New Roman", 18, 1 'points=18,1 = bold
    SLEEP 50
    GRAPHIC SET POS (74,67) : GRAPHIC PRINT "1"
    GRAPHIC SET POS (174,67) : GRAPHIC PRINT "2"
    GRAPHIC SET POS (274,67) : GRAPHIC PRINT "3"
    GRAPHIC SET POS (374,67) : GRAPHIC PRINT "4"
    GRAPHIC SET POS (474,67) : GRAPHIC PRINT "5"
    GRAPHIC SET POS (574,67) : GRAPHIC PRINT "6"
    GRAPHIC SET POS (674,67) : GRAPHIC PRINT "7"
    GRAPHIC SET POS (774,67) : GRAPHIC PRINT "8"
    GRAPHIC SET POS (874,67) : GRAPHIC PRINT "9"
    SLEEP 50
    GRAPHIC SET POS (74,606) : GRAPHIC PRINT "1"
    GRAPHIC SET POS (174,606) : GRAPHIC PRINT "2"
    GRAPHIC SET POS (274,606) : GRAPHIC PRINT "3"
    GRAPHIC SET POS (374,606) : GRAPHIC PRINT "4"
    GRAPHIC SET POS (474,606) : GRAPHIC PRINT "5"
    GRAPHIC SET POS (574,606) : GRAPHIC PRINT "6"
    GRAPHIC SET POS (674,606) : GRAPHIC PRINT "7"
    GRAPHIC SET POS (774,606) : GRAPHIC PRINT "8"
    GRAPHIC SET POS (874,606) : GRAPHIC PRINT "9"
    GRAPHIC SET POS (1,1)
    END SUB
    Last edited by Lynn Wakefield; 6 Feb 2008, 11:44 AM. Reason: Tried to get code in a window, but looks like I failed, sorry!

  • #2
    Hi Lynn,

    why won't this program show the mouse location?
    Short answer: it does. However, the mouse position it shows you is the one you ask for, which is MOUSEX / MOUSEY, and from the help file for MOUSEX:

    Return the current column position (x coordinate) of the mouse cursor, as of the most recent mouse event retrieved by INKEY$ or WAITKEY$.
    Those events relate to the console window, not your GRAPHIC window. So, click anywhere in the console window, and you'll see the mouse position being reported in your graphic window.

    Not what you're after, I'm sure, but it is the answer to your question. On a rather more helpful note though, you might find this thread useful.

    Regards,

    Pete.

    Comment

    Working...
    X