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

•  DeLiKaTeS Tetris (Тетрис)  173

•  TDictionary Custom Sort  3 344

•  Fast Watermark Sources  3 095

•  3D Designer  4 853

•  Sik Screen Capture  3 351

•  Patch Maker  3 556

•  Айболит (remote control)  3 665

•  ListBox Drag & Drop  3 020

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

•  Графические эффекты  3 948

•  Рисование по маске  3 253

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

•  Canvas Drawing  2 762

•  Рисование Луны  2 586

•  Поворот изображения  2 196

•  Рисование стержней  2 173

•  Paint on Shape  1 570

•  Генератор кроссвордов  2 242

•  Головоломка Paletto  1 771

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

•  Пазл Numbrix  1 685

•  Заборы и коммивояжеры  2 060

•  Игра HIP  1 282

•  Игра Go (Го)  1 232

•  Симулятор лифта  1 477

•  Программа укладки плитки  1 219

•  Генератор лабиринта  1 549

•  Проверка числового ввода  1 369

•  HEX View  1 497

•  Физический маятник  1 359

 
скрыть


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

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



Delphi Sources

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



Оформил: 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-2024 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

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