AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Delphi MagSetWindowFilterList function not remove specified window of screenshot
Thema durchsuchen
Ansicht
Themen-Optionen

MagSetWindowFilterList function not remove specified window of screenshot

Ein Thema von flashcoder · begonnen am 27. Jan 2018 · letzter Beitrag vom 29. Jan 2018
Antwort Antwort
Seite 4 von 4   « Erste     234   
EWeiss
(Gast)

n/a Beiträge
 
#31

AW: MagSetWindowFilterList function not remove specified window of screenshot

  Alt 29. Jan 2018, 01:28
Delphi is case insensitive and is able to know waht is a variable name and a type.
and that is a good code style?
i think not.

greets
  Mit Zitat antworten Zitat
Benutzerbild von Zacherl
Zacherl

Registriert seit: 3. Sep 2004
4.629 Beiträge
 
Delphi 10.2 Tokyo Starter
 
#32

AW: MagSetWindowFilterList function not remove specified window of screenshot

  Alt 29. Jan 2018, 01:55
MagSetWindowSource not is necessary, i tested here (Delphi code) without this api and screenshot still is works.
It keeps crashing, if I comment out the MagSetWindowSource . Callstack points to `msvcrt.memcpi` so I guess there's something fishy somewhere else. Could be anything like wrong types, calling conventions, buffer overreads, ... Same problem might cause your black image. Buffer overreads/overflows can be tricky sometimes and do not always result in reproducable problems.
Projekte:
- GitHub (Profil, zyantific)
- zYan Disassembler Engine ( Zydis Online, Zydis GitHub)

Geändert von Zacherl (29. Jan 2018 um 01:57 Uhr)
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#33

AW: MagSetWindowFilterList function not remove specified window of screenshot

  Alt 29. Jan 2018, 05:40
MagSetWindowSource not is necessary, i tested here (Delphi code) without this api and screenshot still is works.
It keeps crashing, if I comment out the MagSetWindowSource . Callstack points to `msvcrt.memcpi` so I guess there's something fishy somewhere else. Could be anything like wrong types, calling conventions, buffer overreads, ... Same problem might cause your black image. Buffer overreads/overflows can be tricky sometimes and do not always result in reproducable problems.
the Trouble is resize, that is known on W7 64Bit.
but it works on W7 32 BIT.
i think you can nothing do on it.

greets
  Mit Zitat antworten Zitat
flashcoder

Registriert seit: 10. Nov 2013
83 Beiträge
 
#34

AW: MagSetWindowFilterList function not remove specified window of screenshot

  Alt 29. Jan 2018, 06:20
Here is project solved and working 100% like must be.

Delphi-Quellcode:
var
  Form1: TForm1;

implementation

uses
  Unit3, Magnification;

{$R *.dfm}

function MagImageScalingCallback(hwnd: hwnd; srcdata: Pointer;
  srcheader: MAGIMAGEHEADER; destdata: Pointer; destheader: MAGIMAGEHEADER;
  unclipped: TRect; clipped: TRect; dirty: HRGN): BOOL; stdcall;
var
  lpbmi: TBitmapInfo;
  bmp: TBitmap;
  aDC: HDC;
  abitmap: HBitmap;
begin
  Fillchar(lpbmi, sizeof(lpbmi), 0);
  lpbmi.bmiHeader.biSize := sizeof(lpbmi.bmiHeader);
  lpbmi.bmiHeader.biHeight := -srcheader.height;
  // Otherwise the image is upside down.
  lpbmi.bmiHeader.biWidth := srcheader.width;
  lpbmi.bmiHeader.biSizeImage := srcheader.cbSize;
  lpbmi.bmiHeader.biPlanes := 1;
  lpbmi.bmiHeader.biBitCount := 32;
  lpbmi.bmiHeader.biCompression := BI_RGB;

  aDC := GetWindowDC(hwnd);
  bmp := TBitmap.Create;
  abitmap := 0;
  try
    abitmap := CreateDIBitmap(aDC, lpbmi.bmiHeader, CBM_INIT, srcdata, lpbmi,
      DIB_RGB_COLORS);
    bmp.handle := abitmap;
    bmp.SaveToFile('c:\screen.bmp');
  finally
    DeleteObject(abitmap);
    DeleteDC(aDC);
    bmp.Free;
  end;

  Result := True;
end;

procedure MagScreenShot;
var
  desktop, hwndMag: hwnd;
  desktoprect, sourceRect: TRect;
  filterList: THWNDArray;
  m_ScreenX, m_ScreenY, m_ScreenT, m_ScreenL: Integer;
begin

  Form1.WindowState := wsMaximized;

  if not Form3.Showing then
    Form3.Show;

  desktop := GetDesktopWindow;
  GetWindowRect(desktop, desktoprect);

  m_ScreenT := desktoprect.Top;
  m_ScreenL := desktoprect.Left;
  m_ScreenX := desktoprect.right;
  m_ScreenY := desktoprect.bottom;

  if (not MagInitialize) then
  begin
    Application.MessageBox('Init magnification failed', 'Error',
      mb_Ok + mb_IconError);
    Exit;
  end;

  hwndMag := CreateWindow(WC_MAGNIFIER, 'MagnifierWindow',
    WS_CHILD or MS_SHOWMAGNIFIEDCURSOR or WS_VISIBLE, 0, 0, m_ScreenX,
    m_ScreenY, Form1.handle, 0, hInstance, nil);

  if (hwndMag = 0) then
  begin
    Application.MessageBox('MagnifierWindow creation failed', 'Error',
      mb_Ok + mb_IconError);
    Exit;
  end;

  if (not MagSetImageScalingCallback(hwndMag, MagImageScalingCallback)) then
  begin
    Application.MessageBox('Cannot set callback', 'Error',
      mb_Ok + mb_IconError);
    Exit;
  end;

  try
    filterList[0] := Form3.handle;
  except
  end;

  if (not MagSetWindowFilterList(hwndMag, MW_FILTERMODE_EXCLUDE, 1,
    @filterList[0])) then
  begin
    Application.MessageBox('Cannot exclude main window', 'Error',
      mb_Ok + mb_IconError);
    Exit;
  end;

  sourceRect.Top := m_ScreenT;
  sourceRect.Left := m_ScreenL;
  sourceRect.right := m_ScreenX;
  sourceRect.bottom := m_ScreenY;

  Sleep(200);

  if (not MagSetWindowSource(hwndMag, sourceRect)) then
  begin
    Application.MessageBox('Cannot set source to MagnifierWindow', 'Error',
      mb_Ok + mb_IconError);
    Exit;
  end;

  { if (not MagUninitialize) then
    begin
    Application.MessageBox('Finalize magnification failed', 'Error',
    mb_Ok + mb_IconError);
    Exit;
    end; }

end;

procedure TForm1.btn1Click(Sender: TObject);
begin
  MagScreenShot;
end;
Angehängte Dateien
Dateityp: zip Magnification DEMO 29 - 01 - 2018.zip (93,8 KB, 22x aufgerufen)
  Mit Zitat antworten Zitat
Benutzerbild von Zacherl
Zacherl

Registriert seit: 3. Sep 2004
4.629 Beiträge
 
Delphi 10.2 Tokyo Starter
 
#35

AW: MagSetWindowFilterList function not remove specified window of screenshot

  Alt 29. Jan 2018, 06:49
MagSetWindowSource not is necessary, i tested here (Delphi code) without this api and screenshot still is works.
It keeps crashing, if I comment out the MagSetWindowSource . Callstack points to `msvcrt.memcpi` so I guess there's something fishy somewhere else. Could be anything like wrong types, calling conventions, buffer overreads, ... Same problem might cause your black image. Buffer overreads/overflows can be tricky sometimes and do not always result in reproducable problems.
the Trouble is resize, that is known on W7 64Bit
Yes, I can confirm this. The latest version works for me, but resizing still crashes the application.
Projekte:
- GitHub (Profil, zyantific)
- zYan Disassembler Engine ( Zydis Online, Zydis GitHub)
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#36

AW: MagSetWindowFilterList function not remove specified window of screenshot

  Alt 29. Jan 2018, 07:37
Zitat:
Here is project solved and working 100% like must be.
no it Crash.. and has a black Screen.
it works and does not work.

MagImageScalingCallback is not needed.
and if you deactivate Desktop Theme then it Crash always..
on this line

  if (not MagSetWindowSource(hwndMag, sourceRect)) then
with Floating Point invalid Operation.

here are a full new projekt
which works without Crash, please deactivate Desktop Themes before run.
sorry your source text is fully flawed.

1. Each new call creates a new instance of the Magnification Dll without uninitializing the old one before.
2. Each new call creates a new Window without destroy the old one before.
3. Array of tagMAGTRANSFORM is wrong.
4. Filterlist is not Needed.
5. a second form is not needed.
6. the callback also if your use a Timer.

.. and so on.

greets

Geändert von EWeiss (29. Jan 2018 um 09:36 Uhr)
  Mit Zitat antworten Zitat
flashcoder

Registriert seit: 10. Nov 2013
83 Beiträge
 
#37

AW: MagSetWindowFilterList function not remove specified window of screenshot

  Alt 29. Jan 2018, 13:06
Zitat:
Here is project solved and working 100% like must be.
no it Crash.. and has a black Screen.
it works and does not work.

MagImageScalingCallback is not needed.
and if you deactivate Desktop Theme then it Crash always..
on this line

  if (not MagSetWindowSource(hwndMag, sourceRect)) then
with Floating Point invalid Operation.

here are a full new projekt
which works without Crash, please deactivate Desktop Themes before run.
sorry your source text is fully flawed.

1. Each new call creates a new instance of the Magnification Dll without uninitializing the old one before.
2. Each new call creates a new Window without destroy the old one before.
3. Array of tagMAGTRANSFORM is wrong.
4. Filterlist is not Needed.
5. a second form is not needed.
6. the callback also if your use a Timer.

.. and so on.

greets
Even that your code work (and yes works with aero actived or no here), the approach of question is totally different of this and your last update is more near of this approach, but even thank you by fix some bugs mainly the and of your enumeration.

About item , is necessary because i not want show Magnifier window to user (i still will hide Form1 in my project), based on C++ example. Please, read item 2 on page of C++ example.

Relative to black screen, see in my last updated that is black only on Magnifier window, but on bmp file not.

Geändert von flashcoder (29. Jan 2018 um 13:56 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 4 von 4   « Erste     234   


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:02 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz