Skip to content
⌘ NSIS Forum Archive

DropList limited to 999 characters?

18 posts

Prinz#

DropList limited to 999 characters?

Hi,

(Nsis 2.0b1 CVS Modern UI)

I need to add 193 items into my droplist, but it doesn't show more than 999 characters, the rest has been cutted automatically. Is there a way to insert more?

Greets!
kichik#
Why do you need more than 999 characters? Is that even visible on screen?

If you have a compiler you can change Contrib\InstallOptions\InstallOptions.cpp line 449 and replace 1000 with a bigger number, then recompile.
If you don't I must know why would you ever need more then 999 characters before I make that buffer larger.
Prinz#
Hi,

I'd already found it in installoptions.cpp, thanks for your reply anyway.

Why do I need more than 1000 characters? 1000 seems a lot, but in fact it isn't when you need for example: "choose your country": there are 200 countries to choose from. It has about 2450 characters.

Best Regards!
kichik#
Ahh... Right, I forgot that the text field needs to contain all of the entries... I thought you wanted to make a 1000+ characters long line 😁

I have updated the max to 4096 characters, that should be enough I think.
Prinz#
I've tested a little bit with the update, but the droplist is still limited to 1035 chars. (used to be 999) 🙁

I've tried to compile InstallerOptions.cpp to test with static char szResult[4096];

Very strange that it's 999 characters with a buffer of 1024 and 1035 characters with a buffer of 4096.

Do you have an idea?
kichik#
Well, NSIS variables are limited to 1024 charcaters by default. Are you using one big variable to write to the INI?
Prinz#
I'm trying to fill a droplist like this from A to Z:

[Field 1]
Type=DropList
ListItems=AR, Buenos Aires|AT, Salzburg|AT, Vienna|AU, Brisbane|AU, Melbourne|AU, Perth|AU, Sydney|BA, Sarajevo|BE, Antwerp|BE, Brussels|BG, Sofia|BO, La Paz|BR, Rio De Janeiro|BR, Sao Paulo|BS, Nassau|BY, Minsk|BZ, Belize City|CA, Calgary|CA, Edmonton|CA, Montreal|CA, Ottawa|CA, Quebec City|CA, Saskatoon|CA, Toronto|CA, Vancouver|CA, Winnipeg|CH, Bern|CH, Geneva|CH, Lausanne|CH, Zurich|CL, Santiago|CN, Beijing|CN, Shanghai|CO, Bogota|CR, San Jose|CU, Havana|CY, Nicosia|CZ, Prague|DE, Berlin|DE, Bonn|DE, Cologne|DE, Dresden|DE, Dusseldorf|DE, Frankfurt|DE, Hamburg|DE, Munich|DK, Copenhagen|DO, Santo Domingo|DZ, Algiers|EC, Guayaquil|EC, Quito|EG, Alexandria|EG, Cairo|ES, Ibiza|ES, Pamplona|ET, Addis Ababa|FI, Helsinki|FI, Turku|FR, Bordeaux|FR, Cannes|FR, Clermont|FR, Dijon|FR, Lille|FR, Lyon|FR, Marseille|FR, Nice|FR, Paris|FR, Reims|FR, Rennes|FR, Strasbourg|FR, Toulouse|FR, Tours|GB, Birmingham|GB, Liverpool|GB, London|GB, Manchester|GB, Newcastle|GB, Norwich|GB, Plymouth|GR, Athens|GT, Guatemala City|HK, Hong Kong|HN, Tegucigalpa|HT, Port-Au-Prince|HU, Budapest|HU, Zagreb|ID, Bali|ID, Jakarta|IE, Cork|IE, Dublin|IE, Shannon|IL, Jerusalem|IL, Tel Aviv|IN, Bombay|IN, Calcutta|IN, Delhi|IQ, Baghdad|IR, Tehran|IS, Reykjavik|IT, Florence|IT, Genoa|IT, Milan|IT, Naples|IT, Palermo|IT, Rome|IT, Venice|JM, Kingston|JO, Amman|JP, Osaka|JP, Sapporo|JP, Tokyo|KE, Nairobi|KR, Seoul|KW, Kuwait City|lB, Beirut|LK, Colombo|LU, Luxembourg|LY, Tripoli|MO, Casablanca|MX, Acapulco|MX, Cancun|MX, Chihuahua|MX, Guadalajara|MX, Mazatlan|MX, Mexico City|MY, Kuala Lumpur|NI, Lagos|NL, Amsterdam|NL, Rotterdam|NO, Floro|NO, Oslo|NO, Stavanger|NU, Managua|NZ, Auckland|NZ, Christchurch|NZ, Wellington|PA, Panama City|PE, Lima|PH, Manila|PK, Karachi|PL, Krakow|PL, Warsaw|PR, San Juan|PT, Lisbon|PT, Porto|PY, Asuncion|RO, Bucharest|RU, Archangelsk|RU, Irkutsk|RU, Kaliningrad|RU, Moscow|RU, Saint Petersburg|SA, Riyadh|SE, Gothenburg|SE, Malmo|SE, Stockholm|SG, Singapore|SI, Ljubljana|SK, Bratislava|SN, Dakar|SO, Mogadishu|SP, Barcelona|SP, Cordoba|SP, Granada|SP, Madrid|SP, Palma Mallorca|SP, Seville|SP, Tenerife|SP, Valencia|SP, Zaragoza|SY, Damascus|TH, Bangkok|TN, Tunis|TR, Ankara|TR, Istanbul|TT, Port of Spain|TW, Taipei|UA, Kiev|UA, Odessa|UK, Aberdeen|UK, Belfast|UK, Cardiff|UK, Edinburgh|UK, Glasgow|UK, Inverness|UY, Montevideo|VE, Caracas|VG, St. John|VN, Hanoi|ZA, Cape Town|ZA, Johannesburg|ZW, Harare
Left=130
Right=215
Top=125
Bottom=

The text is being cutted right after HONG KONG. Isn't it possible to add more?
kichik#
Depends on how you are writing into the INI. Do you compress it ready or do you change it using NSIS on run-time?

EDIT: OK, it doesn't either way... Let me have a look.
Prinz#
It's a custom page that imports the manually created .ini I wrote before the compile. It reads that .ini when the page shows up. About compression? I don't know.
kichik#
There is the problem. From wsprintf docs:
To use buffers larger than 1024 bytes, use _snwprintf. For more information, see the documentation for the C run-time library.
I will have to fix that one... I will also have to have a look everywhere wsprintf is used =/

For now replace line 585 of InstallOptions.cpp with:

strcpy(pFields[nIdx].pszListItems, szResult);
pFields[nIdx].pszListItems[nResult] = '|';
pFields[nIdx].pszListItems[nResult + 1] = '0';
Prinz#
Thank you!

I'm very sorry to bother you again with another question. When trying to compile InstallerOptions.cpp I receive the following error message:

on line 290: sf->ParseDisplayName(hConfigWindow, NULL, (unsigned short *)s, &eaten, &root, NULL);

[C++ Error] InstallerOptions.cpp(290): E2342 Type mismatch in parameter 'pszDisplayName' (wanted 'wchar_t *', got 'unsigned short *')

I also inserted #define STRICT above #include <windows.h> to avoid an error on line 704
Prinz#
Well, it did make the compiler happy, but unfortunately not the NSIS compiler:

Invalid command: InstallOptions::initDialog
Error in macro MUI_INSTALLOPTIONS_INITDIALOG on macroline 8
Error in macro MUI_FUNCTIONS_WELCOMEPAGE on macroline 23
Error in macro MUI_FUNCTIONS_PAGES on macroline 9
Error in macro MUI_BASIC on macroline 9
Error in macro MUI_SYSTEM on macroline 9
Error in script "C:\Program Files\NSIS20\Examples\Modern UI\droplist.nsi" on line 79 -- aborting creation process

Could you please compile it for me so I can go on with my project?
Thanks for all your help!

(you must be tired of me now 😉 )
kichik#
I am sorry I can't help you there... Seems like the compiler doesn't export IO's function or exports them under the wrong name.

I have attached a compiled version with the above change.

(you must be tired of me now 🙂)
Never 😁