try with this code, work fine for me in Win XP 32 bit.
Code: Select all
#include "hmg.ch"
*------------------------------------------------------------------------------*
Function Main()
*------------------------------------------------------------------------------*
DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 400 ;
HEIGHT NIL ;
TITLE '' ;
MAIN
define button test
row 10
col 10
caption 'test'
action test()
end button
@ 50, 10 LABEL Label_1 AUTOSIZE
END WINDOW
ACTIVATE WINDOW Win_1
Return
*-----------------------------------------------------------------------------------*
procedure test
*-----------------------------------------------------------------------------------*
local i, hDesktop, nDesktopWidth, nDesktopHeight
hDesktop := BT_SCR_GETDESKTOPHANDLE()
nDesktopWidth := GetDesktopWidth()
nDesktopHeight := GetDesktopHeight()
y := 90
for i := 1 to 1000
Win_1.Label_1.VALUE := { i, ") ", HMG_GetObjectCount()[1], HMG_GetObjectCount()[2], HMG_GetObjectCount()[3], " --- ", GetProcessMemoryInfo()[3]/1024/1024 }
xSaveWindowByHandle ( hDesktop , strzero(i,4) + '.' + 'jpg' , 0 , 0 , nDesktopWidth , nDesktopHeight )
IF i % 50 == 0
RELEASE MEMORY // ADD
cName := "Label_"+hb_ntos(i)
@ y, 10 LABEL &cName OF Win_1 AUTOSIZE
y = y + 30
xValue := { i, ") ", HMG_GetObjectCount()[1], HMG_GetObjectCount()[2], HMG_GetObjectCount()[3], " --- ", GetProcessMemoryInfo()[3]/1024/1024 }
SetProperty( "Win_1", cName, "VALUE", xValue )
ENDIF
DO EVENTS // ADD
hb_releaseCPU() // ADD
next i
msginfo('fin')
return
*-----------------------------------------------------------------------------------*
FUNCTION xSaveWindowByHandle ( nHandle , cFileName , nRow , nCol , nWidth , nHeight )
*-----------------------------------------------------------------------------------*
LOCAL hBitmap
hBitmap := xBT_BitmapCaptureClientArea ( nHandle , nRow, nCol, nWidth, nHeight)
IF hBitmap <> 0
IF UPPER(RIGHT( cFileName , 4 ) ) == '.GIF'
BT_BitmapSaveFile (hBitmap, cFileName , BT_FILEFORMAT_GIF )
ELSEIF UPPER(RIGHT( cFileName , 4 ) ) == '.JPG'
BT_BitmapSaveFile (hBitmap, cFileName , BT_FILEFORMAT_JPG )
ELSEIF UPPER(RIGHT( cFileName , 4 ) ) == '.PNG'
BT_BitmapSaveFile (hBitmap, cFileName , BT_FILEFORMAT_PNG )
ELSEIF UPPER(RIGHT( cFileName , 4 ) ) == '.BMP'
BT_BitmapSaveFile (hBitmap, cFileName , BT_FILEFORMAT_BMP )
ENDIF
BT_BitmapRelease (hBitmap)
ENDIF
RETURN hBitmap
Function xBT_BitmapCaptureClientArea ( nHandle , Row, Col, Width, Height)
LOCAL New_hBitmap
LOCAL Max_Width := BT_ClientAreaWidth( nHandle )
LOCAL Max_Height := BT_ClientAreaHeight( nHandle )
bt_FillRectIsNIL (@Row, @Col, @Width, @Height, 0, 0, Max_Width, Max_Height)
bt_AdjustWidthHeightRect (Row, Col, @Width, @Height, Max_Width, Max_Height)
New_hBitmap := BT_BMP_CAPTURESCR ( nHandle , Col, Row, Width, Height, BT_BITMAP_CAPTURE_CLIENTAREA)
Return New_hBitmap