NTK and The NTK Project
are properties of Jn Dechereux
Home | Documentation | FAQ.
Vanilla 1.1.8 is a product of Lussumo. More Information: Documentation, Community Support.
Hi there
In my new project I need to programatically take a picture of the machine desktop at regular intervals - but have no idea how to do this. So, just wondering if a function capable to take a screenshot and save it to disk already exists in NTK? -or- If someone has already developed such kind of code and would like to share it? Any help would be appreciated.
TIA
-Chris
FUNCTION GrabFullScreen(hWndP) Local hDcScr, hdcMem, hBmpWin Local aScrRect := ARRAY(4) Local cBmpFileDest := "Image_"+DTOS(Date())+"_"+nToc(Second())+".bmp" CLEAR TYPEAHEAD NTK_HideWindow(hWndP, .T.) // temporally hide NTK-Snapshot window // Now, we take a snapshot of the full screen... hDcScr := NTK_GetDC( NULL ) // Get a DC on the fullscreen // Retreive the fullscreen resolution aScrRect[ RECT_Left ] := 0 aScrRect[ RECT_Top ] := 0 aScrRect[ RECT_Right ] := NTK_GetSystemMetrics( SM_CXSCREEN ) aScrRect[ RECT_Bottom ] := NTK_GetSystemMetrics( SM_CYSCREEN ) hDcMem := NTK_CreateCompatibleDC( hDcScr ) hBmpWin := NTK_CreateCompatibleBitmap( hDcScr,; aScrRect[ RECT_Right ] - aScrRect[ RECT_Left ],; aScrRect[ RECT_Bottom ] - aScrRect[ RECT_Top ] ) NTK_SelectObject( hdcMem, hBmpWin ) NTK_BitBlt( hDcMem, 0, 0, aScrRect[RECT_Right] - aScrRect[RECT_Left], aScrRect[RECT_Bottom] - aScrRect[RECT_Top],; hDcScr, 0, 0,; SRCCOPY ) NTK_DeleteDC( hdcMem ) NTK_ReleaseDC( hDcScr, NULL ) NTK_HideWindow(hWndP, .F.) // Call back the NTK-Snapshot window IF NTK_SaveBmp( nil, hBmpWin, cBmpFileDest ) lRet := .T. Alert( "FULL-SCREEN:"+CR+; "Picture successfully taken and saved under:"+CR+cBmpFileDest ) ELSE lRet := .F. Alert( "FULL-SCREEN:"+CR+; "Cannot save "+CR+cBmpFileDest ) ENDIF NTK_DeleteObject(hBmpWin) RETURN( lRet )
Hi Ab
It was there since years and I did not see it!
Many thanks - this is exactly what I was looking for.
-Chris
1 to 5 of 5