Skip to content
⌘ NSIS Forum Archive

Refresh a label on a custom window

7 posts

FaKo#

Refresh a label on a custom window

Hello,
(I'm very very very bad in english)
I'm a newbie on NSIS, and I try to make an easy thing :

On a custom window,I have a label and a button

before MUI_INSTALLOPTIONS_SHOW, I verify something and I modify the color and the text of the label like that :

GetDlgItem $label $HWND 1204
SetCtlColors $label 0xFF0000 "transparent"
SendMessage $label ${WM_SETTEXT} 0 "STR:non installé"

and it works 😁

if I click on the button, I want to change the color and the text of the label. I do that :
GetDlgItem $label $HWND 1204
SetCtlColors $label 0x00AA00 "transparent"
SendMessage $label ${WM_SETTEXT} 0 "STR:Installé"

The new text overwrites the older but the older is not erased ; it can be seen under ????!!!!!! 🤪
If I open a window on the custom window, the label is refreshed. How can I refresh the label ? 😢
kichik#
The best way to get around this would be not to use a transparent background. If you can't, try calling RedrawWindow or UpdateWindow using System.dll.
FaKo#
I must use transparent background because I don't know the background color of the window (it's a system color)...

But how can I use System.dll and RedrawWindow or UpdateWindow ? (sorry,I'm a really newbie !...)
kichik#
If you want the system dialog background color you can simply not specify a background color:
SetCtlColors $label 0xFF0000
kichik#
Hmm... Right, can't have text color without background, it will be ignored. You can hide and show the control using:
ShowWindow $0 ${SW_HIDE}
SendMessage $0 ${WM_SETTEXT} "" STR:$0
ShowWindow $0 ${SW_SHOW}
Make sure you include WinMessages.nsh before using that code:
!include WinMessages.nsh
FaKo#
It wooooooooooooorks !!!!!!!!!!!!!!!!!!!!

It's a work-around but It works ! Thx you !!

Thx thx !