I'm having some issues with my InstallOptions Custom page.
I want a textbox to get a notify. Actually, I just want something different to be done when the user presses enter while in this textbox, instead of it going to the next page.
The idea is that the textbox entry will be entered into the listbox below if the user presses enter after entering the text into the textbox. Enter by default means "Next" apparently.
I have tried things like making a copy of the next button and replacing the regular one with a different dialog ID, and making the copy invisible and disabled (the dialog shouldn't return if IDOK button is disabled). This also doesn't work.
I have tried using an external C++ program that, given a window handle and its parent, sees if that window has focus. FindWindow and the "HWND" property in the INI give the same window handles, and the program always returns "1" (that window has focus), or crashes if I try to use the window's parent to get the focused window. It never matters where the real focus is, the program always returns "1".
Nothing seems to be working!
I would rather not modify the NSIS code to make the textbox get a notify because I'm working in a team setting and things need to be compatable all around (and this thing will be modified in the future, when I'm not around).
Also, I don't think a CEdit control gets a notify message anyways. I'd have to make a custom control to get this working! (PAIN PAIN PAIN).
Any suggestions?
InstallOptions: TextBox Notify
9 posts
More details
In my external program, CWnd::GetFocus always returns 0x00000000 because it thinks that the parent window is not valid... and it certainly is valid! I'm using the Rectangle that's for the custom dialogs as the parent window. (It's id is 1018, remember?). Spy++ recognizes it as a window and everything, but when I type cast it as a HWND the unused component is always "???", which is bad. That usually tells me that that window is bad.
I'm also getting :
getfocus warning C4312: 'type cast' : conversion from 'unsigned long' to 'HWND' of greater size
when I compile because I casted an unsigned long value (command-line param) into an HWND. This does not, however, really matter because the window handle value is ENTIRELY preserved, so there shouldn't be any errors.
Help??
In my external program, CWnd::GetFocus always returns 0x00000000 because it thinks that the parent window is not valid... and it certainly is valid! I'm using the Rectangle that's for the custom dialogs as the parent window. (It's id is 1018, remember?). Spy++ recognizes it as a window and everything, but when I type cast it as a HWND the unused component is always "???", which is bad. That usually tells me that that window is bad.
I'm also getting :
getfocus warning C4312: 'type cast' : conversion from 'unsigned long' to 'HWND' of greater size
when I compile because I casted an unsigned long value (command-line param) into an HWND. This does not, however, really matter because the window handle value is ENTIRELY preserved, so there shouldn't be any errors.
Help??
I have sinned. I've decided to use InstallOptionsEx beta 5. I'm not satisfied to use this because it has no Eclipse SDK plugin that I know of. It also reports no compatability with MUI. I think I can get around that though.
I would still like to see if there's an answer to the main problem though...
I would still like to see if there's an answer to the main problem though...
The idea is that the textbox entry will be entered into the listbox below if the user presses enter after entering the text into the textbox. Enter by default means "Next" apparently.Why not use a simple loop in the function that creates the custom page? Here is a simple example which adds the contents of the text box to the list. If the text box is empty when the button is clicked then the next page is shown:
and here is the demo.ini file; Use a TextBox to add entries to a ListBox
Name "Dynamic ListBox Demo"
OutFile dynamiclistbox.exe
ShowInstDetails show
ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
ReserveFile "demo.ini"
Page custom CustomPage
Page instfiles
Function .onInit
InitPluginsDir
File /oname=$PLUGINSDIR\demo.ini "demo.ini"
FunctionEnd
Function CustomPage
Push $0
Push $1
loop:
InstallOptions::dialog "$PLUGINSDIR\demo.ini"
Pop $0
StrCmp $0 "cancel" done
ReadINIStr $0 "$PLUGINSDIR\demo.ini" "Field 2" "State"
StrLen $1 $0
StrCmp $1 0 done
ReadINIStr $1 "$PLUGINSDIR\demo.ini" "Field 4" "ListItems"
StrCpy $1 "$1|$0"
WriteINIStr "$PLUGINSDIR\demo.ini" "Field 4" "ListItems" $1
WriteINIStr "$PLUGINSDIR\demo.ini" "Field 2" "State" ""
Goto loop
done:
Pop $1
Pop $0
FunctionEnd
Section dummy
; Dummy
SectionEnd
; end-of-file
[Settings]
NumFields=4
[Field 1]
Type=Label
Text=Enter item to be added to list (leave blank to go on to next page)
Left=10
Right=300
Top=1
Bottom=10
[Field 2]
Type=Text
Left=10
Right=100
Top=14
Bottom=27
[Field 3]
Type=Label
Text=Current list of items
Left=10
Right=200
Top=32
Bottom=42
[Field 4]
Type=Listbox
ListItems=Item-A|Item-B|Item-C
Left=10
Right=100
Top=44
Bottom=128
It has the same flaw as mine sorry. I dont think I told everyone EVERYTHING that was going on (sorry). If some text is left in the textbox that was not meant to be entered, and you click next, the code detects that something different than what was last entered is in the textbox, and enters it in, and does Abort. Your sample has the same problem unfortunately. Clicking "Install" when there's something in the box enters it in.
Why not add a button marked "Add Item" to the custom page? This would let your script handle these two cases:
(1) User types some text in the box and clicks "Add Item" to add the text to the list and update the custom page to show the new list of items
(2) User types some text in the box (by mistake) then clicks "Next" (or presses ENTER) but this text is _not_ added to the list and the next page appears
You can use the standard InstallOptions2 NOTIFY feature to implement this "Add Item" button.
At the moment I cannot see any other way to meet your two requirements:
(A) The idea is that the textbox entry will be entered into the listbox below if the user presses enter after entering the text into the textbox.
(B) If some text is left in the textbox that was not meant to be entered, and you click next, this text must not be added to the list
(1) User types some text in the box and clicks "Add Item" to add the text to the list and update the custom page to show the new list of items
(2) User types some text in the box (by mistake) then clicks "Next" (or presses ENTER) but this text is _not_ added to the list and the next page appears
You can use the standard InstallOptions2 NOTIFY feature to implement this "Add Item" button.
At the moment I cannot see any other way to meet your two requirements:
(A) The idea is that the textbox entry will be entered into the listbox below if the user presses enter after entering the text into the textbox.
(B) If some text is left in the textbox that was not meant to be entered, and you click next, this text must not be added to the list
This is all well and good, but are you saying that you CAN meet requirement A?
" The idea is that the textbox entry will be entered into the listbox below if the user presses >ENTER< after entering the text into the textbox. "
It's ok if this is not possible. I actually like the idea of having an "add item" button. I very well may add this in because some people are not keyboard people. I wonder if there's an ongoing poll about that...
Thanks
" The idea is that the textbox entry will be entered into the listbox below if the user presses >ENTER< after entering the text into the textbox. "
It's ok if this is not possible. I actually like the idea of having an "add item" button. I very well may add this in because some people are not keyboard people. I wonder if there's an ongoing poll about that...
Thanks
This is all well and good, but are you saying that you CAN meet requirement A?Isn't that what my example does?
Well, yes, your example does do something like that. It does however enter whatever text is in the box (if any) when you click "Install".
InstallOptionsEx Beta 5 had some silly bugs (which I have no time to fix) so I'm not using it. If I wasn't working in team dev mode I would fix it.
I'm currently using a work-around for this problem. My installer by nature expects you to enter a minimum number of entries into the list box. If you've reached the limit and something is still in the textbox then it'll Abort the page.
One way I was going to try was detecting a carriage return character in the textbox string and entering it into the listbox if so. However this won't work either because when you press enter in a multiline textbox it doesn't call the Next button like a non-multiline. Too bad too. It would have worked nicely. There seems to be some strange behavior when you specify WANTRETURN without MULTILINE or vese versa. The escape key no longer quits the installer. Does anybody know what's going on there? Perhaps I could use it to my advantage.
InstallOptionsEx Beta 5 had some silly bugs (which I have no time to fix) so I'm not using it. If I wasn't working in team dev mode I would fix it.
I'm currently using a work-around for this problem. My installer by nature expects you to enter a minimum number of entries into the list box. If you've reached the limit and something is still in the textbox then it'll Abort the page.
One way I was going to try was detecting a carriage return character in the textbox string and entering it into the listbox if so. However this won't work either because when you press enter in a multiline textbox it doesn't call the Next button like a non-multiline. Too bad too. It would have worked nicely. There seems to be some strange behavior when you specify WANTRETURN without MULTILINE or vese versa. The escape key no longer quits the installer. Does anybody know what's going on there? Perhaps I could use it to my advantage.