Preston
Hrm, I didn't get to test this but this should get you started:
var
theicon: TICON;
iconwidth, iconheight : integer;
bmpColor: TBitmap;
r: TRect;
iconinfo: TIconInfo;
begin
bmpColor:= TBitmap.Create;
theicon:= TIcon.Create;
try
iconwidth:= GetSystemMetrics(SM_CXCURSOR);
iconheight:= GetSystemMetrics(SM_CYCURSOR);
r.Top:= 0;
r.Left:= 0;
r.Bottom:= iconheight;
r.Right:= iconwidth;
bmpColor.Height:= iconheight;
bmpColor.Width:= iconwidth;
bmpColor.Canvas.Brush.Color:= clWhite;
bmpColor.Canvas.FillRect(r);
bmpColor.Canvas.Font.Size:= 8;
bmpColor.Canvas.Font.Color:= clBlue;
bmpColor.Canvas.TextOut(6,12,text);
bmpColor.TransparentColor:= clWhite;
iconinfo.fIcon:= True;
iconinfo.xHotspot:= 6;
iconinfo.yHotspot:= 12;
iconinfo.hbmMask:= bmpColor.MaskHandle;
iconinfo.hbmColor:= bmpColor.Handle;
theicon.Handle:= CreateIconIndirect(iconinfo);
finally
bmpColor.Free;
theicon.Free;
end;
end;
A TIcon is a Cursor. In the above example theicon can be set to the
cursor.
--
Brad Prendergast
"The only difference between me and a madman is that I'm not mad." --
Salvador Dali (1904 - 1989)
> Appreciate the response. I'll try it out and repost if there are any
> changes.
Actually this will do it for you: I'd actually return the cursor rather
than setting it.
procedure TForm2.SetCursorText(text: string);
var
theicon: TICON;
iconwidth, iconheight : integer;
bmpColor: TBitmap;
r: TRect;
iconinfo: TIconInfo;
begin
bmpColor:= TBitmap.Create;
theicon:= TIcon.Create;
try
iconwidth:= GetSystemMetrics(SM_CXCURSOR);
iconheight:= GetSystemMetrics(SM_CYCURSOR);
r.Top:= 0;
r.Left:= 0;
r.Bottom:= iconheight;
r.Right:= iconwidth;
bmpColor.Height:= iconheight;
bmpColor.Width:= iconwidth;
bmpColor.Canvas.Brush.Color:= clBlack;
bmpColor.Canvas.FillRect(r);
bmpColor.Canvas.Font.Size:= 8;
bmpColor.Canvas.Font.Color:= clBlue;
bmpColor.Canvas.TextOut(6,12,text);
bmpColor.TransparentColor:= clBlack;
iconinfo.fIcon:= False;
iconinfo.xHotspot:= 6;
iconinfo.yHotspot:= 12;
iconinfo.hbmMask:= bmpColor.MaskHandle;
iconinfo.hbmColor:= bmpColor.Handle;
theicon.Handle:= CreateIconIndirect(iconinfo);
Screen.Cursors[5]:= theicon.Handle;
Screen.Cursor:= 5;
DeleteObject(iconinfo.hbmColor);
finally
bmpColor.Free;
theicon.Free;
end;
end;
--
That works great. Now maybe you know how to change the size of the
cursor? By default it's rather small and doesn't allow for much text.
> Thanks!
>
> That works great. Now maybe you know how to change the size of the
> cursor? By default it's rather small and doesn't allow for much text.
in the code that I had provided, set the variables:
iconwidth:= 500;
iconheight:= 45;
for example.
GetSystemMetrics, SM_CYCURSOR -Width and height, in pixels, of a cursor.
These are the cursor dimensions supported by the current display driver.
The system cannot create cursors of other sizes.
After reading "cannot create cursors of other sizes", I didn't even try
to adjust the width.
Works great!!
just be sure to test across display drivers/adapters....