Why do i have mouse cursor artifacts on portrait monitor setup?

3.2k Views Asked by At

I have a delphi application that loads custom mouse cursors by using LoadImage(Hinstance, PWideChar(Name), IMAGE_CURSOR, 0, 0, LR_DEFAULTCOLOR);. These custom cursors have a size of 32x32, 48x48 or 64x64, depending of the users choice. If i load a custom cursor and move the mouse outside the application, the cursor changes to the windows default (arrow) one. But this arrow now has artifacts on the bottom side of the cursor. Also the artifacts change depending on the custom cursor previously loaded and the size it includes in the, e.g. 64x64 rect.

I was trying to take a screenshot but the artifacts do not appear on it. So i painted the phenomenon to give you a clue how it looks like.

enter image description here

What i have found so far. All points on the following list must be applied:

  • It only happens when the custom mouse cursor is > 32x32.
  • It only happens on a monitor setup in portrait mode.
  • It only happens if the mouse shadow is active.
  • It only happens if the mouse trail is turned off.
  • It only happens when having a NVIDIA graphics card.
  • It only happens when the DPI setting is 100%.

The following code example shows the problem with the cursor. Just create a new VCL Form project and add it to the corresponding unit.

unit Unit6;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

const
   crMyCursor = 1;

type
  TForm6 = class(TForm)
    procedure FormShow(Sender: TObject);
  end;

var
  Form6: TForm6;

implementation

{$R *.dfm}

procedure TForm6.FormShow(Sender: TObject);
begin
  Screen.Cursors[crMyCursor] := LoadImage(Hinstance, PWideChar('MAINICON'), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
  Screen.Cursor := crMyCursor;
end;

end.

UPDATE: It used to be a problem in relation with NVIDIA graphic cards. The artifacts appear with the follwing graphic cards: GeForce 9600 GT, GeForce GT 630 and GeForce GTX 660. I also tested Intel Onboard graphic and ATI graphic cards and the artifacts do not appear with these setups.

So can anyone tell me why these artifacts appear and how i get rid of them?

2

There are 2 best solutions below

0
On

I actually was reintroduced to this issue following a rebuild. My solution for this was to enable "Display pointer trails" in Pointer Options in the Mouse Properties and setting the slider all the way to Short. After that, there were no more artifacts.

Mouse Properties

The mouse trail is barely noticeable to me, and the afterimage of it helps me keep track of it across three monitors.

0
On

It's due to bugs in the graphic drivers and similar things occur for some ATI users as well.
However, this is not a Delphi or even custom mouse issue.

I experienced the exact same phenomenon (weird line artifact following under the mouse cursor), but just on the desktop, on both of my side, portrait-flipped monitors (NB I'm running a gtx680, so your list isn't exhaustive either).

The issue is to do with shadowing. Both the answers here work, but obviously if you like shadows the current top answer (flipping the monitors back to landscape, then reverting at the Keep these settings? prompt) would suit you better.