ssamko Posted January 24, 2016 Share Posted January 24, 2016 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: expandcollapse popup#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 More sharing options...
Danyfirex Posted January 24, 2016 Share Posted January 24, 2016 Hi. something like this. expandcollapse popup#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 ssamko 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
ssamko Posted January 24, 2016 Author Share Posted January 24, 2016 (edited) 7 minutes ago, Danyfirex said: Hi. something like this. expandcollapse popup#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 January 24, 2016 by ssamko Link to comment Share on other sites More sharing options...
ssamko Posted January 24, 2016 Author Share Posted January 24, 2016 got it: _GDIPlus_GraphicsDrawImageRect($hGraphic,$hBitmap,0,0,300,300) thnx for your help ! 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