Added group box, and made dir request not crash and use Text field

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1989 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2002-12-21 11:24:42 +00:00
parent 69ef5ba1ab
commit d66016acfe
4 changed files with 50 additions and 38 deletions

View file

@ -110,6 +110,7 @@ char *STRDUP(const char *c)
#define FIELD_DIRREQUEST (9) #define FIELD_DIRREQUEST (9)
#define FIELD_COMBOBOX (10) #define FIELD_COMBOBOX (10)
#define FIELD_LISTBOX (11) #define FIELD_LISTBOX (11)
#define FIELD_GROUPBOX (12)
// general flags // general flags
#define FLAG_BOLD (0x1) #define FLAG_BOLD (0x1)
@ -209,7 +210,7 @@ bool BrowseForFile(int nControlIdx) {
// ofn.lpstrCustomFilter = NULL; // ofn.lpstrCustomFilter = NULL;
// ofn.lpstrDefExt = NULL; // ofn.lpstrDefExt = NULL;
ofn.nMaxFile = MAX_PATH; ofn.nMaxFile = MAX_PATH;
ofn.lpstrFile = (char*)MALLOC(ofn.nMaxFile); ofn.lpstrFile = (char*)MALLOC(MAX_PATH);
// ofn.nMaxFileTitle = MAX_PATH; // we ignore this for simplicity, leave lpstrFileTitle at NULL // ofn.nMaxFileTitle = MAX_PATH; // we ignore this for simplicity, leave lpstrFileTitle at NULL
// ofn.lpstrFileTitle = new char [ofn.nMaxFileTitle]; // ofn.lpstrFileTitle = new char [ofn.nMaxFileTitle];
@ -224,9 +225,9 @@ bool BrowseForFile(int nControlIdx) {
// ofn.nFilterIndex = 1; // since we use no custom filters, leaving it at 0 means use the first. // ofn.nFilterIndex = 1; // since we use no custom filters, leaving it at 0 means use the first.
// ofn.nMaxCustFilter = 0; // ofn.nMaxCustFilter = 0;
GetWindowText(hControl, ofn.lpstrFile, ofn.nMaxFile); GetWindowText(hControl, ofn.lpstrFile, MAX_PATH);
for(;;) { //for(;;) {
if (pThisField->bSaveDlg) { if (pThisField->bSaveDlg) {
bResult = GetSaveFileName(&ofn); bResult = GetSaveFileName(&ofn);
} else { } else {
@ -241,9 +242,9 @@ bool BrowseForFile(int nControlIdx) {
// if (*(ofn.lpstrFile)) { //&& (CommDlgExtendedError() == FNERR_INVALIDFILENAME)) { // if (*(ofn.lpstrFile)) { //&& (CommDlgExtendedError() == FNERR_INVALIDFILENAME)) {
// *(ofn.lpstrFile) = '\0'; // *(ofn.lpstrFile) = '\0';
// } else { // } else {
break; //break;
// } // }
} //}
return false; return false;
} }
@ -263,14 +264,11 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData) {
bool BrowseForFolder(int nControlIdx) { bool BrowseForFolder(int nControlIdx) {
BROWSEINFO bi; BROWSEINFO bi;
HWND hControl;
hControl = pFields[nControlIdx].hwnd;
bi.hwndOwner = hConfigWindow; bi.hwndOwner = hConfigWindow;
bi.pidlRoot = NULL; bi.pidlRoot = NULL;
bi.pszDisplayName = (char*)MALLOC(MAX_PATH); bi.pszDisplayName = (char*)MALLOC(MAX_PATH);
LPCTSTR lpszTitle = NULL; bi.lpszTitle = pFields[nControlIdx].pszText;
bi.ulFlags = BIF_STATUSTEXT; bi.ulFlags = BIF_STATUSTEXT;
bi.lpfn = BrowseCallbackProc; bi.lpfn = BrowseCallbackProc;
bi.lParam = nControlIdx; bi.lParam = nControlIdx;
@ -299,7 +297,7 @@ bool BrowseForFolder(int nControlIdx) {
char *pszFolder = (char*)MALLOC(MAX_PATH); char *pszFolder = (char*)MALLOC(MAX_PATH);
if (SHGetPathFromIDList(pResult, pszFolder)) { if (SHGetPathFromIDList(pResult, pszFolder)) {
SetWindowText(hControl, pszFolder); SetWindowText(pFields[nControlIdx].hwnd, pszFolder);
} }
LPMALLOC pMalloc; LPMALLOC pMalloc;
@ -413,7 +411,7 @@ void AddBrowseButtons() {
// control is found, then it adds the corresponding browse button. // control is found, then it adds the corresponding browse button.
// NOTE: this also resizes the text box created to make room for the button. // NOTE: this also resizes the text box created to make room for the button.
int nIdx; int nIdx;
int nWidth = 22; int nWidth = 15;
FieldType *pNewField; FieldType *pNewField;
for (nIdx = nNumFields - 1; nIdx >= 0; nIdx--) { for (nIdx = nNumFields - 1; nIdx >= 0; nIdx--) {
@ -501,6 +499,7 @@ bool ReadSettings(void) {
{ "RADIOBUTTON", FIELD_RADIOBUTTON }, { "RADIOBUTTON", FIELD_RADIOBUTTON },
{ "ICON", FIELD_ICON }, { "ICON", FIELD_ICON },
{ "BITMAP", FIELD_BITMAP }, { "BITMAP", FIELD_BITMAP },
{ "GROUPBOX", FIELD_GROUPBOX },
{ NULL, 0 } { NULL, 0 }
}; };
// Control flags // Control flags
@ -869,7 +868,10 @@ int createCfgDlg()
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE }, WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE },
{ "LISTBOX", // FIELD_LISTBOX { "LISTBOX", // FIELD_LISTBOX
DEFAULT_STYLES | WS_GROUP | WS_TABSTOP | LBS_DISABLENOSCROLL | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT, DEFAULT_STYLES | WS_GROUP | WS_TABSTOP | LBS_DISABLENOSCROLL | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT,
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE } WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE },
{ "BUTTON", // FIELD_GROUPBOX
DEFAULT_STYLES | BS_GROUPBOX,
WS_EX_TRANSPARENT }
}; };
#undef DEFAULT_STYLES #undef DEFAULT_STYLES
@ -891,7 +893,7 @@ int createCfgDlg()
rect.top = MulDiv(pFields[nIdx].rect.top, baseUnitY, 8); rect.top = MulDiv(pFields[nIdx].rect.top, baseUnitY, 8);
rect.bottom = MulDiv(pFields[nIdx].rect.bottom, baseUnitY, 8); rect.bottom = MulDiv(pFields[nIdx].rect.bottom, baseUnitY, 8);
if (pFields[nIdx].rect.left < 0) if (pFields[nIdx].rect.left < 0)
rect.left += dialog_r.right - dialog_r.left; rect.left += dialog_r.right - dialog_r.left;
if (pFields[nIdx].rect.right < 0) if (pFields[nIdx].rect.right < 0)
rect.right += dialog_r.right - dialog_r.left; rect.right += dialog_r.right - dialog_r.left;

View file

@ -1,54 +1,64 @@
[Settings] [Settings]
NumFields=6 NumFields=7
[Field 1] [Field 1]
Type=checkbox Type=checkbox
text=Install support for X text=Install support for X
left=0 left=5
right=300 right=-5
top=0 top=10
bottom=10 bottom=18
state=0 state=0
[Field 2] [Field 2]
Type=checkbox Type=checkbox
text=Install support for Y text=Install support for Y
left=0 left=5
right=-1 right=-5
top=13 top=19
bottom=23 bottom=27
state=1 state=1
[Field 3] [Field 3]
Type=checkbox Type=checkbox
text=Install support for Z text=Install support for Z
left=0 left=5
right=-1 right=-5
top=26 top=28
bottom=36 bottom=36
state=0 state=0
[Field 4] [Field 4]
Type=FileRequest Type=FileRequest
State=C:\poop.poop State=C:\poop.poop
Left=0 Left=5
Right=-1 Right=-5
Top=46 Top=38
Bottom=59 Bottom=50
Filter=Poop Files|*.poop|All files|*.* Filter=Poop Files|*.poop|All files|*.*
Flags=FILE_MUST_EXIST|OFN_EXPLORER|OFN_HIDEREADONLY Flags=FILE_MUST_EXIST|OFN_EXPLORER|OFN_HIDEREADONLY
[Field 5] [Field 5]
Type=DirRequest Type=DirRequest
Left=0 Left=5
Right=-1 Right=-5
Top=64 Top=51
Bottom=77 Bottom=63
Text=Select a directory...
State=C:\Program Files\NSIS
[Field 6] [Field 6]
Type=Label Type=Label
Left=5
Right=-5
Top=64
Bottom=78
Text=This is a label...
[Field 7]
Type=GroupBox
Left=0 Left=0
Right=-1 Right=-1
Top=87 Top=0
Bottom=97 Bottom=-1
Text=This is a label... Text=This is a group box...

View file

@ -18,7 +18,7 @@ InstallDir "$PROGRAMFILES\IOTest"
;Use ReserveFile for your own InstallOptions INI files too! ;Use ReserveFile for your own InstallOptions INI files too!
ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll" ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
ReserveFile "test.ini" ReserveFile "Copy of test.ini"
;Texts on the dialogs ;Texts on the dialogs
DirText "Choose a directory" DirText "Choose a directory"
@ -56,7 +56,7 @@ Function .onInit
;$PLUGINSDIR will automatically be removed when the installer closes ;$PLUGINSDIR will automatically be removed when the installer closes
InitPluginsDir InitPluginsDir
File /oname=$PLUGINSDIR\test.ini "test.ini" File /oname=$PLUGINSDIR\test.ini "copy of test.ini"
FunctionEnd FunctionEnd

Binary file not shown.