Announcement

Collapse
No announcement yet.

SPI_SetMouseTrails

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

  • SPI_SetMouseTrails

    This works to turn on/off mouse trails.

    Code:
    #Include "win32api.inc"
    Function PBMain() As Long
       Local Tails, Unused As Long
       Tails = 6   '0,1 no Trails  > 1 = trails
       SystemParametersInfo(%SPI_SETMOUSETRAILS,Tails,Unused,%SPIF_SENDCHANGE)
    End Function
    But a variable is required where "Unused" is shown. Here's the declaration from Jose's includes.

    Code:
    Declare Function SystemParametersInfoA Import "USER32.DLL" Alias "SystemParametersInfoA" ( _
       ByVal uiAction As Dword _                            ' __in UINT uiAction
     , ByVal uiParam As Dword _                             ' __in UINT uiParam
     , ByRef pvParam As Any _                               ' __inout_opt PVOID pvParam
     , ByVal fWinIni As Dword _                             ' __in UINT fWinIni
     ) As Long                                              ' BOOL
    I guess I don't understand how this defines the need for a variable in that position.

    Code:
     , ByRef pvParam As Any _                               ' __inout_opt PVOID pvParam

  • #2
    SystemParametersInfoA function (winuser.h) - Win32 apps | Microsoft Docs
    That parameter near bottom of page.

    It is for a feature of SystemParametersInfo that you're not using. But the function expects 4 parameters, so you send null in that position.

    Cheers,

    added: Instead of making variable "Unused", then calling
    SystemParametersInfo(%SPI_SETMOUSETRAILS,Tails,Unused,%SPIF_SENDCHANGE)

    Over-ride the BYREF in the include file's DECLARE with
    SystemParametersInfo(%SPI_SETMOUSETRAILS,Tails,BYVAL 0,%SPIF_SENDCHANGE)
    You no longer need "Unused".
    (Being an IN as well as OUT parameter may cause this method to error. see next)

    Or even simpler, just use a literal 0 instead of "Unused". (suggested on MSDN page)

    From Help for CALL -
    When you pass parameters from the calling code with an explicit BYVAL, you effectively switch off the compilers type-checking for that parameter. This can be useful in cases where the called code is expecting a BYREF parameter, and you wish to pass an address of another data type that would trigger a compile-time error without the BYVAL method.
    Dale

    Comment


    • #3
      Howdy, Dale and thanks for the reply!

      I tried a plain zero and it failed to compile, saying it needed a variable.

      Comment


      • #4
        Hi Gary, anyway to demonstrate this mouse trails function in a compilable example ? I'm ever eager to learn to enhance my PB programming
        Thanks in advance

        Comment


        • #5
          Byval 0 compiles fine. For you, Tim:

          Added - max nunber of mouse trails seems to be 16 (Windows 10)

          '
          Code:
          '====================================================================
          #COMPILE EXE
          #DIM ALL
          '%UNICODE = 1
          #INCLUDE "WIN32API.INC"
          
          '====================================================================
          FUNCTION PBMAIN () AS LONG
            LOCAL hDlg AS DWORD
          
            DIALOG NEW 0, "Set Mousetrails",,, 130, 40, %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg
          
            '------------------------------------------------------------------
            CONTROL ADD BUTTON, hDlg, %IDOK,     "6 Trails", 10, 15, 50, 14
            CONTROL ADD BUTTON, hDlg, %IDCANCEL, "0 Trails", 70, 15, 50, 14
          
            '------------------------------------------------------------------
            DIALOG SHOW MODAL hDlg CALL DlgProc
          
          END FUNCTION
          
          '====================================================================
          CALLBACK FUNCTION DlgProc() AS LONG
          
            SELECT CASE AS LONG CB.MSG
            CASE %WM_INITDIALOG
          
            CASE %WM_DESTROY  ' reset meouse trails to 0 at exit? In case we just test and forget..
               SystemParametersInfo(%SPI_SETMOUSETRAILS, 0, BYVAL 0, %SPIF_SENDCHANGE)
          
            CASE %WM_COMMAND
                SELECT CASE AS LONG CB.CTL
                CASE %IDOK
                   IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                      SystemParametersInfo(%SPI_SETMOUSETRAILS, 6, BYVAL 0, %SPIF_SENDCHANGE)
                   END IF
          
                CASE %IDCANCEL
                   IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN 'end prog
                      SystemParametersInfo(%SPI_SETMOUSETRAILS, 0, BYVAL 0, %SPIF_SENDCHANGE)
                   END IF
                END SELECT
          
            END SELECT
          END FUNCTION
          '

          Comment


          • #6
            I guess I don't understand how this defines the need for a variable in that position.
            The DECLARE statement tells you - well, it actually tells the compiler - that you need either a variable OR a numeric literal by value... which, based on the DECLARE you are using, requires the BYVAL point of call override.


            FWIW, I sent in a NFS many years ago to support an empty argument in a call, e.g.,

            Code:
            SystemParametersInfo(%SPI_SETMOUSETRAILS, 6, , %SPIF_SENDCHANGE)
            .. and have the compiler automatically substitute "BYVAL 0&" for the empty argument.

            I still think that's a good idea as it makes it obvious that you are not using that argument for this particular call.
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Thank you Sir Borje

              Comment


              • #8
                Tim
                Attached is the Mouse Trails with a special cursor ( custom made cursor) program
                modified from Borje

                It will display a nice custom made cursor with trails.

                Attached Files

                Comment


                • #9
                  Thanks Anne, wonderful !

                  Comment

                  Working...
                  X