Archive: Window and Control


Window and Control
Hello everybody,

I create a topic about Windows and Controls because I think it's an important part that is not enough documented.
For exemple, I had difficulties to found information about functions (and their parameters) allowing windows and controls handling (EnableWindow, FindWindow, GetDlgItem, IsWindow, SendMessage, SetCtlColors, ShowWindow).

So I will have many questions about this topic.

________________________________________________________________________________

My first question is :
- Where can I found the id list of the different controls ??

GetDlgItem $0 $HWNDPARENT <id_control>

Here is a macro I use to enable/disable the "next" button:

!macro SetNextButtonEnabled flag
Push $0
GetDlgItem $0 $HWNDPARENT 1
!if ${flag} == 0
EnableWindow $0 0
!else
EnableWindow $0 1
!endif
Pop $0
!macroend


This shows how to use GetDlgItem and EnableWindow, but I can't tell you where you can get the <id_control> from. I just copied it from some example code myself...


Also the docs say that you can get the handle of the "inner" dialog this way:

FindWindow $0 "#32770" "" $HWNDPARENT

Thank you LoRd_MuldeR, I found also different examples on the forum or with the NSIS install.

But I would like to understand at what control correspond the different ids (1028, 1037, 1256, ...). So a complete list, if it exists, will be perfect !!!!!

I have read that there are a list in NSIS/Contrib/UIs/resource.h but I haven't this file in my NSIS install.


Use Resource Hacker and open the UI executable file.

Stu


Originally posted by Corpio
I have read that there are a list in NSIS/Contrib/UIs/resource.h but I haven't this file in my NSIS install. [/B]
That is a source code file. It's a C Header file to be precise. You won't find it in your install, you need to get source codes...

You can also view the file via SVN:
http://nsis.svn.sourceforge.net/view...24&view=markup

Thank you Afrow UK,

I have look this software quickly, I think it can help me.


PS : I may come back on this topic to ask another question about Windows and Controls so see you soon.


Hello,

I have a problem with a STATIC control on a components page allowing me to write the description of the section flied by the user thanks to the .onMouseOverSection callback.

When I want to change the control text, I run this code:

SendMessage $hWndControl ${WM_SETTEXT} 0 "STR:${DESCRIPTION}"

with $hWndControl, the handle to the good destination control


It writes the good text at the good place on the good time but it doesn't erase the previous text. So I have texts overlayed and unreadabled.

Any idea !!!

Thanks.

for a quick hack, hide then show the window, for a real solution; call InvalidateRect or RedrawWindow with the system plugin


I'm sorry Anders but I tested different solution to hide and show the window without results.

Maybe I don't use the good solution !!!!!

Can you help me with little code ??

Thanks.



PS : I tried this code

SendMessage $HWNDPARENT ${MSG} 0 0
SendMessage $HWNDPARENT ${MSG} 1 0

with :
- MSG = WM_ENABLE
- MSG = WM_SHOWWINDOW

I'm not sure if I understand what are you trying to manage,

http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.14.1

http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.14.7


Use ShowWindow with ${SW_HIDE} and again with ${SW_SHOW}.

Stu


Hello,

We were concentrated on the Anders' solution.

for a quick hack, hide then show the window, for a real solution; call InvalidateRect or RedrawWindow with the system plugin
Actually, the solution is to use the LockWindow function :
Function .onMouseOverSection
LockWindow on
...
LockWindow off
FunctionEnd



PS :
I think I already tried this solution because I had the same problem with an other STATIC control that I have resolved with this. But I tried it in this case without results. I don't insisted because there is a difference between the two cases. And when I retried, it worked, so ...

Hello,

I have also the problem with the static control on the instfiles page allowing NSIS to write the details of the installation.
I bring back the problem is : when we change the text of a static control, it overlays the previous text that is not removed.
But now I can't use the LockWindow function around the SendMessage calls - allowing to change the static control text - because it's not me who controls this, it's NSIS.

The problem happens if I use a SetCtlColors to have the static control background transparent. If I take off the SetCtlColors, the problem not produces.

So I don't know how to resolve this problem in this context !!!


Hello I tried to reproduce the problem in a simple installer to illustrate it.

Name "Test"
OutFile "Test.exe"

Page instfiles "" InstFilesPageShow

Function InstFilesPageShow
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R0 $R0 1006
SetCtlColors $R0 0xFF0000 Transparent
FunctionEnd

Section ""
CreateDirectory "$DESKTOP\Dir_1"
CreateDirectory "$DESKTOP\Dir_1\Dir_1_1"
CreateDirectory "$DESKTOP\Dir_1\Dir_1_2"
SectionEnd

Try using LockWindow around the SetCtlColors.

Stu


Thanks Afrow UK for your suggestion but it doesn't work.


PS :
The code given before works so - if you want - you can just copy/paste it in a .nsi file and test it to see the problem and - if you want - try to help me.


not sure if this is a bug in nsis or the windows static control, but not all controls can handle transparent backgrounds

if you really need transparent background, you can use a ugly hack like:

Section 


FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R0 $R0 1006
SetCtlColors $R0 0xFF0000 Transparent

!macro uglyprinthack x
LockWindow on
detailprint "${x}"
LockWindow off
!macroend

!insertmacro uglyprinthack aaaaa
sleep 1234 ;do something
!insertmacro uglyprinthack BBBBB
sleep 2222 ;do something
!insertmacro uglyprinthack ""
SectionEnd

Thanks Anders but I repeat, it's not me that change the static control text, it's a default action of the instfiles page.
I take inspiration from your suggestion and I put LockWindow on before and LockWindow off after each line code leading to a display in the control.

Name "Test"
OutFile "Test.exe"

Page instfiles "" InstFilesPageShow

Function InstFilesPageShow
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R0 $R0 1006
SetCtlColors $R0 0xFF0000 Transparent
FunctionEnd

Section ""
LockWindow on
CreateDirectory "$DESKTOP\Dir_1"
LockWindow off
LockWindow on
CreateDirectory "$DESKTOP\Dir_1\Dir_1_1"
LockWindow off
LockWindow on
CreateDirectory "$DESKTOP\Dir_1\Dir_1_2"
LockWindow off
SectionEnd
It works but it stay really ugly and impossible to use with bigger sections (I remind this code is just an illustration of the problem, my real code is more important !!!).

I think this bug can't be resolved simply and neatly on the script. Maybe the solution is to change something in the NSIS source but I think it's not so easy.
Now, I content oneself with a uniform background (whithout image) for this window part.


And I have an other question on this topic !!!!!!!!!

It's possible to modify controls of the predefined pages as directory, components or instfiles thanks to the modification of the executable containing the resources with Resource Hacker and its reloading with the ChangeUI function.

Is it possible to use resources contained on this executable on a custom page ????????????????

In fact, I can add in this executable new dialog resources allowing me to customized the interface of new pages without using a plugin as InstallOption or nsDialog.
But how can I load these new resources ????????

Thanks. :D


So, anything new with instfile's static transparent background? I'm having the exact same problem now.