Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  4 450

•  TDictionary Custom Sort  6 483

•  Fast Watermark Sources  6 281

•  3D Designer  9 224

•  Sik Screen Capture  6 615

•  Patch Maker  6 994

•  Айболит (remote control)  6 998

•  ListBox Drag & Drop  5 867

•  Доска для игры Реверси  97 059

•  Графические эффекты  7 198

•  Рисование по маске  6 501

•  Перетаскивание изображений  5 365

•  Canvas Drawing  5 741

•  Рисование Луны  5 454

•  Поворот изображения  4 981

•  Рисование стержней  3 535

•  Paint on Shape  2 803

•  Генератор кроссвордов  3 669

•  Головоломка Paletto  2 959

•  Теорема Монжа об окружностях  3 763

•  Пазл Numbrix  2 481

•  Заборы и коммивояжеры  3 166

•  Игра HIP  2 132

•  Игра Go (Го)  2 066

•  Симулятор лифта  2 438

•  Программа укладки плитки  2 113

•  Генератор лабиринта  2 584

•  Проверка числового ввода  2 264

•  HEX View  2 591

•  Физический маятник  2 202

 
скрыть

  Форум  

Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Включить изображение курсора в снимок экрана



Оформил: DeeCo

// 1. Get the handle to the current mouse-cursor and its position 
function GetCursorInfo2: TCursorInfo;
 var
  hWindow: HWND;
  pt: TPoint;
  pIconInfo: TIconInfo;
  dwThreadID, dwCurrentThreadID: DWORD;
 begin
  Result.hCursor := 0;
  ZeroMemory(@Result, SizeOf(Result));
  // Find out which window owns the cursor 
 if GetCursorPos(pt) then
  begin
    Result.ptScreenPos := pt;
    hWindow := WindowFromPoint(pt);
    if IsWindow(hWindow) then
    begin
      // Get the thread ID for the cursor owner. 
     dwThreadID := GetWindowThreadProcessId(hWindow, nil);

      // Get the thread ID for the current thread 
     dwCurrentThreadID := GetCurrentThreadId;

      // If the cursor owner is not us then we must attach to 
     // the other thread in so that we can use GetCursor() to 
     // return the correct hCursor 
     if (dwCurrentThreadID <> dwThreadID) then
      begin
        if AttachThreadInput(dwCurrentThreadID, dwThreadID, True) then
        begin
          // Get the handle to the cursor 
         Result.hCursor := GetCursor;
          AttachThreadInput(dwCurrentThreadID, dwThreadID, False);
        end;
      end
      else
      begin
        Result.hCursor := GetCursor;
      end;
    end;
  end;
 end;

 // 2. Capture the screen 
function CaptureScreen: TBitmap;
 var
  DC: HDC;
  ABitmap: TBitmap;
  MyCursor: TIcon;
  CursorInfo: TCursorInfo;
  IconInfo: TIconInfo;
 begin
  // Capture the Desktop screen 
 DC := GetDC(GetDesktopWindow);
  ABitmap := TBitmap.Create;
  try
    ABitmap.Width  := GetDeviceCaps(DC, HORZRES);
    ABitmap.Height := GetDeviceCaps(DC, VERTRES);
    // BitBlt on our bitmap 
   BitBlt(ABitmap.Canvas.Handle,
      0,
      0,
      ABitmap.Width,
      ABitmap.Height,
      DC,
      0,
      0,
      SRCCOPY);
    // Create temp. Icon 
   MyCursor := TIcon.Create;
    try
      // Retrieve Cursor info 
     CursorInfo := GetCursorInfo2;
      if CursorInfo.hCursor <> 0 then
      begin
        MyCursor.Handle := CursorInfo.hCursor;
        // Get Hotspot information 
       GetIconInfo(CursorInfo.hCursor, IconInfo);
        // Draw the Cursor on our bitmap 
       ABitmap.Canvas.Draw(CursorInfo.ptScreenPos.X - IconInfo.xHotspot,
                            CursorInfo.ptScreenPos.Y - IconInfo.yHotspot, MyCursor);
      end;
    finally
      // Clean up 
     MyCursor.ReleaseHandle;
      MyCursor.Free;
    end;
  finally
    ReleaseDC(GetDesktopWindow, DC);
  end;
  Result := ABitmap;
 end;

 // Example: Capture the screen and include the cursor. 
// Show the Screenshot in Image1 

procedure TForm1.Button1Click(Sender: TObject);
 begin
   Image1.Picture.Assign(CaptureScreen);
 end;




Похожие по теме исходники

Image2Text (изображение в текст)

Хранитель экрана Папины Дочки

Передача удаленного экрана по сети (Remote Screen)




Copyright © 2004-2025 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте