TransWikia.com

how to use the "SPI_SETMOUSETRAILS" Parameters

Stack Overflow Asked by mingy on November 27, 2021

I am learning Win32 API programming. I read this paragraph, it says:

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa

SPI_SETMOUSETRAILS

Enables or disables the Mouse Trails feature, which improves the visibility of mouse cursor movements by briefly showing a trail of cursors and quickly erasing them.

To disable the feature, set the uiParam parameter to zero or 1. To enable the feature, set uiParam to a value greater than 1 to indicate the number of cursors drawn in the trail.

Windows 2000: This parameter is not supported.

I tried to write the following code:

#include <windows.h>

int main(int argc, char *argv[], char *envp[])
{
    //SystemParametersInfo(SPI_SETMOUSETRAILS, NULL,(PVOID)10, 0);
    SystemParametersInfo(SPI_SETMOUSETRAILS, NULL,(PVOID)0, 0);
}

But it doesn’t seem to make a difference.

Can anyone tell me how this macro works? I couldn’t find an example on the Internet, so I am asking here.

One Answer

Read the documentation again more carefully:

To disable the feature, set the uiParam parameter to zero or 1. To enable the feature, set uiParam to a value greater than 1 to indicate the number of cursors drawn in the trail.

Look at the declaration of the function:

BOOL SystemParametersInfoA(
    UINT uiAction,
    UINT uiParam,
    PVOID pvParam,
    UINT fWinIni
);

Your code is setting the uiParam parameter to 0 (disabling the feature), and setting the pvParam parameter to the cursor count (which is ignored).

Try this instead:

#include <windows.h>

int main(int argc, char *argv[], char *envp[])
{
    UINT cursorCount = ...;
    SystemParametersInfo(SPI_SETMOUSETRAILS, cursorCount, NULL, 0);

    return 0;
}

I couldn't find an example on the Internet

Really? When I enter just SPI_SETMOUSETRAILS by itself into Google, literally the 1st link returned contains an example:

http://ntcoder.com/bab/tag/spi_setmousetrails/

SystemParametersInfo is a powerful function which does and retrieves whole lot of things related to windows general behavior for eg: turning on and off certain features like mouse trails which we normally do via control panel->main.cpl

Look up MSDN for more information on SystemParametersInfo. I’ll just show a demo on how to turn on and off mouse trails…

// Turn on mouse trails, showing 10 cursors drawn in the trail
SystemParametersInfo( SPI_SETMOUSETRAILS, 10, 0, 0 );
// Turn off mouse trails, set trail count to 1 or zero to disable trails
SystemParametersInfo( SPI_SETMOUSETRAILS, 1, 0, 0 );

Answered by Remy Lebeau on November 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP