Archive: Need help with BGImage


Need help with BGImage
The example is fine, but I don't know how to actually utilize this for a script that is NOT an example.

The script snippet I'm using is:

;--------------------------------
;BGIMAGE
Section
# the plugins dir is automatically deleted when the installer exits
InitPluginsDir
File /oname=$PLUGINSDIR\bgimage.bmp "c:\foo\bgimage.bmp"
BgImage::Init /NOUNLOAD /FILLSCREEN $PLUGINSDIR\bgimage.bmp

BgImage::Destroy
SectionEnd
;--------------------------------

Of course, compiling this with a working script does not produce the BGImage. It'd be great if more information were present. Building this from following the instructions exactly in the readme does not work, either.


You should initialize it when you want it to show (.onGUIInit for example) and destroy it when you want to stop showing it (.onInstSuccess/Fail which currently does not work for a very weird and unknown reason - destroy it at the end of the last section, or a hidden section). The example shows it longer than the second it flashes on your screen because it pops a few message boxes that stalls the code execution and thus "avoids" the destroy function for as long as you don't dismiss the message boxes.


Put it in the .onInit function.

edit: that should be .onGUIInit


Don't put it in .onInit. As the readme states:

Do not use in .onInit!

Yeah that's true. I mean not a init & destroy right after each other in a section :D


See... this is the kind of thing that bothers me.
There's no way I would have known any of that information.

The instructions explicitly state:

SetImage [/FILLSCREEN] path_to_bitmap
Sets a new image to the current timage window
Use /FILLSCREEN to make the image fill the screen
Do not use in .onInit!

So, I still don't understand how to get this to work, I'm sorry. I'm sorry I'm expected to understand every little detail about this program! :rolleyes:

So, I'm confused.

The most frustrating thing about this is that there are no real examples. Everyone just showcases their little feature, but only tells 20% of the whole story.


So what do I need to do, explicitly, to get the bgimage to display when they double click the EXE, and to go away when it's finished installing?

I'm looking for actual syntax here.


I give up on this "feature."

Since the instructions put this whole thing into a section, I can't put a function inside a section. Trying to create a function .onGUIInit yields this error:

Error: Function named ".onGUIInit" already exists.
Error in macro MUI_FUNCTIONS_GUIINIT on macroline 6
Error in macro MUI_BASIC on macroline 8
Error in macro MUI_SYSTEM on macroline 16
Error in macro MUI_LANGUAGEFILE_BEGIN on macroline 7
!include: error in script: "C:\Program Files\NSIS\Contrib\Modern UI\Language files\English.nsh" on line 9
Error in macro MUI_LANGUAGE on macroline 6
Error in script "C:\Tolwyn\build\7jg77_current.nsi" on line 87 -- aborting creation process


You should first understand the basics of a NSIS script. What a function, a callback function, a section etc. is. There is a good tutorial in the documentation.


If you are using the Modern UI, you should define a custom function, because the Modern UI inserts this function.

A copy from the documentation:

!define MUI_CUSTOMFUNCTION_ONGUIINIT myGuiInit

Function myGUIInit
...your own code...
FunctionEnd

Thanks, Joost.
That's part of the problem, though.
I do understand the basics of NSIS Script editing. I would say that I have an AVERAGE working knowledge.

I think you may be too close to the documentation to have a real objective eye on how utterly futile some of it is. It takes a concept, and simply just redfines it; or in another way, states what the concept is, not really what it's for, what it does, and how to use it.

It's extremely confusing.


I do understand your problem. But we simply don't have enough time to write more turorials, examples etc. It's already a lot of work to maintain the current documentation.

We are still looking for more people who want to help writing turorials and stuff.


Ok. I did what you said. Toward the top of my script, I have:

!define MUI_CUSTOMFUNCTION_ONGUIINIT myGuiInit

Then I have:
;BGIMAGE
Function myGuiInit
# the plugins dir is automatically deleted when the installer exits
InitPluginsDir
File /oname=$PLUGINSDIR\bgimage.bmp "c:\foo\bgimage.bmp"
BgImage::Init /NOUNLOAD /FILLSCREEN $PLUGINSDIR\bgimage.bmp
FunctionEnd

Then I have:

Function .onInstSuccess
BgImage::Destroy
FunctionEnd
Function .onInstFail
BgImage::Destroy
FunctionEnd

When compiling the script, I get:

2 warnings:
install function "myGuiInit" not referenced - zeroing code (14-23) out

install function ".onInstFail" not referenced - zeroing code (29-33) out



Function .onInstSuccess
BgImage::Destroy
FunctionEnd

Function .onInstFailed
BgImage::Destroy
FunctionEnd


And, did you use the defines BEFORE the MUI_LANGUAGE macro's:?
Modern UI Documentation
Add the defines before the MUI_LANGUAGE macro's.

Yep, should be the order of commands.

The Readme explains the right order. All defines should be before the MUI_LANGUAGE macro's.


(.onInstSuccess/Fail which currently does not work for a very weird and unknown reason - destroy it at the end of the last section, or a hidden section)
Do NOT use it in .onInstSuccess/Failed. Destroy BgImage at the end of the last section as the example does.

Ok. I'll keep hacking (literally) away at it.
I feel I'm closer now. Thanks for all the help and putting up with my exasperation.