x_bennY Posted February 16, 2018 Share Posted February 16, 2018 (edited) Hey! I'm trying to capture a screenshot and put it in a control without saving it(as fast as possible), just using the memory...It's a SlidePresenter and i need to create a preview on the main form. I have tryied some things with GDI+, but without sucess. Here is the code: expandcollapse popup#include <GuiConstantsEx.au3> #include <GDIPlus.au3> #include <ScreenCapture.au3> _Main() Func _Main() Local $hGUI, $hBMP, $hBitmap, $hGraphic ; Capture upper left corner of screen $hBMP = _ScreenCapture_Capture ("", 0, 0, 400, 300) ; Create GUI $hGUI = GUICreate("GDI+", 400, 300) $Pic = GUICtrlCreatePic("",0,0,400,300) GUISetState() ; Initialize GDI+ library _GDIPlus_Startup () ; Draw bitmap to GUI $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP ($hBMP) $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($Pic) _GDIPlus_GraphicsDrawImage ($hGraphic, $hBitmap, 0, 0) ; Clean up resources _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_BitmapDispose ($hBitmap) _WinAPI_DeleteObject ($hBMP) ; Shut down GDI+ library _GDIPlus_ShutDown () ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_Main thx guys -------------------------------------------- Found the solution: Func SlideShow_Preview() $hBMP = _ScreenCapture_CaptureWnd("", $SlideGUI) $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) $hBitmap_resized = _GDIPlus_ImageResize($hBitmap, 390, 215) ;GDI+ bitmap $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_resized) ;GDI bitmap _WinAPI_DeleteObject(GUICtrlSendMsg($louvores_bg_rchlbPreview, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hBitmap_resized) _WinAPI_DeleteObject($hHBitmap) EndFunc Edited February 16, 2018 by x_bennY Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now