TonyT
23rd June 2004 15:07 UTC
EnableWindow, WM_SETFOCUS
Hi
First of all - I've recently moved over to NSIS from using Windows Installer and I'm thoroughly enjoying the experience! Thanks very much for a great piece of software.
I've attached a simple nsi and InstallOptions ini to demonstrate a problem I'm having.
I want to enable and disable a textbox, and set/kill focus when it is enabled/disabled.
Everything appears to work OK, but the textbox refuses to accept keyboard input when it is enabled (mouse input seems OK).
I have tried placing the WM_SETFOCUS message in three different places but none seem to work (all three are indicated in the nsi).
TIA for any pointers on this one.
Tony
TonyT
23rd June 2004 15:11 UTC
Attachment
Looks like I lost the attachment...
Joel
23rd June 2004 15:49 UTC
I made a little changes at your function LeaveSimpleTest
Function LeaveSimpleTest
!insertmacro MUI_INSTALLOPTIONS_READ $choice "SimpleTest" "Settings" "State"
StrCmp $choice 1 BtnEnable BtnDisable
BtnEnable:
GetDlgItem $DlgItem $hwnd 1202
EnableWindow $DlgItem 1
SendMessage $DlgItem ${WM_SETTEXT} "" "STR:Enable"
Abort
BtnDisable:
GetDlgItem $DlgItem $hwnd 1202
SendMessage $DlgItem ${WM_SETTEXT} "" "STR:Disable"
EnableWindow $DlgItem 0
Abort
FunctionEnd
The messages have keeping you from typing.
TonyT
23rd June 2004 15:59 UTC
No focus on textbox
Thanks for that.
The textbox now accepts keyboard input, but I'd really like it to receive focus when it's enabled.
Any ideas on how to achieve that?
Tony
Joel
23rd June 2004 17:19 UTC
System plugin with SetFocus ;)
zambiniman
23rd June 2004 22:33 UTC
Use WM_NEXTDLGCTL
I had same problem but instead of using the System plug-in for setFocus function I used the following instead:
!define EM_SETSEL "0x0B1" ; Put this at the top somewhere
Function LeaveSimpleTest
!insertmacro MUI_INSTALLOPTIONS_READ $choice "SimpleTest" "Settings" "State"
StrCmp $choice 1 BtnEnable BtnDisable
BtnEnable:
GetDlgItem $DlgItem $hwnd 1202
EnableWindow $DlgItem 1
SendMessage $DlgItem ${WM_SETTEXT} "" "STR:Enable"
SendMessage $DlgItem ${EM_SETSEL} 0 -1
SendMessage $hwnd ${WM_NEXTDLGCTL} $DlgItem 1
Abort
BtnDisable:
GetDlgItem $DlgItem $hwnd 1202
EnableWindow $DlgItem 0
SendMessage $DlgItem ${WM_SETTEXT} "" "STR:Disable"
Abort
FunctionEnd
TonyT
24th June 2004 14:08 UTC
Thanks
Excellent, WM_NEXTDLGCTL did it.
Thanks very much.