Archive: Want to disable an EditBox


Want to disable an EditBox
I created a custom page to hold two radio buttons and an edit box. I would like the edit box to enable and disable according to which radio button is checked. I am only partially successful so far and would like help from whomever might know how to do this.

I can enable and disable the edit box, but the tabstop doesn't change unless I leave the page and re-enter it. (In other words, if the field is active upon entry then the tab always goes into the edit box even when it is grayed out; vice-versa if it is disabled upon screen entry the tab won't go into it even if it becomes active.)

To disable the edit box I have the edit box HWND in $1 and use:


!insertmacro MUI_INSTALLOPTIONS_WRITE "newpage.ini" "Field 3" "Flags" DISABLED|READONLY|NOTABSTOP
SendMessage $1 ${WM_ENABLE} 0 0
SendMessage $1 ${EM_SETREADONLY} 1 0
Abort


To enable the edit box I use:

!insertmacro MUI_INSTALLOPTIONS_WRITE "newpage.ini" "Field 3" "Flags" ""
SendMessage $1 ${WM_ENABLE} 1 0
SendMessage $1 ${EM_SETREADONLY} 0 0
Abort


Does anyone have ideas?

Thanks,
Don

Use built-in EnableWindow instruction.

-Stu


Thanks for the advise. It is a big improvement, but I found (another) problem.

I wanted to set the edit box state to match the radio button upon entry to the page, so I replace the page Display function with InitDialog and Show, and in between those I call EnableWindow if I need to disable edit box. The problem is that when I disable the edit box, the entire dialog loses keyboard function. The mouse still works, and it works properly when disabled via the 'leave page' function.

Here's the code I use now to enter the page:


!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "newpage.ini"

Pop $0 ; HWND for dialog
IntCmp $1 0 +3 ; test radiobutton state
GetDlgItem $1 $0 1202 ; $1 is now 'Field 3' hWnd
EnableWindow $1 0

!insertmacro MUI_INSTALLOPTIONS_SHOW

The code in the 'leave-page' function is so simple now that I won't copy it here.