NassauSky Posted January 29, 2015 Share Posted January 29, 2015 I'm creating 3 different sized buttons with bitmaps on them from the inet. Any idea why after adding a 2nd Global variable $hHBitmapM to the nice code provided by UEZ ('?do=embed' frameborder='0' data-embedContent>>) the script doesn't run but shows an error in the console: !>11:50:07 AutoIt3.exe ended.rc:-1073741819 #include <GDIplus.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> _GDIPlus_Startup() Global $hHBitmapL = _GDIPlus_BitmapCreateFromMemory(InetRead("http://icons.iconarchive.com/icons/hopstarter/soft-scraps/64/User-Administrator-Blue-icon.png"), 1) Global $hHBitmapM = _GDIPlus_ImageResize($hHBitmapL,25,25) ;Global $hHBitmapM=$hHBitmapL Global $hGUI = GUICreate("Bitmap from inet", 540, 396, -1, -1) GUISetBkColor(0xFFFFFF) Global $iBtnL = GUICtrlCreateButton("", 65, 89, 72, 72, $BS_BITMAP) , $hBtnL = GUICtrlGetHandle($iBtnL) _WinAPI_DeleteObject(_SendMessage($hBtnL, $BM_SETIMAGE, $IMAGE_BITMAP, $hHBitmapL)) Global $iBtnM = GUICtrlCreateButton("", 65, 189, 25, 25, $BS_BITMAP) , $hBtnM = GUICtrlGetHandle($iBtnM) _WinAPI_DeleteObject(_SendMessage($hBtnM, $BM_SETIMAGE, $IMAGE_BITMAP, $hHBitmapM)) GUISetState() Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hHBitmapL) _GDIPlus_Shutdown() GUIDelete() Exit Case $iBtnL MsgBox(0, "Info", "Image in button was downloaded from web and used directly without saving to disk first!") Case $iBtnM MsgBox(0, "Info", "Image in button was downloaded from web and used directly without saving to disk first!") EndSwitch Until False Thanks Link to comment Share on other sites More sharing options...
MikahS Posted January 29, 2015 Share Posted January 29, 2015 This is where your script stops: Global $hHBitmapM = _GDIPlus_ImageResize($hHBitmapL,25,25) Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
mikell Posted January 29, 2015 Share Posted January 29, 2015 #include <GDIplus.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> _GDIPlus_Startup() Global $hHBitmapL = _GDIPlus_BitmapCreateFromMemory(InetRead("http://icons.iconarchive.com/icons/hopstarter/soft-scraps/64/User-Administrator-Blue-icon.png"), 1) $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmapL) $hBitmap2 = _GDIPlus_ImageResize($hBitmap,25,25) Global $hHBitmapM=_GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap2) ;Global $hHBitmapM=$hHBitmapL Global $hGUI = GUICreate("Bitmap from inet", 540, 396, -1, -1) GUISetBkColor(0xFFFFFF) Global $iBtnL = GUICtrlCreateButton("", 65, 89, 72, 72, $BS_BITMAP) , $hBtnL = GUICtrlGetHandle($iBtnL) _WinAPI_DeleteObject(_SendMessage($hBtnL, $BM_SETIMAGE, $IMAGE_BITMAP, $hHBitmapL)) Global $iBtnM = GUICtrlCreateButton("", 65, 189, 25, 25, $BS_BITMAP) , $hBtnM = GUICtrlGetHandle($iBtnM) _WinAPI_DeleteObject(_SendMessage($hBtnM, $BM_SETIMAGE, $IMAGE_BITMAP, $hHBitmapM)) GUISetState() Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hHBitmapL) _GDIPlus_Shutdown() GUIDelete() Exit Case $iBtnL MsgBox(0, "Info", "Image in button was downloaded from web and used directly without saving to disk first!") Case $iBtnM MsgBox(0, "Info", "Image in button was downloaded from web and used directly without saving to disk first!") EndSwitch Until False Link to comment Share on other sites More sharing options...
UEZ Posted January 29, 2015 Share Posted January 29, 2015 See my comments in the code: #include <GDIplus.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> _GDIPlus_Startup() Global $hHBitmapL = _GDIPlus_BitmapCreateFromMemory(InetRead("http://icons.iconarchive.com/icons/hopstarter/soft-scraps/64/User-Administrator-Blue-icon.png"), 1) ;this is a GDI bitmap Global $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmapL) ;convert GDI to GDIPlus bitmap Global $hBitmapM = _GDIPlus_ImageResize($hBmp,25,25) ;this is a GDIPlus bitmap! Global $hHBitmapM = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmapM) ;this is a GDI bitmap Global $hGUI = GUICreate("Bitmap from inet", 540, 396, -1, -1) GUISetBkColor(0xFFFFFF) Global $iBtnL = GUICtrlCreateButton("", 65, 89, 72, 72, $BS_BITMAP) , $hBtnL = GUICtrlGetHandle($iBtnL) _WinAPI_DeleteObject(_SendMessage($hBtnL, $BM_SETIMAGE, $IMAGE_BITMAP, $hHBitmapL)) ;this needs a GDI bitmap!!! Global $iBtnM = GUICtrlCreateButton("", 65, 189, 25, 25, $BS_BITMAP) , $hBtnM = GUICtrlGetHandle($iBtnM) _WinAPI_DeleteObject(_SendMessage($hBtnM, $BM_SETIMAGE, $IMAGE_BITMAP, $hHBitmapM)) ;this needs a GDI bitmap!!! GUISetState() Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GDIPlus_BitmapDispose($hBmp) _GDIPlus_BitmapDispose($hBitmapM) _WinAPI_DeleteObject($hHBitmapM) _WinAPI_DeleteObject($hHBitmapL) _GDIPlus_Shutdown() GUIDelete() Exit Case $iBtnL MsgBox(0, "Info", "Image in button was downloaded from web and used directly without saving to disk first!") Case $iBtnM MsgBox(0, "Info", "Image in button was downloaded from web and used directly without saving to disk first!") EndSwitch Until False Br, UEZ 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 comment Share on other sites More sharing options...
mikell Posted January 29, 2015 Share Posted January 29, 2015 Much cleaner Link to comment Share on other sites More sharing options...
Solution NassauSky Posted January 29, 2015 Author Solution Share Posted January 29, 2015 Thanks Mikell I didn't try out your code yet because I happened to read this after UEZ posted his code. Excellent @UEZ that was nice. .Here is the code again I hope you don't mind I cleaned it up a little to make it more readable. #include <GDIplus.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> _GDIPlus_Startup() Global $GDIbmpLarge = _GDIPlus_BitmapCreateFromMemory(InetRead("http://icons.iconarchive.com/icons/hopstarter/soft-scraps/64/User-Administrator-Blue-icon.png"), 1) ;this is a GDI bitmap Global $GDIplusLarge = _GDIPlus_BitmapCreateFromHBITMAP($GDIbmpLarge) ;convert GDI to GDIPlus bitmap Global $GDIplusMedium = _GDIPlus_ImageResize($GDIplusLarge,25,25) ;this is a GDIPlus bitmap! Global $GDIbmpMedium = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIplusMedium) ;this is a GDI bitmap Global $hGUI = GUICreate("Bitmap from inet", 540, 396, -1, -1) GUISetBkColor(0xFFFFFF) Global $iBtnL = GUICtrlCreateButton("", 65, 89, 72, 72, $BS_BITMAP) , $hBtnL = GUICtrlGetHandle($iBtnL) _WinAPI_DeleteObject(_SendMessage($hBtnL, $BM_SETIMAGE, $IMAGE_BITMAP, $GDIbmpLarge)) ;this needs a GDI bitmap!!! Global $iBtnM = GUICtrlCreateButton("", 65, 189, 25, 25, $BS_BITMAP) , $hBtnM = GUICtrlGetHandle($iBtnM) _WinAPI_DeleteObject(_SendMessage($hBtnM, $BM_SETIMAGE, $IMAGE_BITMAP, $GDIbmpMedium)) ;this needs a GDI bitmap!!! GUISetState() Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GDIPlus_BitmapDispose($GDIplusMedium) _GDIPlus_BitmapDispose($GDIplusLarge) _WinAPI_DeleteObject($GDIbmpMedium) _WinAPI_DeleteObject($GDIbmpLarge) _GDIPlus_Shutdown() GUIDelete() Exit Case $iBtnL MsgBox(0, "Info", "Large Image Downloaded from web and used directly without saving to disk first!") Case $iBtnM MsgBox(0, "Info", "Medium Image Downloaded and converted from web and used directly without saving to disk first!") EndSwitch Until False This code will download an image from the internet and create 2 buttons with the original size (Large) and a smaller resized (Medium) button. Thanks again... Autoit is impressing me so far with things I tried in PHP & C# that just couldn't do what I needed to like this. 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