ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 CaptureFromScreen does not capture menu

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
PeterPanino Posted - Feb 25 2024 : 16:41:31
1. I start a Timer.

2. I focus the Notepad window.

3. I open a menu on Notepad.

4. Then the Timer fires and takes a screenshot from Notepad while the menu on Notepad is still open (ImageEnView1.IO.CaptureFromScreen(iecsSpecifiedWindow, -1, NotepadHandle).

5. The Notepad menu is not seen on the screenshot!

How to create a screenshot of the menu?
8   L A T E S T    R E P L I E S    (Newest First)
PeterPanino Posted - Feb 28 2024 : 00:52:59
Now I've done it even better: I've created a method to take a screenshot of ANY menu even when it is displayed outside of a window. In this way, I can also make a screenshot of a CASCADED menu with submenus by combining the menu with its submenus by taking into account their relative positions and combining them into a common screenshot!
xequte Posted - Feb 27 2024 : 20:45:06
Nicely done

Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Feb 27 2024 : 06:30:50
"The hard part would be getting the handle of the menu."

That is easy with MSAA (Microsoft Active Accessibility), although the handle itself is not needed to obtain the menu screenshot.

"I think your best bet would be capturing the whole screen, then cropping it to the dimensions of the window you are trying to capture."

That's exactly what I've done to solve the problem:



And then, by automatically making a TImageEnProc.CompareWith I extract the menu part of the image:



This will be available as a one-click solution (among many other ingenious solutions) in my upcoming Program Window Manager Pro 2.0.
xequte Posted - Feb 26 2024 : 16:41:01
Hi

The hard part would be getting the handle of the menu. I think your best bet would be capturing the whole screen, then cropping it to the dimensions of the window you are trying to capture. Though that would still fail in situations where the menu is outside the area of the parent window.

However I am not particularly experienced in this area, you might want to ask on a more general forum, like Stack Overflow.

Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Feb 26 2024 : 15:48:17
I have tried this function using BitBlt:

function PACaptureWindowToTIEBitmap(AWinHandle: HWND): TIEBitmap;
var
  WindowDC: HDC;
  WindowRect: TRect;
  CaptureRect: TRect;
begin
  // Create the TIEBitmap that will hold the screenshot of the window
  Result := TIEBitmap.Create;

  // Get the device context (DC) of the window
  WindowDC := GetWindowDC(AWinHandle);
  try
    // Get the dimensions of the window, including non-client areas
    GetWindowRect(AWinHandle, WindowRect);
    CaptureRect := Rect(0, 0, WindowRect.Right - WindowRect.Left, WindowRect.Bottom - WindowRect.Top);

    // Prepare the TIEBitmap to match the window size
    Result.Allocate(CaptureRect.Right - CaptureRect.Left, CaptureRect.Bottom - CaptureRect.Top);

    // Copy from the window's DC to the TIEBitmap
    BitBlt(Result.Canvas.Handle, 0, 0, CaptureRect.Right, CaptureRect.Bottom, WindowDC, 0, 0, SRCCOPY);
  finally
    ReleaseDC(AWinHandle, WindowDC);
  end;
end;


But even that does not capture the menu!
PeterPanino Posted - Feb 26 2024 : 15:21:28
Hi Nigel,

Could you provide a fallback screenshot method to capture menus, overlays, tooltips, etc., using BitBlt?
xequte Posted - Feb 26 2024 : 03:14:22
Hi Peter

That's not possible with ImageEn, I'm afraid. I don't know of a screen capture component that supports it, but it should be possible.


Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Feb 26 2024 : 00:48:28
Is there no solution in ImageEn to capture a MENU? I've researched MSAA (Microsoft Active Accessibility), where I can get a MenuHandle notification right before Windows displays the menu. Then, I would have to obtain a screenshot of the whole screen with
IO.CaptureFromScreen(iecsScreen, -1 );
by using something like a Timer ...

Then I would have to compare the screens before and after the menu with Proc.Compare (which is extremely slow with large screens).

It would be nice if ImageEn had a built-in solution for creating a menu screenshot!