Link to home
Start Free TrialLog in
Avatar of lucley
lucley

asked on

using Clipboard functions in a DLL

I try to write a function that Copy's the Active window to a Bitmap file. When I use this function in a program it work's fine. When put it in a DLL it don't work.
Help!!!!!

function CopyActiveScreenToFile(FName: PChar): Boolean;
var TmpBMP:TBitmap;
    Data: THandle;
    Palette: HPALETTE;
begin
  Result := False;
  Clipboard.Open;
  keybd_event(VK_SNAPSHOT, 0, 0, 0);
  TmpBMP := TBitmap.Create;
  try
    Data := GetClipboardData(CF_BITMAP);
    Palette := GetClipboardData(CF_PALETTE);
    TmpBMP.LoadFromClipBoardFormat(CF_BITMAP, Data, Palette);
    TmpBMP.SaveToFile(FName);
    if FileExists(FName) then
      Result := True
    else
      Result :=False;
  finally
    TmpBMP.Free;
  end;
  Clipboard.Close;
end;
Avatar of BlackDeath
BlackDeath

hoi, lucley!

i can't get this to work - EIvalidGraphic with LoadFromClipboardFormat.
?
are you sure it runs as supposed?

Black Death.
ASKER CERTIFIED SOLUTION
Avatar of inter
inter
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial