Archive: progress callback and BgImage


progress callback and BgImage
Hi

This is my first post to the WinAMP/NSIS forums :)

I work for a game company and we've just decide (well, I've just decided) to migrate from InstallShield to NSIS.

The installation I'm working on at the moment is on 2 CDs, so I'm doing a double installer (the first one asks for the language, the second is copied by the first one to the HD and does most of the work, such as the extractions from the 2 CDs)

I need to do billboards (I'm using BgImage) that change regulary during installation (e.g. at 10%, 20%, 30%...) So far what I've done is to separate my files into several zip files that are roughly the same size then I do extract / show BgImage A / extract / show BgImage B and so.

I was wondering of there was any way to link callbacks to the instfiles progression or something, so that I can call a function every 10 percentage points with the progress value and use that function to change the background image. Or is there another better way to do this?


In NSIS 2.03 or above, you can write plug-ins that will be able to execute NSIS code. Creating a plug-in to listen to Windows messages and execute NSIS code accordingly could cause problems because the NSIS code interpreter is not built for multi-threaded execution. However, if you choose your hooking correctly, it shouldn't be a problem. NSIS uses SendMessage to update the progress bar, so no code should be executed while the progress bar is updating.

So, if you create a plug-in that hooks the progress bar and listens to PBM_SETPOS, you should be able to call a callback function in your script to update BgImage.


Hum, long time no code, but I think I actually understood most of that :) Thanks for taking the time to answer.

There's just one point on which I'm not clear :

Originally posted by kichik
In NSIS 2.03 or above, you can write plug-ins that will be able to execute NSIS code.
I had imagined calling the dll with a (script) function name, but basically I don't know which parameters to pass to ExecuteCodeSegment (and more specifically how to translate the function name into ExecuteCodeSegments first parameter). I found it used in \exehead\ui.c and had a look at it in \exehead\exec.c but as I haven't looked at much else in the code I haven't really made any headway making sense of it all.

Originally posted by kichik on mIRC
use 2.04 and extra_parameters parameter
extra->ExecuteCodeSegment(address, 0);
you can get address using GetFunctionAddress in the script, for example.
Script execution is not thread safe, be careful with it.
Thanks, that's exactly what I needed