Loading a external image - Printable Version -Shoutbox (https://shoutbox.menthix.net) +-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58) +--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4) +---- Forum: Scripting (/forumdisplay.php?fid=39) +----- Thread: Loading a external image (/showthread.php?tid=72225) Loading a external image by Yorick on 03-01-2007 at 05:00 PM
Hello, RE: Loading a external image by Matti on 03-01-2007 at 05:24 PM First you should download the file to a temporany location, which you can do with the new MsgPlus.DownloadFile function. Then, you can use PlusWnd.ImageElmt_SetImageFile to change the image displayed. Don't forget to delete your file afterwards! RE: Loading a external image by matty on 03-01-2007 at 06:03 PM
quote:However when you are setting the Image from a location that is not in your Scripts folder you need to prefix the path with a \. For instance if you saved your image to C:\Temp and it was called myimage.jpg the code would be: code: RE: Loading a external image by Yorick on 03-02-2007 at 06:53 PM
Thanks a lot guys! code: And then you have to use the OnEvent_DownloadFileComplete(), but how do I append the image to the above made window? How can I get the WndProfileInformation window in the OnEvent_DownloadFileComplete function? code: RE: Loading a external image by CookieRevised on 03-02-2007 at 07:01 PM
Each and every variable in a script needs to be declared somewhere. This is done using the var statement. code: If you declare a variable inside a function, it is a local variable. The variable will only exist as long as the function runs. When the function ends, the variable will not exist anymore. eg: code: If you declare a variable in the main scope of the script, thus outside any functions, it is a global variable. The variable will exist as long as the script is running and thus can be used from anywhere in the script, including from inside funtcions... eg: code: Short answer: declare WndProfileInformation as a global variable. RE: Loading a external image by Yorick on 03-02-2007 at 07:04 PM
At the top of the script I have code: Is this not enough? So in the function I only use code: But for some reason I can't use it in the download function... EDIT: Made a mistake in the function name... It works quit good now, but I use the following code now: code: But It doesn't show it in the element, but there does change something. The default image is removed, but the new image is not shown... Do I have to do anything with the OutFile path? Maybe add some slashes... EDIT2: Missed Marty's post, just had to add to slashes before the path, it works great now! Thanks guys ! RE: Loading a external image by Matti on 03-02-2007 at 07:23 PM
quote:And this should be done when you create the window, like in: code:The difference here is the missing "var" prefix, without it it'll get declared as a global variable. Note: when the window is destroyed, you should delete the variable too! RE: Loading a external image by Yorick on 03-02-2007 at 07:32 PM
I don't know if I need to open a new topic about this, please say if I need to! RE: RE: Loading a external image by CookieRevised on 03-02-2007 at 09:13 PM
quote:Personally I would not recommend declaring variables like that. It is bad practice and prone to errors/bugs if you're not carefull. Always use var and always declare your global variables outside functions first. quote:we need far more information to answer this question properly as there are billions of things which you can mean or want to do. With the information given all I can say is if you don't have the info then don't display it and use a description prefix. eg: Profile Name: John Country: Age: 25 EDIT: after seeing your other thread, I understand what you mean. hint: always provide enough details from the start PS: a control is in that context always static... no control moves around on their own. Static means 'user can not interact with it' (eg: a text label), opposed to dynamic which is changeable by the user (eg: a combobox). Thus it doesn't have anything todo with moving. Anyways, Or you could simply move controls, but this will require the use of Windows APIs. This is possible, but certainly not elegant for this purpose. Or you could instead of making 3 static labels, just make 1 static label and fill it with a string which is a concatenation from the individual variables seperated with a newline character (\n). eg: code:PS: Also notice what I've done with the age. That line adds either "years" or "year" according to what the age is (if age is 1 it will add "year"; thus without the s). (Age == 1 ? " year" : " years") is called a ternary operation. It is in fact an IF THEN ELSE but written as a single statement on one line. The shown ternary operation is the same as if you would write: code: RE: RE: RE: Loading a external image by Eljay on 03-02-2007 at 09:23 PM
quote: I think he was referring to removing the var from the statement inside the function so instead of creating a local variable, it would set the already existing global variable. |