Skip to content
⌘ NSIS Forum Archive

New Checkbox modifying components checkbox state

6 posts

luthar#

New Checkbox modifying components checkbox state

Hello,

I hope my subject is clear.

Basicly, I want to be able to add a new checkbox to the Modern UI components page. To do this, I will go with the extract/write in ini files.

My main problem is that I want to be able to modify the state of the components checkbox (basicly gray/ungray them).

I saw a couple of threads about similar things but I can't seem to find a way to do it.

Here are the solutions I tought, yet none are imho nicely programmed:
- Use the checkbox as a *next* button. Use the MUI_PAGE_CUSTOMFUNCTION_LEAVE macro to call a function that will SetSectionFlags. Reload the page (can this be done?!)

- Use the checkbox as a *next* button. Create two components page, one with checkbox grayed and other one not grayed. Use the MUI_PAGE_CUSTOMFUNCTION_LEAVE to switch from one page to another. When the real next button is pressed, jump to Directory page.

Any ideas on this? If so, any references to examples/code/eetc...
Red Wine#
The .OnSelChange callback might be useful,

luthar#
So what have I done so far...Any tips would be welcomed..

Hacked the UI to add a checkbox control...to Dialog 104 (Components)
CONTROL "", 1044, BUTTON, BS_CHECKBOX | WS_CHILD | WS_VISIBLE, 0, 68, 90, 18 

I added the following lines to create the Components page...
  !define MUI_PAGE_CUSTOMFUNCTION_PRE Component_pre
  !define MUI_PAGE_CUSTOMFUNCTION_LEAVE Component_leave
  !insertmacro MUI_PAGE_COMPONENTS 
Made the following functions:
Function Component_pre
    FindWindow $0 "#32770" "" $HWNDPARENT
        GetDlgItem $1 $0 1044
    SendMessage $1 ${WM_SETTEXT} 0 "TESTING 123"
FunctionEnd
Function Component_leave
     #
     # Missing code to get the CheckBox Id (I know its reference to 1044 but how to get the event that called this function?
        ${If} ......
        ${if} $0 == "0"
            # default disable so no RO
            SectionGetFlags ${SECMatlab} $3
            IntOp $3 ${SF_SELECTED} | ${SF_RO}
            SectionSetFlags ${SECMatlab}  $3
            SectionGetFlags ${SECDotNet} $3
            IntOp $3 $3 | ${SF_RO}
            SectionSetFlags ${SECDotNet}  $3
        ${else}
            SectionGetFlags ${SECMatlab} $3
            IntOp $3 $3 | ${SF_RO}
            SectionSetFlags ${SECMatlab}  $3
            SectionGetFlags ${SECDotNet} $3
            IntOp $3 $3 | ${SF_RO}
            SectionSetFlags ${SECDotNet}  $3
        ${endif}
        abort
    ${EndIf}
FunctionEnd 
The new checkbox added does not respond to any click events (it doesn't show the checkmark when clicked )
Afrow UK#
Do check boxes send the BN_CLICKED notification? If so, you can use the ButtonEvent plug-in.

Stu
luthar#
Everything worked perfectly with the ButtonEvent.

I still have a problem tought...

When in a section I put SectionIn RO, the components becomes greyed...

Yet with the code below it doesn't get grayed and the clear doesn't seem to work.

Function Component_Modification
  # Swap Values of Checkbox
  ${If} $DefaultCheckBox == 1 
      Strcpy $DefaultCheckBox "0"
  ${Else} 
      StrCpy $DefaultCheckBox "1"    
  ${EndIf}
  # Has user checked the check box ?
  FindWindow $R0 "#32770" "" $HWNDPARENT
  GetDlgItem $R1 $R0 1200
  
  SendMessage $R1 ${BM_SETCHECK} $DefaultCheckBox 0 
    ${If} $DefaultCheckBox != 1 # User has not checked check box.
           ; default disable so no RO and must turn grey
        SectionGetFlags ${SECMatlab} $3
        !insertmacro ClearSectionFlag $3 ${SF_RO}
        SectionSetFlags ${SECMatlab}  $3
        SectionGetFlags ${SECDotNet} $3
        !insertmacro ClearSectionFlag $3 ${SF_RO}
        SectionSetFlags ${SECDotNet}  $3
    ${else}
        SectionGetFlags ${SECMatlab} $3
        IntOp $3 $3 | ${SF_RO}
        SectionSetFlags ${SECMatlab}  $3
        SectionGetFlags ${SECDotNet} $3
        IntOp $3 $3 | ${SF_RO}
        SectionSetFlags ${SECDotNet}  $3
    ${EndIf}
FunctionEnd 
luthar#
Is it possible to put the section checkbox to gray, I would need to send the BM_SETSTATE message.

If so, is there anyway to get access to the CheckBox from the section?