Jump to content
Sign in to follow this  

Save screenshot in memory and put it in a control

Recommended Posts

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:


#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <ScreenCapture.au3>


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)


    ; 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
    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))














Edited by x_bennY

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...