PDA

View Full Version : EnableWindow, WM_SETFOCUS


TonyT
23rd June 2004, 14:07
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, 14:11
Looks like I lost the attachment...

Joel
23rd June 2004, 14:49
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, 14:59
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, 16:19
System plugin with SetFocus (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/setfocus.asp) ;)

zambiniman
23rd June 2004, 21:33
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, 13:08
Excellent, WM_NEXTDLGCTL did it.

Thanks very much.