no more /UNLOAD with new plug-in api

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5844 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2008-12-12 19:31:52 +00:00
parent 06ab0c6314
commit 3db2839a3c
9 changed files with 65 additions and 36 deletions

View file

@ -8,7 +8,7 @@
g_stringsize=string_size; \
g_stacktop=stacktop; }
#define NSISFunc(name) extern "C" void __declspec(dllexport) name(HWND hwndParent, int string_size, char *variables, stack_t **stacktop)
#define NSISFunc(name) extern "C" void __declspec(dllexport) name(HWND hwndParent, int string_size, char *variables, stack_t **stacktop, extra_parameters *extra)
char szTemp[2048];
HWND hWndImage, hWndParent;
@ -61,11 +61,24 @@ HBITMAP __stdcall LoadBitmapFile(long right, long bottom, BITMAP *bBitmap);
COLORREF GetColor();
void __stdcall GetXY(LPPOINT lpPoint);
NSISFunc(Destroy);
static UINT_PTR PluginCallback(enum NSPIM msg)
{
if (msg == NSPIM_GUIUNLOAD)
{
Destroy(0, 0, 0, 0, 0);
}
return 0;
}
BOOL bReturn;
NSISFunc(SetReturn) {
EXDLL_INIT();
extra->RegisterPluginCallback(g_hInstance, PluginCallback);
popstring(szTemp);
bReturn = !lstrcmpi(szTemp, "on");
}
@ -83,6 +96,8 @@ static void __stdcall my_pushstring(char *str)
NSISFunc(SetBg) {
EXDLL_INIT();
extra->RegisterPluginCallback(g_hInstance, PluginCallback);
ECS();
if (!hWndImage) {
@ -335,7 +350,7 @@ NSISFunc(Destroy) {
SendMessage(hWndImage, WM_CLOSE, 0, 0);
hWndImage = 0;
oldProc = NULL;
Clear(0, 0, 0, 0);
Clear(0, 0, 0, 0, 0);
UnregisterClass("NSISBGImage", g_hInstance);
}

View file

@ -20,15 +20,10 @@ Usage
Notes
~~~~~
* All but the last used function (which should be Destroy) must use /NOUNLOAD so the image window won't be destroyed before it should.
* This plugin requires NSIS 2.0b4 and above.
* This plugin requires NSIS 2.42 and above.
* Do not call SetBg (which creates the window) from a section or a function called by a section.
* Never use /NOUNLOAD in .onInstSuccess and .onInstFailed. Failing to do so will cause the installer to crash.
This means you should not call Destroy from .onInstSuccess or .onInstFailed.
Available functions
~~~~~~~~~~~~~~

View file

@ -22,32 +22,32 @@ Function .onGUIInit
!ifdef DEBUG
# turn return values on if in debug mode
BgImage::SetReturn /NOUNLOAD on
BgImage::SetReturn on
!endif
# set the initial background for images to be drawn on
# we will use a gradient from drak green to dark red
BgImage::SetBg /NOUNLOAD /GRADIENT 0 0x80 0 0x80 0 0
BgImage::SetBg /GRADIENT 0 0x80 0 0x80 0 0
!insertmacro GetReturnValue
# add an image @ (150,0)
BgImage::AddImage /NOUNLOAD $PLUGINSDIR\2.bmp 150 0
BgImage::AddImage $PLUGINSDIR\2.bmp 150 0
!insertmacro GetReturnValue
# add the same image only transparent (magenta wiped) @ (150,16)
BgImage::AddImage /NOUNLOAD /TRANSPARENT 255 0 255 $PLUGINSDIR\2.bmp 150 16
BgImage::AddImage /TRANSPARENT 255 0 255 $PLUGINSDIR\2.bmp 150 16
!insertmacro GetReturnValue
# create the font for the following text
CreateFont $R0 "Comic Sans MS" 50 700
# add a blue shadow for the text
BgImage::AddText /NOUNLOAD "Testing 1... 2... 3..." $R0 0 0 255 48 48 798 198
BgImage::AddText "Testing 1... 2... 3..." $R0 0 0 255 48 48 798 198
!insertmacro GetReturnValue
# add a green shadow for the text
BgImage::AddText /NOUNLOAD "Testing 1... 2... 3..." $R0 0 255 0 52 52 802 202
BgImage::AddText "Testing 1... 2... 3..." $R0 0 255 0 52 52 802 202
!insertmacro GetReturnValue
# add the text
BgImage::AddText /NOUNLOAD "Testing 1... 2... 3..." $R0 255 0 0 50 50 800 200
BgImage::AddText "Testing 1... 2... 3..." $R0 255 0 0 50 50 800 200
!insertmacro GetReturnValue
# show our creation to the world!
BgImage::Redraw /NOUNLOAD
BgImage::Redraw
# Refresh doesn't return any value
FunctionEnd
@ -60,7 +60,7 @@ Section
StrCmp $0 "" skipSound
moreSounds:
StrCmp $1 "" noMoreSounds
BgImage::Sound /NOUNLOAD /WAIT $WINDIR\Media\$1
BgImage::Sound /WAIT $WINDIR\Media\$1
# Sound doesn't return any value either
MessageBox MB_YESNO "Another sound?" IDNO noMoreSounds
FindNext $0 $1
@ -71,32 +71,30 @@ Section
skipSound:
# change the background image to Mike, tiled
BgImage::SetBg /NOUNLOAD /TILED $PLUGINSDIR\1.bmp
BgImage::SetBg /TILED $PLUGINSDIR\1.bmp
!insertmacro GetReturnValue
# we have to redraw to reflect the changes
BgImage::Redraw /NOUNLOAD
BgImage::Redraw
MessageBox MB_OK "Mike the llama"
# clear everything
BgImage::Clear /NOUNLOAD
BgImage::Clear
# Clear doesn't return any value
# set another gradient
BgImage::SetBg /NOUNLOAD /GRADIENT 0xFF 0xFA 0xBA 0xAA 0xA5 0x65
BgImage::SetBg /GRADIENT 0xFF 0xFA 0xBA 0xAA 0xA5 0x65
!insertmacro GetReturnValue
# add some text
BgImage::AddText /NOUNLOAD "A Desert for Mike" $R0 0 0 0 50 50 800 150
BgImage::AddText "A Desert for Mike" $R0 0 0 0 50 50 800 150
!insertmacro GetReturnValue
# add mike as an image
BgImage::AddImage /NOUNLOAD $PLUGINSDIR\1.bmp 50 150
BgImage::AddImage $PLUGINSDIR\1.bmp 50 150
!insertmacro GetReturnValue
# again, we have to call redraw to reflect changes
BgImage::Redraw /NOUNLOAD
BgImage::Redraw
SectionEnd
Function .onGUIEnd
# Destroy must not have /NOUNLOAD so NSIS will be able to unload
# and delete BgImage before it exits
BgImage::Destroy
# Destroy doesn't return any value
FunctionEnd