0

I made a custom page using NSIS and I created in it a CheckBox to set the homepage of Internet Explorer. I combined these codes which I collected from different sources

To create the CheckBox:

${NSD_CreateCheckbox} 8 80 10 10 "CheckBox1"
Pop $Custom_Page1_CheckBox1
GetFunctionAddress $0 OnCheckbox
nsDialogs::OnClick $Custom_Page1_CheckBox1 $0

ans this is the function I used to set the home page of Internet Explorer:

Function OnCheckbox

WriteRegStr HKCU "Software\Microsoft\­­­Internet Explorer\Main" "Start Page" "http://www/homepage.com/"
FunctionEnd

The problem is there is no management of the selection which the user may choose.

How to solve this problem?

  • Are you displaying the page to user? This is your whole code? – Slappy May 09 '14 at 05:56
  • Thanks for replying Broo. Yes I am displaying the custom page to the user. So, he can uncheck the checkbox if he don't want to change his home page. The codes above are the whole codes which I found.. to create a Checkbox, call a function and within the function put a code which will change the home page of Internet Explorer. are those codes insufficient to perform this? – user3577221 May 09 '14 at 07:23
  • Why is this tagged with "webbrowser-control"? – Anders May 09 '14 at 11:32
  • So this is not a WHOLE code you have, isn't it? You need a little more to display the page and have it working. See Anders sample below. – Slappy May 09 '14 at 12:42
  • @Anders .. I used webbrowser-control as a tag because the action includes setting a homepage.. So, it's like we are controlling a webbrowser :-p – user3577221 May 09 '14 at 18:00
  • @Slappy Ofc this is not the whole code.. there are a lot of labels too. – user3577221 May 09 '14 at 18:02
  • @user3577221: Webbrowser control has special meaning on Windows, it is the IE trident engine embedded in a host application. – Anders May 09 '14 at 18:24
  • @Anders: Okay .. I changed it though I understood nothing from this sentence "IE trident engine embedded in a host application" lol .. – user3577221 May 09 '14 at 18:41
  • @user3577221: http://stackoverflow.com/a/9066236 – Anders May 09 '14 at 19:37
  • @Anders: I understood partially now .. merci :-D – user3577221 May 09 '14 at 19:57

1 Answers1

1

A OnClick handler is not the correct place to perform actions that change the users system.

You should check the state when the user is about to leave the page. If this custom page is before the InstFiles page I would recommend that you just save the state in a variable and then perform the action in a section at the same time as other install tasks.

!include nsDialogs.nsh
!include LogicLib.nsh

Page Custom MyPageCreate MyPageLeave
Page InstFiles

var OverrideIEHomeCheck

Function MyPageCreate
nsDialogs::Create 1018
Pop $0
${NSD_CreateCheckbox} 8 80 50u 10u "Evil"
Pop $OverrideIEHomeCheck
nsDialogs::Show
FunctionEnd

Function MyPageLeave
${NSD_GetState} $OverrideIEHomeCheck $0
${If} $0 <> ${BST_UNCHECKED}
    MessageBox mb_ok "Checked, do something now or remember the state"
${EndIf}
FunctionEnd
Anders
  • 97,548
  • 12
  • 110
  • 164
  • This is a perfect Solution.. it works.. Thank you again Anders .. it's as you said, the custom page is before InstFiles.. I don't know how to save the state in a variable and call it from a section. can you please give me a simple code to do this. – user3577221 May 09 '14 at 18:07
  • The code is pretty much there already. Change '${NSD_GetState} $OverrideIEHomeCheck $0' to '${NSD_GetState} $OverrideIEHomeCheck $OverrideIEHomeState' and move the ${If} ... part to a section where you check the new OverrideIEHomeState variable – Anders May 09 '14 at 18:22