guinness 1,541 Posted April 22, 2014 Share Posted April 22, 2014 I know UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to post Share on other sites
Synix 3 Posted July 2, 2014 Share Posted July 2, 2014 (edited) Please correct me if I forgot something Zedna, but I think this change fixes a potential memory leak without breaking anything: Add the following line inside _ResourceSetImageToCtrl() above "_GDIPlus_BitmapDispose($pBitmap)" _WinAPI_DeleteObject($hBitmap) In my tests running a loop loading constantly .pngs into a control this worked flawlessly, closing the big memory leak I just mentioned. Ah and by the way, the newest stable AutoIt version did some minor change to the GDIPlus.au3 UDF which needs to be adapted inside resources.au3: $ghGDIPDll is now called $__g_hGDIPDll And I want to thank you for this great UDF, I really appreciate it and would love to see an improved version without all the known limitations. I don't know if it'd possible for your whole UDF, but my thoughts for further improvements would be: - Passing handles via ByRef parameters to release resources manually later (=> ResourceGet) - Call _GDIPlus_Startup() and _GDIPlus_ShutDown() at the top and bottom of every function? I'm no expert by any means, so forgive me if these suggestions are maybe dumb ^^ Edited July 2, 2014 by Synix Link to post Share on other sites
guinness 1,541 Posted July 2, 2014 Share Posted July 2, 2014 (edited) I agree it's time this UDF be updated for those of us who use the latest version of AutoIt. I am looking at improvements tonight and tomorrow. Edited July 2, 2014 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to post Share on other sites
Zedna 375 Posted July 3, 2014 Author Share Posted July 3, 2014 Ah and by the way, the newest stable AutoIt version did some minor change to the GDIPlus.au3 UDF which needs to be adapted inside resources.au3: $ghGDIPDll is now called $__g_hGDIPDll - Passing handles via ByRef parameters to release resources manually later (=> ResourceGet) - Call _GDIPlus_Startup() and _GDIPlus_ShutDown() at the top and bottom of every function? I use AutoIt 3.2.12.1/3.3.7.23 so I'm happy with this resources UDF in this way (later changes in GDIPlus) Anyway I agree that majority of AutoIters probably use latest AutoIt. As about other proposals I considered it at begining of creation of my UDF (years ago) and I decided to do it the way it's now for the best simplicity. Originally I had plans for improvements and I even collected some proposals from posts in that topic but as I said later my situation changed and I have no time/priority for changes of this my Resources UDF currently. For me and my projects it's working fine. Sorry for bad news :-( Anyway anybody feel free to copy/modify/post your changed versions of this my Resources UDF. Synix 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to post Share on other sites
Zedna 375 Posted July 3, 2014 Author Share Posted July 3, 2014 (edited) Just for the reference. Here is my Resources UDF updated as ResourcesEx UDF by guinness compatible with latest AutoIt. '?do=embed' frameborder='0' data-embedContent>> Edited July 3, 2014 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to post Share on other sites
Zedna 375 Posted July 15, 2014 Author Share Posted July 15, 2014 Somewhere on the forum (maybe in this topic) was mentioned this kind of problem with resizing of images in AutoIt's picture control and as far as I can roughly remember there was also some clever solution using some control's style applied to picture control so it was doing resizing of image to size of picture control correctly/automatically. I can't remember neither exact solution nor exact topic/post so try to search this topic/forum ... It is style SS_REALSIZECONTROL, SS_REALSIZEIMAGE accordimg to MSDN description http://msdn.microsoft.com/en-us/library/windows/desktop/bb760773%28v=vs.85%29.aspx Resources UDF ResourcesEx UDF AutoIt Forum Search Link to post Share on other sites
marko001 2 Posted August 26, 2014 Share Posted August 26, 2014 Is it possible to use embedded images (.bmp) and send them to a Listview through command _GUIImageList_AddBitmap? At the moment I use: If FileExists($site & $Images_site & $i & ".bmp") Then _GUIImageList_AddBitmap($hImage, $SiteFolder & $i & ".bmp") Else _GUIImageList_AddBitmap($hImage, $SiteFolder & "error.bmp") EndIf Thanks, Marco Link to post Share on other sites
Zedna 375 Posted August 27, 2014 Author Share Posted August 27, 2014 (edited) Is it possible to use embedded images (.bmp) and send them to a Listview through command _GUIImageList_AddBitmap? Yes it's possible and simple. Just use _GUIImageList_Add() instead of _GUIImageList_AddBitmap() In _GUIImageList_Add() there is parameter handle to bitmap which you can get by _ResourceGet(). _ResourceGet() returns directly hBitmap for RT_BITMAP type of resources. Edited August 27, 2014 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to post Share on other sites
sean5470 3 Posted April 16, 2015 Share Posted April 16, 2015 Hey there. I realize this is a rather old thread, however I've made great use of your resources.au3 file. I have an issue that I am not proficient enough to figure out, so I seek your guidance, Earlier today I updated to AutotIT 3.3.12.0 I was anticipating a simple plugin and go. The powers that be had other plans I think, LOL After updating, even when I compile a previous script that was previously compilable, it giving me an error in the resource include.screen shot That is the only error it's giving me and it's a new one to me. I've not modified my original script in any way since updating AutoIT, yet for some reason, it's giving this error now. I use the include mostly for utilizing rt_rcdata .png files that I use as button and background pictures. Any help you may offer regarding this, or if you need more information, please don't hesitate to ask me. I'd be most grateful if you can find a moment to investigate this issue as I love what the include offers. Temporarily, since I need to compile some scripts from previous, I am going to reinstall the previous AutoIT. Though I'd prefer long term to have it up to date. Sincerely, Sean. here's some snippets of all the includes in a script, one of the func and how I've written my code that worked previously: Like I mentioned, the script as a whole, as is, compiled fine prior to updating AutoIT today. #AutoIt3Wrapper_Res_File_Add=Z:\Documents\AutoIt Scripts\MyMods\TTR_Scripts\ModLoader\pictures\updated\Return.png, rt_rcdata, Return_btn ;~-------- File Includes. -------- #include <GUIConstantsEx.au3> #include <GUIHyperLink.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <File.au3> #include <FileConstants.au3> #include <Array.au3> #include <FTPEx.au3> #include <resources.au3> #include <GuiButton.au3> #include <ListViewConstants.au3> #include <TabConstants.au3> Func Return_BTN() ; ------------ RePack Button ------------------------------------ $Return_Button = GUICtrlCreateButton("Return", 130, 10, 50, 20, BitOR($WS_EX_LAYERED, $BS_BITMAP)) _ResourceSetImageToCtrl($Return_Button, "Return_btn", $rt_rcdata ) GUICtrlSetOnEvent($Return_Button, "ShowMainGUI") GUICtrlSetState($Return_Button, $GUI_NOFOCUS) EndFunc Link to post Share on other sites
guinness 1,541 Posted April 16, 2015 Share Posted April 16, 2015 It's because we changed that global variable in later editions. Look at ResourcesEx UDF in my signature. This is intended to work with later versions of AutoIt. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to post Share on other sites
sean5470 3 Posted April 16, 2015 Share Posted April 16, 2015 (edited) I shall do that then. Thank you so much for your reply! Sean -------------------------------------------- Update: Thanks a bunch Guinness! the ResourcesEX worked like a charm! Much appreciated. Sean Edited April 16, 2015 by sean5470 Link to post Share on other sites
guinness 1,541 Posted April 16, 2015 Share Posted April 16, 2015 I shall do that then. Thank you so much for your reply! Sean -------------------------------------------- Update: Thanks a bunch Guinness! the ResourcesEX worked like a charm! Much appreciated. Sean No problems. Read the differences as alot has changed between these versions. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to post Share on other sites
Zedna 375 Posted April 16, 2015 Author Share Posted April 16, 2015 (edited) As guinness said my Resources UDF is compatible with older AutoIt's version. If you need to use it in new version of AutoIt 3.3.12.0 and above then you have to replace in resources.au3 $ghGDIPDll --> $__g_hGDIPDll There are 2 occurencies of it in my UDF. After this correction it will work also in new AutoIt 3.3.12.0+ Here is my resources UDF with this correction compatible with latest AutoIt 3.3.12.0+ resources.au3 But I stopped improving my original Resources UDF so guinness have made copy of it named ResourcesEx which is compatible with latest AutoIt and also with another changes and improvements so you may use either my fixed original UDF (attached in this post) or guinness's new UDF. Link to both of them is also in my signature Edited April 16, 2015 by Zedna pixelsearch 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to post Share on other sites
sean5470 3 Posted April 16, 2015 Share Posted April 16, 2015 As guinness said my Resources UDF is compatible with older AutoIt's version. If you need to use it in new version of AutoIt 3.3.12.0 and above then you have to replace in resources.au3 $ghGDIPDll --> $__g_hGDIPDll There are 2 occurencies of it in my UDF. After this correction it will work also in new AutoIt 3.3.12.0+ Here is my resources with this correction compatible with latest AutoIt 3.3.12.0+ resources.au3 But I stopped improving my original Resources UDF so guinness have made copy of it named ResourcesEx which is compatible with latest AutoIt and also with another changes and improvements so you may use either my fixed original (attached in this post) or guinness's new UDF. Link to both of them is also in my signature Oh awesome! yes, I have already downloaded Guinness's version and it worked like a champ. However, I really appreciated the info and link to a compatible version of yours as well. This will save me the hassle of modifying many of my old scripts now. I thank you for the reply and for your time. Sincerely, Sean Link to post Share on other sites
qwert 49 Posted April 16, 2015 Share Posted April 16, 2015 I've been trying to follow the suggestions in this thread to use Resources (or ResourcesEX) to embed PNGs in scripts as a resource. After several tries, I keep falling short of a workable end result. I've gotten a PNG to display on a normal background, but not in the context that I need: a draggable PNG with a transparent background. For reference, here's an example of my results based on FileInstall(). expandcollapse popup; ; Modified script to demonstrate dragging a Torus.png ; #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global Const $SC_DRAGMOVE = 0xF012 Global $GUI, $eenmaalexit = True FileInstall("c:\AutoIt3\Examples\GUI\Torus.png", @ScriptDir & "\Torus.png") _GDIPlus_Startup() $GUI = GUICreate("", 198, 210, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUICtrlSetState(-1, $GUI_DISABLE) $Label = GUICtrlCreateLabel("", 0, 0, 120, 120, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetTip(-1, "Click and hold to drag" & @CRLF & "... ESC to close") $iLoad = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Torus.png") $hGraphic = _GDIPlus_ImageGetGraphicsContext($iLoad) _SetBitmap($GUI, $iLoad, 255, _GDIPlus_ImageGetWidth($iLoad), _GDIPlus_ImageGetHeight($iLoad)) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($iLoad) GUISetState(@SW_SHOW, $GUI) GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") GUISetOnEvent($GUI_EVENT_CLOSE, "_Dragwindow") While 1 Sleep(50) WEnd Func _Exit() _GDIPlus_Shutdown() Exit EndFunc Func _Dragwindow() Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE _Exit() EndSwitch EndFunc Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($GUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Func _SetBitmap($hGUI, $hImage, $iOpacity, $n_width, $n_height) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $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", $n_width) DllStructSetData($tSize, "Y", $n_height) $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) EndFunc ;==>_SetBitmap Would one of you mind showing the equivalent based on an embedded Torus.PNG? (and replacing _SetBitmap(), if that's possible) Link to post Share on other sites
UEZ 1,433 Posted April 16, 2015 Share Posted April 16, 2015 Try this:expandcollapse popup; ; Modified script to demonstrate dragging a Torus.png ; #AutoIt3Wrapper_Res_File_Add="c:\Program Files (x86)\AutoIt3\Examples\GUI\Torus.png", RT_RCDATA, PNG_1, 0 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "ResourcesEx.au3" Opt("GUIOnEventMode", 1) Global Const $SC_DRAGMOVE = 0xF012 Global $GUI, $eenmaalexit = True ;~ FileInstall("c:\AutoIt3\Examples\GUI\Torus.png", @ScriptDir & "\Torus.png") $GUI = GUICreate("", 198, 210, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUICtrlSetState(-1, $GUI_DISABLE) $Label = GUICtrlCreateLabel("", 0, 0, 120, 120, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetTip(-1, "Click and hold to drag" & @CRLF & "... ESC to close") $iLoad = _Resource_GetAsBitmap("PNG_1") Global $tDim = DllStructCreate($tagBITMAP) DllCall('gdi32.dll', 'int', 'GetObject', 'int', $iLoad, 'int', DllStructGetSize($tDim), 'ptr', DllStructGetPtr($tDim)) _SetBitmap($GUI, $iLoad, 255, $tDim.bmWidth, $tDim.bmHeight) GUISetState(@SW_SHOW, $GUI) GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") GUISetOnEvent($GUI_EVENT_CLOSE, "_Dragwindow") While 1 Sleep(50) WEnd Func _Exit() _WinAPI_DeleteObject($iLoad) Exit EndFunc Func _Dragwindow() Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE _Exit() EndSwitch EndFunc Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($GUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Func _SetBitmap($hGUI, $hBitmap, $iOpacity, $n_width, $n_height) Local $hScrDC, $hMemDC, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $n_width) DllStructSetData($tSize, "Y", $n_height) $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) EndFunc ;==>_SetBitmap You need ResourcesEx.au3! Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to post Share on other sites
qwert 49 Posted April 17, 2015 Share Posted April 17, 2015 Thank you! That works perfectly ... but just to make sure I understand, can you confirm that the $tDim structure is released automatically upon Exit (unlike the object $iLoad). Also, can the $iLoad object be released immediately after the _SetBitmap()? ... or does it have to exist while the bitmap is on the screen? These are subtle points, but I'd like to know them since I know so little about how Dll structures operate. Link to post Share on other sites
UEZ 1,433 Posted April 17, 2015 Share Posted April 17, 2015 Thank you! That works perfectly ... but just to make sure I understand, can you confirm that the $tDim structure is released automatically upon Exit (unlike the object $iLoad). Also, can the $iLoad object be released immediately after the _SetBitmap()? ... or does it have to exist while the bitmap is on the screen? These are subtle points, but I'd like to know them since I know so little about how Dll structures operate.The struct reserves a portion in memory and it will released automatically when your script closes.You can use _WinAPI_DeleteObject($iLoad) just after _SetBitmap. I don't know whether releasing the $iLoad resource after _SetBitmap will work on WinXP or when Aero is disabled. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to post Share on other sites
qwert 49 Posted April 17, 2015 Share Posted April 17, 2015 Based on what you've said, I'll try deleting $iLoad after use. One of my scripts can have several copies running, each with an image in the 1 megabyte range. I'm "old school" in that I like to conserve resources where I can. I appreciate your help. Link to post Share on other sites
Zedna 375 Posted April 17, 2015 Author Share Posted April 17, 2015 (edited) @qwert and others Please create your own topic in "General help" section of this forum and here in my topic make only posts/questions relevant to my Resources UDF! Edited April 17, 2015 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to post Share on other sites
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