Jump to content

Hbitmap draw to picture


ssamko
 Share

Recommended Posts

Hello guys...I have a problem with drawing hbitmap to GUI(GUICtrlCreatePic) .

1) I get hbmp

2)I want to use it like picture in my program(dont ask me why...I just want to use this way) but it doesnt work for me and idk why :/

i used the code from help-file...but I when i wanted to rewrite it to picture-object instead of normal gui it didnt work.

Code from help file: 

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

Example()

Func Example()
    Local $hGUI, $hBMP, $hBitmap, $hGraphic

    ; Capture upper left corner of screen
    $hBMP = _ScreenCapture_Capture("", 0, 0, 800, 600)

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 600)
    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Draw bitmap to GUI
    $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _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 the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example
Exit

and instead of drawing it to main-GUI I want to draw it to picture object(GUICtrlCreatePic) in that GUI

 

 

 

 

Link to comment
Share on other sites

Hi. something like this.

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

Example()

Func Example()
    Local $hGUI, $hBMP, $hBitmap, $hGraphic,$hImagePic

    ; Capture upper left corner of screen
    $hBMP = _ScreenCapture_Capture("", 0, 0, 300, 300)

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 600)
    $hImagePic=GUICtrlCreatePic("",30,30,300,300)

    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Draw bitmap to GUI
    $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($hImagePic))
    _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 the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example
Exit

Saludos

Link to comment
Share on other sites

7 minutes ago, Danyfirex said:

Hi. something like this.

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

Example()

Func Example()
    Local $hGUI, $hBMP, $hBitmap, $hGraphic,$hImagePic

    ; Capture upper left corner of screen
    $hBMP = _ScreenCapture_Capture("", 0, 0, 300, 300)

    ; Create GUI
    $hGUI = GUICreate("GDI+", 800, 600)
    $hImagePic=GUICtrlCreatePic("",30,30,300,300)

    GUISetState(@SW_SHOW)

    ; Initialize GDI+ library
    _GDIPlus_Startup()

    ; Draw bitmap to GUI
    $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($hImagePic))
    _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 the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example
Exit

Saludos

great man...you are my hero ! and 1 more question....when I will take a screen of lets say 800x800 and my picture area is just 300x300 can be that picture only minimalised from 800x800 to 300x300 so as to see whole pic in that 300x300 area? 

I hope you understand....my english level is not very good

Edited by ssamko
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...