Announcement

Collapse
No announcement yet.

Help Mouse

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

  • #21
    Dave

    You are a scholar and a gentleman!

    If you knew how many hours I had spent on this, you would understand the depths of my gratitude.

    I am very naive and it took me ages to realize what you meant, but I got there!

    There are still a few mysteries - I do not seem to be able to get a depressed key into con.inkey$ but at least I am making progress.

    Is this an issue for every PBCC user who goes to Windows10? Some of my investigation seems to imply this - and some people are annoyed about the Microsoft default decisions. Maybe we need to make it clear in the PB docs somewhere.

    Thanks again Dave

    Kerry
    [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
    Kerry Farmer

    Comment


    • #22
      Originally posted by Rodney Hicks View Post
      Why do you say that this is not to the specifications? Good catch Borje, I missed that CON.MOUSE setting.
      I now withdraw that allegation - oops!

      For my own ego, I need to say I am totally familiar with the CON.MOUSE structure. Much of my testing was done with the full gamut of operations ie CON.MOUSE (15,31)

      [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
      Kerry Farmer

      Comment


      • #23
        With Dave's solution, I am now getting the row and col numbers but nothing else

        Here is my 'brilliant' self documenting dynamic demonstration

        The results I get are in the code

        Code:
        #COMPILE EXE
        #DIM ALL
        GLOBAL key_char AS STRING
        GLOBAL mouse_stat_value AS LONG
        GLOBAL instat_value AS LONG
        GLOBAL mouse_x AS LONG
        GLOBAL mouse_y AS LONG
        GLOBAL len_inkey AS LONG
        GLOBAL inkey_char AS LONG
        FUNCTION PBMAIN () AS LONG
        CON.MOUSE (4,3)                                                  'Restricted to button push for control purposes, there are 2 buttons on my mouse
        CON.MOUSE.ON
        DO
        CLS
        CON.PRINT "Press any key or mouse button (twice)"
        CON.WAITKEY$                                                     'This CON.WAITKEY$ to allow all data and status to be received and set up
                                                                                        'Note: all parameters are found and stored, so we do not have a self clearing problem
        mouse_x             = 0          :mouse_x                 = CON.MOUSE.ROW
        mouse_y             = 0          :mouse_y                 = CON.MOUSE.COL
        mouse_stat_value    = 0    :mouse_stat_value   = CON.MOUSE.STAT
        instat_value        = 0          :instat_value             = CON.INSTAT
        key_char            = ""          :key_char                  = CON.INKEY$      'Done last so it does not remove the input buffer character and affect the other parameters
        CON.PRINT "Mouse x:       ",mouse_x                                'Works well, displays the correct row if the last input was a mouse click or zero for a keyboard entry
        CON.PRINT "Mouse y:       ",mouse_y                                'Works well, displays the correct column if the last input was a mouse click or zero for a keyboard entry
        CON.PRINT "CON.MOUSE.STAT ";mouse_stat_value       'Does not work, = 0 in both keyboard character and mouse button depresses
        CON.PRINT "CON.INSTAT     ";instat_value                        'Does not work, = 0 in both keyboard character and mouse button depresses
        CALL inkeysub
        CON.WAITKEY$                                                                  'This CON.WAITKEY$ to pause the program so you can see the results
        LOOP                                                                                   'Until program is externally deleted
        END FUNCTION
        SUB inkeysub
        len_inkey = LEN(key_char)
        CON.PRINT "Length Inkey   ";len_inkey                                'Does not work, = 0 in both keyboard character and mouse button depresses
        CON.PRINT "CON.INKEY$     ";"a"+key_char+"b"                 'Does not work, = ab in both keyboard character and mouse button depresses
        IF  len_inkey <> 0 THEN
            FOR inkey_char = 1 TO len_inkey
                CON.PRINT inkey_char;
                CON.PRINT ASC(key_char,1)
            NEXT
        ELSE
            CON.PRINT
            CON.PRINT
            CON.PRINT
            CON.PRINT
        END IF
        END SUB
        Any thoughts please?
        [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
        Kerry Farmer

        Comment


        • #24
          Are we saying that if we cannot solve this that Windows 10 (and later Windows versions) are incompatible with screen operations with PBCC? The concept of 'Console Windows' has had its day?
          [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
          Kerry Farmer

          Comment


          • #25
            Kerry,

            The issue with Windows 10 (default QuickEdit ON) can also exist on a Win7 PC if the user has set that as a default option via the Console's Default properties menu.

            Here is a modification of your test code that resets QuickEdit for your app if set in Win10 or Win7.
            Note comments re: CON.INSTAT and CON.MOUSE.STAT.
            Code:
            #COMPILE EXE                        ' PBCC60
            #DIM ALL
            #BREAK ON
            #Include "win32api.inc"
            
             GLOBAL key_char AS STRING
             GLOBAL mouse_stat_value AS LONG
             GLOBAL instat_value AS LONG
             GLOBAL mouse_x AS LONG
             GLOBAL mouse_y AS LONG
             GLOBAL len_inkey AS LONG
             GLOBAL inkey_char AS LONG
            '------------------/
            
            SUB DisableQuickEditMode()
             LOCAL hStdIn, dwMode AS Dword'
               hStdIn = GetStdHandle(%STD_INPUT_HANDLE)           ' Delared in win32api.inc
               dwMode = dwMode OR %ENABLE_EXTENDED_FLAGS          ' %ENABLE_EXTENDED_FLAGS  = &H0080
               SetConsoleMode ByVal hStdIn, ByVal dwMode          '
            END SUB
            '------------------/DisableQuickEditMode
            
            FUNCTION PBMAIN () AS LONG
              DisableQuickEditMode()                              ' turn off QuickEdit mode for this app
            
              CON.MOUSE (4,3)                                     ' Restricted to button push for control purposes, there are 2 buttons on my mouse
              CON.MOUSE.ON
              DO
                CLS
                CON.PRINT "Press any key or mouse button (twice)"
             '    CON.WAITKEY$                                                     ' CON.WAITKEY$ retrieves most recent event - Mouse or Key - clears buffers
                                                                                   ' See help notes for CON.MOUSE.STAT **
                Do
                  Sleep 100
                  If Con.Mouse.Stat Then WinBeep 400,200  : Exit Loop              ' mouse event monitor note mouse events also set Instat
                  If Con.Instat <> 0 Then WinBeep 800,200 : Exit Loop              ' either mouse or keyboard event monitor
                Loop
            
                mouse_x             = 0     :mouse_x            = CON.MOUSE.ROW
                mouse_y             = 0     :mouse_y            = CON.MOUSE.COL
                mouse_stat_value    = 0     :mouse_stat_value   = CON.MOUSE.STAT ' ** Determines whether a mouse event is ready to be retrieved from the console input buffer.
            
                instat_value        = 0     :instat_value       = CON.INSTAT     ' *
            
                key_char            = ""    :key_char           = CON.INKEY$        ' Done last so it does not remove the input buffer character and affect the other parameters
                CON.PRINT "Mouse x:       ",mouse_x                                 ' Works well, displays the correct row if the last input was a mouse click or zero for a keyboard entry
                CON.PRINT "Mouse y:       ",mouse_y                                 ' Works well, displays the correct column if the last input was a mouse click or zero for a keyboard entry
                CON.PRINT "CON.MOUSE.STAT ";mouse_stat_value                        ' x Does not work, = 0 in both keyboard character and mouse button depresses
                CON.PRINT "CON.INSTAT     ";instat_value                            ' x Does not work, = 0 in both keyboard character and mouse button depresses
                CALL inkeysub
                CON.WAITKEY$                                                        ' This CON.WAITKEY$ to pause the program so you can see the results
              LOOP        ' Until program is externally deleted (or [X])
            END FUNCTION
            '------------------/PBMain
            
            SUB inkeysub
              len_inkey = LEN(key_char)
              CON.PRINT "Length Inkey   ";len_inkey                                ' x Does not work, = 0 in both keyboard character and mouse button depresses
              CON.PRINT "CON.INKEY$     ";"a "+key_char+" b"                 ' x Does not work, = ab in both keyboard character and mouse button depresses
              IF  len_inkey <> 0 THEN
                FOR inkey_char = 1 TO len_inkey
                    CON.PRINT inkey_char;
                    CON.PRINT ASC(key_char,inkey_char)
                NEXT
              ELSE
                CON.PRINT
                CON.PRINT
                CON.PRINT
                CON.PRINT
              END IF
            END SUB
            '------------------/
            Eric might have a comment or two regarding if 'Console Windows' have had their day
            Rgds, Dave

            Comment


            • #26
              Dave, on my Win 7 machine your code works for me. CON.MOUSE.STAT returns either 0 or -1 when appropriate as does CON.STAT. As well, the sub inkeysub works as it should. This is true as well with the disablequickeditmode commented out but that may be because the default properties are set accordingly.
              The concept of 'Console Windows' may not quite have had its day, but its days are certainly numbered by Windows 10.
              Rod
              "To every unsung hero in the universe
              To those who roam the skies and those who roam the earth
              To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

              Comment


              • #27
                Hi Rod,

                Yes, it's a bit tricky to test - mostly because Windows will remember the user's choices for each application..

                To test that the Sub is effective, comment out the first line in PBMain.
                Compile and run. In the app's System Menu (right click the Caption Bar), Select Properties/Options/Edit Options and enable Quick Edit, OK.

                Shut down the app and restart it - mouse clicks are gobbled up by the "Edit" behaviours.
                Shut down, uncomment the first line in PBMain, re-compile and run again. Mouse clicks are accessible to the app once more

                The QuickEdit Mode is set in two console menu places - one is in the per application 'Properties', the other is in the 'Defaults' options.

                Changes made in the First are stored in the registry and applied next time the app is started.
                Changes in the second are applied to applications the first time they are run by the user..


                Rgds, Dave

                Comment


                • #28
                  Thanks Dave! Works exactly like you said it would!
                  Not that I use PBCC much, it's nice to know, though.
                  Kerry might have to start using a GRAPHIC WINDOW for his shenanigans and I suggest starting with Borje's Graphic Buttons code:
                  https://forum.powerbasic.com/forum/u...window-buttons
                  Rod
                  "To every unsung hero in the universe
                  To those who roam the skies and those who roam the earth
                  To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                  Comment


                  • #29
                    Thanks Dave :I deliver small programs that run automatically - and need no set up. I was a bit worried that I could not do this anymore.

                    Thanks Rod. Does the GRAPHIC WINDOW solution solve all my problems? Is it a future proofed solution?

                    I have spent many many hours on this and it has raised a few questions for me:

                    Should I have realized that Console Windows was an obsolescent technique?

                    I am particularly concerned that some of my old programs will not work when my clients upgrade

                    Should PB being telling us this? What is their professional responsibility? Should they have told us that some 'ordinary' instructions did not work the same way in later versions of Windows?

                    Should PB at least tone down their claim that "Ever wished for a BASIC Windows Compiler? One with the straightforward DOS text mode interface but megabytes and megabytes of memory? Ever wished for a Windows compiler that's truly easy to use? Well, now it's here. Today. The PowerBASIC Console Compiler for Windows. With PB/CC, it's a whole new Windows! Text mode every version of Windows from Win95 to Vista and Win10."?

                    PB has not been upgraded for 5 years now. We have all become obsessed with 64 bit. But are we also facing other obsolescence?

                    Are there very few of us PBCC'ers left?

                    I was hoping that PB would last out my life - but for the first time, I am wondering if this was a forlorn hope.

                    I have a programming rule that when I get a bug, it is me, not the compilers or the OS. I know that if you are getting tricky this rule does not apply. But I was not getting that tricky. And this has cost me big time.

                    Kerry
                    [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
                    Kerry Farmer

                    Comment


                    • #30
                      Does the GRAPHIC WINDOW solution solve all my problems? Is it a future proofed solution?
                      Sadly, no, because the solution to a problem is another problem. It may be a future proofed solution if you look at the problem as an opportunity!
                      Rod
                      "To every unsung hero in the universe
                      To those who roam the skies and those who roam the earth
                      To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                      Comment


                      • #31
                        https://blogs.windows.com/buildingap...nical-preview/

                        Console changed, not dieing???????????
                        Dale

                        Comment


                        • #32
                          Should PB at least tone down their claim that "Ever wished for a BASIC Windows Compiler? One with the straightforward DOS text mode interface but megabytes and megabytes of memory? Ever wished for a Windows compiler that's truly easy to use? Well, now it's here. Today. The PowerBASIC Console Compiler for Windows. With PB/CC, it's a whole new Windows! Text mode every version of Windows from Win95 to Vista and Win10."?
                          Darned if I know why that claim is either in need of 'toning down' or should be restricted to "text mode."

                          Directory List with Non-ASCII (Unicode) characters in file names 5-31-08 for PB/WIN or PB/CC

                          Compiles 'as is' in the stated PB/Win AND PB/CC versions... as a GUI program

                          I almost hate to resurrect Ye Olde Painte Brush and Artist Aphorisim... except here it really applies!
                          Michael Mattias
                          Tal Systems Inc.
                          Racine WI USA
                          mmattias@talsystems.com
                          http://www.talsystems.com

                          Comment


                          • #33
                            Originally posted by Dave Biggs View Post
                            Kerry,

                            The issue with Windows 10 (default QuickEdit ON) can also exist on a Win7 PC if the user has set that as a default option via the Console's Default properties menu.

                            Here is a modification of your test code that resets QuickEdit for your app if set in Win10 or Win7.
                            Dave

                            I just wanted you to know that you saved my bacon.

                            Without this code, I would have been forced to change my market or change my compiler

                            1000 thank you's sir

                            Kerry

                            [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
                            Kerry Farmer

                            Comment


                            • #34
                              No worries Bro
                              Rgds, Dave

                              Comment

                              Working...
                              X