I am trying to use the PrintWindow function from the Windows API described at http://msdn.microsoft.com/en-us/library/windows/desktop/dd162869(v=vs.85).aspx
BOOL PrintWindow(
HWND hwnd,
HDC hdcBlt,
UINT nFlags
);
The call parameters are as follow :
[quote]hwnd
A handle to the window that will be copied.
hdcBlt
A handle to the device context.
nFlags
The drawing options. It can be one of the following values.
Value Meaning
PW_CLIENTONLY
Only the client area of the window is copied to hdcBlt. By default, the entire window is copied.[/quote]
Here is what I have so far, partly inspired from posts in the old forum :
[code] soft Declare Function PrintWindow Lib “user32” (hwnd As integer, hdcBlt As integer, nFlags As integer) As integer
Dim ret as Picture
Dim PichDC as integer
Dim tmphwnd as integer
Dim i as integer
ret = NewPicture( self.width, self.height, 32 )
PichDC = ret.Graphics.Handle(1)
tmphwnd = self.handle
i = PrintWindow( tmphwnd, PichDC, 1)
Canvas1.Backdrop = ret[/code]
tmphwnd is set to the window handle
The notion of Device Context from MS is a bit confusing. From discussions in the old forum, a member said that was the handle to a graphic object. Then the OP said it was working, but with no further detail
In the LR, Graphics.Handle(HandleTypeHDC ) where HandleTypeHDC = 1 gives the Windows handle. So that is how I set PichDC.
The last parameter is to copy the whole screen (0), or just the window (1).
When I call the code, no error, but no image capture either. What could be wrong ?
I also looked at http://www.pinvoke.net/default.aspx/user32/PrintWindow.html for the VB method, as well as several others and everything matches. This API call is not using that many parameters. What could be wrong ?
If anybody has pointers, they will be greatly appreciated. TIA.