Archive: [nsDialogs] How to create Checkbox with transparent background?


[nsDialogs] How to create Checkbox with transparent background?
  Hello,
I am trying to write custom page using nsdialogs.
I am using bitmap control on the background. On that bitmap
I put some other controls, like labels and few checkboxes.
There are no problems with Label transparency, however I cant do the same with Checkbox (or RadioButton).
Is there any possibility to do that?

Here is a pseudocode I use:

Function CreateFinishPage


Var /Global Finish_Dialog
Var /GLOBAL Finish_Image
Var /GLOBAL Finish_Image_Handle
File/oname=$PLUGINSDIRFinish_Image.bmp "Graphics\\Wizard\\Welcome_Image.bmp"

Var /Global Finish_Header
Var /Global Finish_Header_Font
Var /Global Finish_Text
Var /Global Finish_Run



LockWindow on
GetDlgItem$0 $HWNDPARENT 3
EnableWindow$0 0
GetDlgItem$0 $HWNDPARENT 2
EnableWindow$0 0
GetDlgItem $R0 $HWNDPARENT 1
SendMessage $R0${WM_SETTEXT} 0 "STR:$(FINISH_QUIT)"
GetDlgItem $0 $HWNDPARENT 1028
ShowWindow$0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1256
ShowWindow$0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1045
ShowWindow$0 ${SW_NORMAL}
LockWindow off

nsDialogs::Create /NOUNLOAD 1044
Pop $Finish_Dialog

${If} $Finish_Dialog == error
Abort
${EndIf}

;Header Text
${NSD_CreateLabel} 125u 15u 63% 30u "$(FINISH_TITLE)"
Pop $Finish_Header
${NSD_AddStyle} $Finish_Header ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}
CreateFont $Finish_Header_Font "TAHOMA" "12" "700"
SendMessage $Finish_Header ${WM_SETFONT} $Finish_Header_Font 0
SetCtlColors $Finish_Header "0x000000" "TRANSPARENT"
>; Text
${NSD_CreateLabel} 130u 50u 185u 90u "$(FINISH_TEXT)"
Pop $Finish_Text
${NSD_AddStyle} $Finish_Text ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}
SetCtlColors $Finish_Text "0x000000" "TRANSPARENT"

>; Run
${NSD_CreateCheckBox} 125u 142u 60% 16u "Some text I use"
Pop $Finish_Run
SetCtlColors $Finish_Run "0x000000" "TRANSPARENT"

>; The checkbox is not transparent!

; Background Image
${NSD_CreateBitmap} 0u 0u 100% 100% ""
Pop $Finish_Image
${NSD_SetImage} $Finish_Image $PLUGINSDIRFinish_Image.bmp $Finish_Image_Handle


nsDialogs::Show
${NSD_FreeImage} $Finish_Image_Handle

FunctionEnd
>
I hope, someone of you can help. Thanks
-Pawel

One way would be to separate the text from the checkbox.

So your code would change like the following:


...

; Run
${NSD_CreateCheckBox} 125u 145u 9u 9u ""
Pop $0
${NSD_CreateLabel} 140u 145u 60% 16u "Some text I use"
Pop $Finish_Run
SetCtlColors $Finish_Run "0x000000" "TRANSPARENT"
>...

Originally posted by f0rt
One way would be to separate the text from the checkbox.

So your code would change like the following:
...

; Run
${NSD_CreateCheckBox} 125u 145u 9u 9u ""
Pop $0
${NSD_CreateLabel} 140u 145u 60% 16u "Some text I use"
Pop $Finish_Run
SetCtlColors $Finish_Run "0x000000" "TRANSPARENT"
>...
Yes, you are right. Thanks. I did that before. But, I want to learn how to do it normally (in that solution, I had to add .onclick functions for all labels, to simulate checkbox - more code, but works well). There must be some trick to do that.
I need some Windows API guru :p
Checkboxes, RadioButtons, GroupBoxes... I found this are not transparent.
-Pawel

I have solved this problem a long time ago.
Recently I was creating some nsDialogs page and I was not able to remember on it and I had to search in my old scripts...
So I put it on the forum now for everyone (also for me :D)

Var /Global CHECKBOX 

>${NSD_CreateCheckbox} 0 -50 100% 8u Test
Pop $CHECKBOX
># Set tranparent color for control
>SetCtlColors $CHECKBOX "0xFF00FF" transparent
># Add special style
>${NSD_AddExStyle} $CHECKBOX ${WS_EX_TRANSPARENT}|${WS_EX_TOPMOST}
Works fine for CheckBox and RadioButtons

On Windows XP, it works only fine for a push button if you had specified "XPStyle on", but doesn't support checkbox or radiobutton.


Actually it works ONLY for checkbox and radiobutton, because with labels there are no such problems...
I tried Win XP + Win 7 both were fine, also XPStyle on/off.


I just try your script again and I found that it works for a push-button and a radio button but not a checkbox. See my screenshot.

My customize checkbox:
http://forums.winamp.com/attachment....chmentid=48707
This customize checkbox also draw a focus rectangle when either checkbox or label is clicked to imitate a real checkbox. But still has problem sometimes.

Using your script:
http://forums.winamp.com/attachment....chmentid=48708
I also try to remove the line "${NSD_AddExStyle}", it is the same as before.

I am using official NSIS 2.46.

Click to download the attachment for these two example:
http://forums.winamp.com/attachment....chmentid=48706


i have some checkbox and text controls on a tab, but only text control can use BackgroundTrans to make it looks good.
BackgroundTrans doesn't works on the text label of checkbox and radio.
anyone knows how to solve this?
thanks.