Archive: Change images in nsDialogs


Change images in nsDialogs
I state that I tried to look for some solutions about it in all the afternoon but I failed.
I have to change an image of a nsDialog in runtime. I have a dialog like this:

[ImageNo] IE8 [ProgressBar]
[ImageNo] Microsoft Visual C++ [ProgressBar]
[ImageNo] Adobe [ProgressBar]

If they are not installed in the OS I will show an image and I will install them. After installing IE8 for example I want show another image but I am not able to do it. Can someone help me?
After installing IE8 my dialog should be:

[ImageYes] IE8 [ProgressBar]
[ImageNo] Microsoft Visual C++ [ProgressBar]
[ImageNo] Adobe [ProgressBar]

I hope you understand what I mean.
Thanks in advance


Just use the set image commands from the nsDialogs readme


I tried but I can't get it. Ok I will try. I can't modify a dialog from a section without calling the function. Should I call the function with parameters to show what I want or is there an easiest way? Maybe passing handlers from the stack and then I can set images like I want.

Edit: I tried without success I am not able to understand where I am wrong. I made my creator function showing my dialog. Then I have a section where I install some components but I am not able to update the dialog that I showed and modifying progress bars or images.


Why are you talking about sections? nsDialogs are on custom pages.

You should post the code you already have so we can see what the problem is...


My code is like this http://nsis.sourceforge.net/Docs/nsD....html#step-add nothing more I only made the creator function. I have never used custom pages. Annnd here I attached an example code of what I want to do.


You cannot modify pages in sections. All sections are executed on the instfiles page, so the previous page is gone. You need to create a new page after instfiles.


mmm ok. I will manage the function in a way that shows what I want to spend less parameters as possible. and are dialogs shown the same in silent mode?

Edit: ok they are not shown


I can't find "delete post" -.-''


new question
Is there a way to hide instfiles page and show only nsDialogs to make the user know what is happening?
I mean substitute the instfiles page with a nsDialog practically


Hmm... You could move all the Sections code to functions, then call those in your custom instfiles page.


I tried this


Page custom nsDialogs
Var counter
Var message
Function nsDialogs
nsDialogs::Create 1018
Pop $1
IntOp $counter 0 + 0
start:
Pop $0
${If} $0 == "done"
StrCpy $message "message$counter"
${ElseIf} $0 == ""
StrCpy $message "starting"
${EndIf}
${NSD_CreateLabel} 20 0 25% 12u "$message"
Pop $Label
nsDialogs::Show
IntOp $counter $counter + 1
Push "done"
Goto start
FunctionEnd


This code should be a loop and it is. But to make show different messages I have to press always close button.

Edit: this code should change always the same label with a new one but it seems to have a sintax mistake. This code exit when create for the second time a label I don't know why anyway the meaning I think it's clear. Can it work? Anyway I have to solve the problem to close always the window manually to make a new one appear

You can only show a page once. Because of this, you can only create it once, too. To update a label, use SendMessage with the ${WM_SETTEXT} message.


Yeah you are right and to update an image? As I understood I can't reload an entire dialog. But I can't make ${NSD_SetImage} $Image "path" $ImageHandler to set a new one because I need to close the last one. .-. any "sendImage" command? T.T

Edit: I trawled the .nsh file and I found this:
SendMessage $R0 ${STM_SETIMAGE} ${_IMGTYPE} $0

Could be useful? If yes can you explain me those parameters?


Edit2: ok I made a simple and ignorant copy/paste of this


StrCpy $0 "MyImage.bmp"
System::Call 'user32::LoadImage(i 0, t r0, i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_LOADFROMFILE}) i.s'
Pop $IMAGE
SendMessage $Image ${STM_SETIMAGE} ${IMAGE_BITMAP} $IMAGE

And it work but remain the problem that I have to press close button to show the next dialog. How can I do to solve this problem?

Nothing I have always to close the last dialog to open another one. I have to open a dialog. Execute a program and show another dialog with a modify image. I have to do this process many times. But it seems that when I make nsDialogs::Show the function stop also if I have other code after. >.< I am made I must take a break. Someone has time to make a little example code on how to open a dialog set some images and then change them with some conditions? It will be really helpful


Indeed nsDialogs::Show halts execution of the script until Next or Back is clicked. You need to use a callback function, such as nsD_OnClick.


I think I don't follow you. How can I use a callback function in this case? I don't want to stress but I can't understand. I am working with nsis since one month but it's a really big "world". Anyway if you are so patient to explain me I am grateful to you. Anyway I will try to do it by myself.... ^^


Callback functions are NSIS functions that get called when something special happens. nsDialogs can call callbacks for specific events, for example the onclick event. The only way to execute NSIS code while nsDialogs is waiting for the Next or Back button to be clicked, is to use a callback function.


ok... You say to set on .OnClick function (when I press install) my nsis code and then refresh my dialog when I need it?:|


This will not work. NSIS code (except in Sections) runs under the same thread as the UI. Therefore the UI will not update until your callback function has returned (i.e. it will become unresponsive). The only thing you can do is add an image on the InstFiles page with Resource Hacker.

Stu


Ok stu. Tomorrow morning I will look for an "escamotage". Maybe a little patch. Or something else. Anyway thanks for the patience again =P.


mmmmm...

Originally posted by bennaloz
Ok stu. Tomorrow morning I will look for an "escamotage". Maybe a little patch. Or something else. Anyway thanks for the patience again =P
I was thinking about what I can do to solve this issue. Is there a way to say to a dialog to close itself so I can open another one? Any idea to achieve my goal. The perfect thing is to eliminate the wait after nsDialogs::show I think. But I have no idea how to do it.

I solved my problem. I make the main setup run in silent mode comunicate with a secondary setup that only shows Dialogs according to parameters that I send. Every time I need a new dialog I will kill the last process and will execute a new one with new parameters. It seems to work. Maybe it's not the best solution but it's better than nothing