wraithdu Posted November 23, 2010 Share Posted November 23, 2010 Does anyone else think this is a bug? The example is self explanatory. #include <ScreenCapture.au3> $file = @DesktopDir & "\capture.jpg" $file2 = @DesktopDir & "\capture2.jpg" _ScreenCapture_Capture($file, 0, 0, 640, 480) _ScreenCapture_Capture($file2, 400, 0, 1040, 480) GUICreate("", 400, 300) $pic = GUICtrlCreatePic($file, 10, 40, 320, 240) $status = GUICtrlCreateLabel("The original 640x480 image fit to 320x240...", 10, 10, 380) GUISetState() Sleep(3000) GUICtrlSetData($status, "Change the image, still 320x240...") GUICtrlSetImage($pic, $file2) Sleep(3000) GUICtrlSetData($status, "Blank the control via GUICtrlSetImage($pic, """")...") GUICtrlSetImage($pic, "") Sleep(3000) GUICtrlSetData($status, "Set the image again, but now the control forgot its size.") GUICtrlSetImage($pic, $file) Sleep(3000) FileDelete($file) FileDelete($file2) Link to comment Share on other sites More sharing options...
UEZ Posted November 23, 2010 Share Posted November 23, 2010 I don't know whether this is a bug or a feature but after GUICtrlSetImage($pic, "") the settings for $pic will be reset. One workaround: ... GUICtrlSetImage($pic, "") Sleep(3000) GUICtrlSetData($status, "Set the image again, but now the control forgot its size.") $pic = GUICtrlCreatePic($file, 10, 40, 320, 240) ;workaround is to set $pic again GUICtrlSetImage($pic, $file) 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...
wraithdu Posted November 23, 2010 Author Share Posted November 23, 2010 Except that duplicates the control. You'd have to do a GUICtrlDelete($pic) as well. I've already considered the workarounds. In the app where I first ran into this, I just created a transparent png that I used instead of GUICtrlSetImage($pic, ""). Link to comment Share on other sites More sharing options...
Yashied Posted November 23, 2010 Share Posted November 23, 2010 I use GUICtrlSetPos() after GUICtrlSetImage($Pic, ""). My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
wraithdu Posted November 23, 2010 Author Share Posted November 23, 2010 (edited) I use GUICtrlSetPos() after GUICtrlSetImage($Pic, ""). I just tried that, didn't work, which was surprising. GUICtrlSetData($status, "Blank the control via GUICtrlSetImage($pic, """")...") GUICtrlSetImage($pic, "") GUICtrlSetPos($pic, 10, 40, 320, 240) Sleep(3000) GUICtrlSetData($status, "Set the image again, but now the control forgot its size.") GUICtrlSetImage($pic, $file) Sleep(3000) Edited November 23, 2010 by wraithdu Link to comment Share on other sites More sharing options...
wraithdu Posted November 29, 2010 Author Share Posted November 29, 2010 Back from the holiday now... So, I don't see a consensus here... is this a bug? If so I'll report it. Maybe not a bug but a designed behavior that might be changed (= feature req)? Link to comment Share on other sites More sharing options...
AndreyS Posted April 23, 2015 Share Posted April 23, 2015 Hello everyone! The theme is very old, but still is not fixed. After properly remove and re-create a permanent control only in order to clean it from the image. Prompt, who knows what there is more correct solutions to the following example: GUICtrlSetImage ($PicPreview, "") GUICtrlSetPos ($PicPreview, 352, 140, 417, 400) ; - this line does not helps! GUICtrlSetStyle ($PicPreview, $WS_BORDER) Thanks! Link to comment Share on other sites More sharing options...
Lecdev Posted June 24, 2015 Share Posted June 24, 2015 I know this actually... by design when you use the set image function whether it be setting an image from a multi image library or a single image file it uses the height and width parameters from the size of the first file it finds for the image size as a separate paramater to the control size for supporting controls that don't initially have an image with a defined size for an image within them like listviewitems etc... so when you blank the image it resets to not having a image size parameter in the control because it no longer has an image and the next time you load the picture it gets the full image size from the file and uses it.there isnt much you can do about it but you've got the delete the control option already plus you could use the following...set a transparent colour and load a dummy rectangle image which is just all that transparent colour to keep the size in play on the control but i think just deleting the control and recreating it is probably a better option so you don't have to include an image in the script.or guictrlsetpos will work if you use it after putting the image back in, not after blanking the control, as the following;GUICtrlSetImage($pic, "")Sleep(3000)GUICtrlSetImage($pic, $file)GUICtrlSetPos ($Pic, 10, 40, 320, 240)you can use a flag to make the size resetting conditional if you know when the control is going to be empty;$flagnone = 0; other codeGUICtrlSetImage($pic, "")$flagnone = 1Sleep(3000)GUICtrlSetImage($pic, $file)If $flagnone Then GUICtrlSetPos($Pic, 10, 40, 320, 240) $flagnone = 0EndIfyou can also do something like this,if fileexists($filex) then GUICtrlSetImage($pic, $filex)or;if filegetsize($filex) > 0 then GUICtrlSetImage($pic, $filex)to just not edit it if you dont know when the file is going to be empty or nonexistentor you can check the control before you update it by using;$Gui = GuiCreate("Test Gui",400,300); other code$controlpos = ControlGetPos($Gui, "", $pic)If IsArray($controlpos) Then If $controlpos[2] <> 320 Or $controlpos[3] <> 240 Then $flagnone = 1EndIfGUICtrlSetImage($pic, $file)If $flagnone Then GUICtrlSetPos($Pic, 10, 40, 320, 240) $flagnone = 0EndIfunfortunately if you use ControlGetPos you still need to do it after the point the control blanks and set the flag not after trying to put the image back in because the control still has its own size of 320x240 defined and will return that if there is an image of any size at all within it.surely that explains it... 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