Now frees the memory of loaded bitmaps when exiting

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2353 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2003-03-23 17:12:14 +00:00
parent d0ae879778
commit 56abf7e444
2 changed files with 30 additions and 22 deletions

View file

@ -76,27 +76,28 @@ int LookupTokens(TableEntry*, char*);
void ConvertNewLines(char *str); void ConvertNewLines(char *str);
struct FieldType { struct FieldType {
char *pszText; char *pszText;
char *pszState; char *pszState;
char *pszRoot; char *pszRoot;
char *pszListItems; char *pszListItems;
char *pszFilter; char *pszFilter;
int nType; int nType;
RECT rect; RECT rect;
int nMinLength; int nMinLength;
int nMaxLength; int nMaxLength;
char *pszValidateText; char *pszValidateText;
int nFlags; int nFlags;
bool bSaveDlg; bool bSaveDlg;
HWND hwnd; HWND hwnd;
UINT nControlID; UINT nControlID;
int nParentIdx; // this is used by the filerequest and dirrequest controls int nParentIdx; // this is used by the filerequest and dirrequest controls
HANDLE hImage; // this is used by image/icon field to save the handle to the image
}; };
// initial buffer size. buffers will grow as required. // initial buffer size. buffers will grow as required.
@ -930,12 +931,9 @@ int createCfgDlg()
} }
} else if (nType == FIELD_BITMAP || nType == FIELD_ICON) { } else if (nType == FIELD_BITMAP || nType == FIELD_ICON) {
WPARAM nImageType = nType == FIELD_BITMAP ? IMAGE_BITMAP : IMAGE_ICON; WPARAM nImageType = nType == FIELD_BITMAP ? IMAGE_BITMAP : IMAGE_ICON;
SendMessage( LPARAM nImage = 0;
hwCtrl, if (nImageType == IMAGE_BITMAP) {
STM_SETIMAGE, pFields[nIdx].hImage = LoadImage(
nImageType,
pFields[nIdx].pszText?
(LPARAM)LoadImage(
0, 0,
pFields[nIdx].pszText, pFields[nIdx].pszText,
nImageType, nImageType,
@ -946,7 +944,16 @@ int createCfgDlg()
? (pFields[nIdx].rect.bottom - pFields[nIdx].rect.top) ? (pFields[nIdx].rect.bottom - pFields[nIdx].rect.top)
: (rect.bottom - rect.top), : (rect.bottom - rect.top),
LR_LOADFROMFILE LR_LOADFROMFILE
):(LPARAM)LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(103)) );
nImage = (LPARAM)pFields[nIdx].hImage;
}
else
nImage = (LPARAM)LoadIcon(GetModuleHandle(0), MAKEINTRESOURCE(103));
SendMessage(
hwCtrl,
STM_SETIMAGE,
nImageType,
nImage
); );
} }
} }
@ -1012,6 +1019,7 @@ void showCfgDlg()
FREE(pFields[nIdx].pszListItems); FREE(pFields[nIdx].pszListItems);
FREE(pFields[nIdx].pszFilter); FREE(pFields[nIdx].pszFilter);
FREE(pFields[nIdx].pszRoot); FREE(pFields[nIdx].pszRoot);
DeleteObject(pFields[nIdx].hImage);
} }
FREE(pFields); FREE(pFields);

Binary file not shown.