k_hejwosz
19th August 2004 00:02 UTC
Programatically change the active control (the one which has focus) in a custom page
I am in the middle of developing an installer for my company's flagship application.
I have designed the Select Installation Type custom page, which suggests to users the recommended installation strategy.
My problem (illustrated in the attachment):
If, despite recommendation, users chose Clean install, clicked Next and backtracked right upon, the installer would remember their choice but the active control would still remain the first radio button on the page (in the picture: Update).
My question:
Is it possible to programmatically change the active control (i.e. the one which is going to have focus on the page)?
deguix
19th August 2004 10:35 UTC
My problem (illustrated in the attachment):
Where is that?
Is it possible to programmatically change the active control (i.e. the one which is going to have focus on the page)?
The page state is saved everytime when the user goes to another page. You can set a control state by using
WriteINIStr.
Problems:
I think there is something in your installer that is setting the state everytime the page is executed.
That means, or are you using
WriteINIStr, or you're replacing the old file each time the page is executed.
Solutions:
You should set the state of that control much before showing the page, for example, on the installer .onInit or .onGUIInit function. This makes that page to really save that page state until the installer finishes.
k_hejwosz
19th August 2004 10:38 UTC
I did not mean the state of the control but focus band around it.
deguix
19th August 2004 11:29 UTC
OK, I created a function for you to set focus to a control. To use it, you need first to reserve the page, call this function, and only then show the page. The input used by the function is:
Push "YourINIFile.ini" ;Page INI file
Push $0 ;Page Handle (you got when reserving the page)
Push "2" ;Control Number
Call SetFocus
The function code is:
Function SetFocus
Exch $0 ; Control Number
Exch
Exch $2 ; Page Handle
Exch
Exch 2
Exch $3 ; Page INI File
Exch 2
Push $1
Push $R0
Push $R1
Push $R2
Push $R3
Push $R4
Push $R5
IntOp $1 $0 + 1199
GetDlgItem $1 $2 $1
# Send WM_SETFOCUS message
System::Call "user32::SetFocus(i r1, i 0x0007, i,i)i"
ReadINIStr $R0 "$3" "Field $0" "Left"
ReadINIStr $R1 "$3" "Field $0" "Right"
ReadINIStr $R3 "$3" "Field $0" "Top"
ReadINIStr $R4 "$3" "Field $0" "Bottom"
IntOp $R2 $R1 - $R0
IntOp $R5 $R4 - $R3
System::Call "user32::CreateCaret(i r0, i, i R2, i R5)i"
System::Call "user32::ShowCaret(i r0)i"
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Pop $R0
Pop $1
Pop $0
Pop $2
Pop $3
FunctionEnd
zimsms
19th August 2004 13:31 UTC
Nice! Thanks deguix!
k_hejwosz
22nd August 2004 16:26 UTC
Originally posted by deguix
Push $0 ;Page Handle (you got when reserving the page)
Could you please explain what you mean by the above. How do I reserve the page?
deguix
23rd August 2004 11:53 UTC
InstallOptions::initDialog "YourPage.ini" ;<- Reserving the page
Pop $hwnd ;<- Page handle
InstallOptions::show ;<- Showing reserved page
k_hejwosz
23rd August 2004 12:52 UTC
Thank you deguix. You were extremely helpful.