cookiemonster Posted February 20, 2014 Share Posted February 20, 2014 Ive got two images which accept files being dropped onto them and is then meant to copy the new image to to location in the code and then update the display to show the new image. At the moment if you replace one, it replaces both of them, when they are meant to be seperate so you update one and it only updates that one, if you get what I mean. I understand why the current code wont work as seperate but cant work out how to make it work, I guess i need to essentially say: If (DROPPED IMAGE) = "tempscr" then FileCopy(StringReplace(@GUI_DRAGFILE,@CRLF,""), $loc_logo,1) _SetImage($pic_logo, $loc_logo) ElseIF (DROPPED IMAGE NAME) = "tempscr2 then FileCopy(StringReplace(@GUI_DRAGFILE,@CRLF,""), $loc_logo2,1) SetImage($pic_logo2, $loc_logo2) EndIf but im not sure how to get the file name (just the name not full path) Any ideas people? heres my current code: expandcollapse popup#include <GUIConstantsEx.au3> #include <icons.au3> #Region MainWindow $Main = GUICreate("GUI 1",600,480,-1,-1,-1, $WS_EX_ACCEPTFILES) GUICtrlCreateTab(8, 16, 585, 424) #EndRegion MainWindow #Region ImagesTab GUICtrlCreateTabItem("Image") GUICtrlCreateGroup("Image", 16, 50, 569, 380) GUICtrlCreateGroup("Image 1", 20, 66, 142, 150) $loc_logo = "C:\tempscr.png" $pic_logo = GUICtrlCreatePic('', 26,82,128,128) GUICtrlSetState(-1,$GUI_DROPACCEPTED) _SetImage($pic_logo, $loc_logo) GUICtrlCreateGroup("Image 2", 20, 220, 142, 150) $loc_logo2 = "C:\tempscr2.png" $pic_logo2 = GUICtrlCreatePic('', 26,236,128,128) GUICtrlSetState(-1,$GUI_DROPACCEPTED) _SetImage($pic_logo2, $loc_logo2) #EndRegion ImagesTab GUISetState(@SW_SHOW) while (1) $nMsg=GUIGetMsg() switch $nMsg case $GUI_EVENT_CLOSE Exit case $GUI_EVENT_DROPPED FileCopy(StringReplace(@GUI_DRAGFILE,@CRLF,""), $loc_logo,1) _SetImage($pic_logo, $loc_logo) FileCopy(StringReplace(@GUI_DRAGFILE,@CRLF,""), $loc_logo2,1) SetImage($pic_logo2, $loc_logo2) EndSwitch Wend Link to comment Share on other sites More sharing options...
Solution cookiemonster Posted February 20, 2014 Author Solution Share Posted February 20, 2014 incase anyone ever needs to know the answer I worked it out a way that works for what I need it for expandcollapse popup#include <GUIConstantsEx.au3> #include <icons.au3> #Region MainWindow $Main = GUICreate("GUI 1",600,480,-1,-1,-1, $WS_EX_ACCEPTFILES) GUICtrlCreateTab(8, 16, 585, 424) #EndRegion MainWindow #Region ImagesTab GUICtrlCreateTabItem("Image") GUICtrlCreateGroup("Image", 16, 50, 569, 380) GUICtrlCreateGroup("Image 1", 20, 66, 142, 150) $loc_logo = "C:\tempscr.png" $pic_logo = GUICtrlCreatePic('', 26,82,128,128) GUICtrlSetState(-1,$GUI_DROPACCEPTED) _SetImage($pic_logo, $loc_logo) GUICtrlCreateGroup("Image 2", 20, 220, 142, 150) $loc_logo2 = "C:\tempscr2.png" $pic_logo2 = GUICtrlCreatePic('', 26,236,128,128) GUICtrlSetState(-1,$GUI_DROPACCEPTED) _SetImage($pic_logo2, $loc_logo2) #EndRegion ImagesTab GUISetState(@SW_SHOW) while (1) $nMsg=GUIGetMsg() switch $nMsg case $GUI_EVENT_CLOSE Exit case $GUI_EVENT_DROPPED ImageDrop() EndSwitch Wend Func ImageDrop() $Var_filepath = @GUI_DRAGFILE $var_filename = StringRegExpReplace($Var_filepath, "^.*\\", "") MsgBox(0, "Result", $var_filename) If $var_filename = "logo" Then MsgBox(0, "Result", $var_filename & " : logo") FileCopy(StringReplace(@GUI_DRAGFILE,@CRLF,""), $loc_logo,1) _SetImage($pic_logo2, $loc_logo) ElseIf $var_filename = "logo2" Then MsgBox(0, "Result", $var_filename & " : logo2") FileCopy(StringReplace(@GUI_DRAGFILE,@CRLF,""), $loc_logo2,1) _SetImage($pic_ldpi, $loc_logo2) Else MsgBox(0, "Incorrect Image", "This image is not labelled correctly") EndIf 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