- NSIS Discussion
- Window and Control
Archive: Window and Control
Corpio
27th June 2008 15:38 UTC
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>
LoRd_MuldeR
27th June 2008 15:50 UTC
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
Corpio
27th June 2008 16:07 UTC
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.
Afrow UK
27th June 2008 16:14 UTC
Use Resource Hacker and open the UI executable file.
Stu
LoRd_MuldeR
27th June 2008 16:32 UTC
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
Corpio
27th June 2008 17:19 UTC
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.
Corpio
1st July 2008 15:12 UTC
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.
Anders
1st July 2008 15:31 UTC
for a quick hack, hide then show the window, for a real solution; call InvalidateRect or RedrawWindow with the system plugin
Corpio
1st July 2008 16:05 UTC
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
Afrow UK
1st July 2008 21:20 UTC
Use ShowWindow with ${SW_HIDE} and again with ${SW_SHOW}.
Stu
Corpio
2nd July 2008 08:47 UTC
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 ...
Corpio
2nd July 2008 11:19 UTC
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 !!!
Corpio
3rd July 2008 11:23 UTC
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
Afrow UK
3rd July 2008 11:53 UTC
Try using LockWindow around the SetCtlColors.
Stu
Corpio
3rd July 2008 13:19 UTC
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.
Anders
3rd July 2008 15:09 UTC
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
Corpio
3rd July 2008 15:28 UTC
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 !!!).
Corpio
3rd July 2008 16:38 UTC
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.
Corpio
3rd July 2008 16:47 UTC
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
BuilderBob
16th September 2008 10:17 UTC
So, anything new with instfile's static transparent background? I'm having the exact same problem now.