Well thanks i managed to fix it , i just have one small worry left. It shows the screen mouse as a circle! i want it to draw the main mouse icon.
Code looks like this :
unit ScreenCapLib2Unit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Windows, Forms, Controls, Graphics, Dialogs, LCLType,
LCLIntf, StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure DrawCursor (ACanvas:TCanvas; Position:TPoint) ;
var
HCursor : THandle;
begin
HCursor := GetCursor;
DrawIconEx(ACanvas.Handle, Position.X, Position.Y,
HCursor, 32, 32, 0, 0, DI_NORMAL) ;
end;
procedure CaptureScreen();
var
DCDesk: HDC;
bmp: TBitmap;
CurPos: TPoint;
begin
Form1.Hide;
bmp := TBitmap.Create;
bmp.Height := Screen.Height;
bmp.Width := Screen.Width;
DCDesk := GetDC(0);
bmp.LoadFromDevice(DCDesk);
BitBlt(bmp.Canvas.Handle, 0, 0, Screen.Width, Screen.Height,DCDesk, 0, 0, SRCCOPY);
GetCursorPos(CurPos);
DrawCursor(bmp.Canvas, CurPos);
bmp.SaveToFile('C:\Users\******************\Desktop\ScreenShot.bmp');
ReleaseDC(GetDesktopWindow, DCDesk);
showmessage('Done check Desktop');
bmp.Free;
Form1.Show;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
//CaptureScreen();
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Hide;
CaptureScreen();
end;
end.
Attached is the screenshot it shows, dont know why it is so
[image]https://i.postimg.cc/yYksKj6S/Screen-Shot.png[/image]