XavierSLN Posted July 3, 2021 Share Posted July 3, 2021 Hey Guys, It's my first topic and my english is pretty bad. Usually I just read and never had a reason to create an Account, but this time I can't solve the problem by simply googling it. Excuse my bad english. Is there a way to put a png picture [always on top!] so that I'm able to work below it (drawning) with my mouse/drawingprogram? I've tried to come up with a solution myself but frankly: I have no Idea how to do it. And it's also important that I can determine the coordinates where the picture is placed and that it keeps being transparant, and preferably (but not neccesarly) borderless. It would be of great help. Thanks in advance and sorry for giving you a headache reading through this mess. Xavier Link to comment Share on other sites More sharing options...
Solution Shark007 Posted July 3, 2021 Solution Share Posted July 3, 2021 Try to make this work for yourself. #AutoIt3Wrapper_Res_File_Add="logo\shark.png", RT_RCDATA, shark, 0 #include <ResourcesEx.au3> Global $Pic = GUICtrlCreatePic('', -1, -1) ; logo _Resource_SetToCtrlID($Pic, 'shark') GUICtrlSetPos($Pic, 205, 70, 140, 140) https://www.autoitscript.com/forum/topic/162499-resourcesex-udf/ XavierSLN 1 Link to comment Share on other sites More sharing options...
Gianni Posted July 3, 2021 Share Posted July 3, 2021 this is ready to use expandcollapse popup#include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> ; #include <WinAPISysWin.au3> #include <WinAPI.au3> Global $sFileImage = @TempDir & "\Leopard.png" If Not FileExists($sFileImage) Then InetGet("http://www.pngall.com/wp-content/uploads/2/Sitting-Leopard-Transparent.png", $sFileImage) $h = _SetImage(100, 100, $sFileImage) MsgBox(0, '', "You can drag the image around" & @CRLF & "hit OK to end") ; FileDelete($sFileImage) Func _SetImage($Left, $Top, $Picture, $iOpacity = 255) _GDIPlus_Startup() Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend Local $hImage = _GDIPlus_ImageLoadFromFile($Picture) Local $iWidth = _GDIPlus_ImageGetWidth($hImage) Local $iHeight = _GDIPlus_ImageGetHeight($hImage) Local $hGUI = GUICreate('', $iWidth, $iHeight, $Left, $Top, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) Local $hLabel = GUICtrlCreateLabel('', 0, 0, $iWidth, $iHeight, -1, $GUI_WS_EX_PARENTDRAG) GUISetState(@SW_SHOW, $hGUI) $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $iWidth) DllStructSetData($tSize, "Y", $iHeight) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) _GDIPlus_Shutdown() Return $hGUI EndFunc ;==>_SetImage XavierSLN 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Shark007 Posted July 4, 2021 Share Posted July 4, 2021 @Chimp, thanks for posting that. I was about to go searching for that very solution because my posted scenario fails with the current AutoIt BETA and switching to the GDIPlus way of presenting a transparent graphic seems more foolproof (to me). XavierSLN 1 Link to comment Share on other sites More sharing options...
XavierSLN Posted July 4, 2021 Author Share Posted July 4, 2021 Just in case anyone was searching for a similiar problem, here is how I got it running. #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> ; #include <WinAPISysWin.au3> #include <WinAPI.au3> HotKeySet ("{ESC}", "_Exit") Global $sFileImage = "Picture" ;Picture is in the same folder as the au3 $h = _SetImage(100, 100, $sFileImage) Func _SetImage($Left, $Top, $Picture, $iOpacity = 255) _GDIPlus_Startup() Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend Local $hImage = _GDIPlus_ImageLoadFromFile($Picture) Local $iWidth = _GDIPlus_ImageGetWidth($hImage) Local $iHeight = _GDIPlus_ImageGetHeight($hImage) Local $hGUI = GUICreate('', $iWidth, $iHeight, $Left, $Top, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) Local $hLabel = GUICtrlCreateLabel('', 0, 0, $iWidth, $iHeight, -1, $GUI_WS_EX_PARENTDRAG) GUISetState(@SW_SHOW, $hGUI) $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $iWidth) DllStructSetData($tSize, "Y", $iHeight) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) _GDIPlus_Shutdown() Return $hGUI EndFunc ;==>_SetImage ToolTip("You can drag the image around" & @CRLF & "Press [ESC] to Exit", 1500, 20) While 1 ;Loop (otherwise the Programm will be exited automatically, because nothing to do) WEnd Func _Exit() _GDIPlus_Shutdown() Exit EndFunc 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