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.
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?