Added About dialog DPI aware support and intro animation

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7041 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2018-11-04 21:25:52 +00:00
parent d6adb07487
commit b1240c82d9
9 changed files with 258 additions and 101 deletions

View file

@ -30,6 +30,7 @@ libs = Split("""
advapi32
user32
gdi32
msimg32
shell32
shlwapi
comdlg32

View file

@ -44,7 +44,7 @@ NRESIZEDATA g_resize;
NFINDREPLACE g_find;
TCHAR g_findbuf[128];
extern NTOOLBAR g_toolbar;
int g_symbol_set_mode;
void* g_ModalDlgData;
NSIS_ENTRYPOINT_SIMPLEGUI
int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int ShowCmd) {
@ -54,7 +54,6 @@ int WINAPI _tWinMain(HINSTANCE hInst,HINSTANCE hOldInst,LPTSTR CmdLineParams,int
// we need to prevent LoadLibrary from searching the current directory because it can contain untrusted DLLs!
FARPROC SDDA = GetProcAddress(hK32, "SetDllDirectoryA"); // WinXP.SP1+
if (SDDA) ((BOOL(WINAPI*)(LPCSTR))SDDA)(""); // Remove the current directory from the default DLL search order
memset(&g_sdata,0,sizeof(NSCRIPTDATA));
memset(&g_resize,0,sizeof(NRESIZEDATA));
memset(&g_find,0,sizeof(NFINDREPLACE));
@ -203,7 +202,7 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
SetClassLongPtr(hwndDlg,GCLP_HICON,(LONG_PTR)hIcon);
// Altered by Darren Owen (DrO) on 29/9/2003
// Added in receiving of mouse and key events from the richedit control
SendMessage(GetDlgItem(hwndDlg,IDC_LOGWIN),EM_SETEVENTMASK,(WPARAM)NULL,ENM_SELCHANGE|ENM_MOUSEEVENTS|ENM_KEYEVENTS);
SendDlgItemMessage(hwndDlg,IDC_LOGWIN,EM_SETEVENTMASK,(WPARAM)NULL,ENM_SELCHANGE|ENM_MOUSEEVENTS|ENM_KEYEVENTS);
DragAcceptFiles(g_sdata.hwnd,FALSE);
g_sdata.menu = GetMenu(g_sdata.hwnd);
g_sdata.fileSubmenu = FindSubMenu(g_sdata.menu, IDM_FILE);
@ -213,7 +212,7 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
CreateToolBar();
InitTooltips(g_sdata.hwnd);
SetDlgItemText(g_sdata.hwnd,IDC_VERSION,g_sdata.branding);
HFONT hFont = CreateFont(14,FW_NORMAL,FIXED_PITCH|FF_DONTCARE,_T("Courier New"));
HFONT hFont = CreateFontPt(hwndDlg,8,FW_NORMAL,FIXED_PITCH|FF_DONTCARE,DEFAULT_CHARSET,_T("Courier New"));
SendDlgItemMessage(hwndDlg,IDC_LOGWIN,WM_SETFONT,(WPARAM)hFont,0);
RestoreWindowPos(g_sdata.hwnd);
RestoreCompressor();
@ -521,33 +520,16 @@ INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
}
return TRUE;
}
case IDM_ABOUT:
{
return DialogBox(g_sdata.hInstance,MAKEINTRESOURCE(DLG_ABOUT),hwndDlg,(DLGPROC)AboutProc);
}
case IDM_NSISHOME:
{
return OpenUrlInDefaultBrowser(g_sdata.hwnd, NSIS_URL);
}
case IDM_FORUM:
{
return OpenUrlInDefaultBrowser(g_sdata.hwnd, NSIS_FORUM_URL);
}
case IDM_NSISUPDATE:
{
CheckForUpdate();
return TRUE;
}
case IDM_DOCS: return (ShowDocs(), TRUE);
case IDM_NSISHOME: return OpenUrlInDefaultBrowser(g_sdata.hwnd, NSIS_URL);
case IDM_FORUM: return OpenUrlInDefaultBrowser(g_sdata.hwnd, NSIS_FORUM_URL);
case IDM_NSISUPDATE: return (CheckForUpdate(), TRUE);
case IDM_ABOUT: return ShowAboutDialog(hwndDlg)|TRUE;
case IDM_SELECTALL:
{
SendDlgItemMessage(g_sdata.hwnd, IDC_LOGWIN, EM_SETSEL, 0, -1);
return TRUE;
}
case IDM_DOCS:
{
ShowDocs();
return TRUE;
}
case IDM_LOADSCRIPT:
{
if (!g_sdata.thread) {
@ -835,17 +817,70 @@ BOOL CALLBACK DialogResize(HWND hWnd, LPARAM /* unused */)
return TRUE;
}
INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
static INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
ABOUTDLGDATA &dd = *(ABOUTDLGDATA*) g_ModalDlgData;
switch(msg) {
case WM_DRAWITEM:
if (wParam == IDC_ABOUTHEADER)
{
DRAWITEMSTRUCT &dis = *(DRAWITEMSTRUCT*) lParam;
RECT r, r2;
const TCHAR txt[] = TEXT("MakeNSISW");
INT dt = DT_NOCLIP|DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER, cch = COUNTOF(txt) - 1, line = DpiScaleY(dis.hwndItem, 2), shadow = 1;
GetClientRect(dis.hwndItem, &r);
if (!dd.FinalHeaderPos)
dd.hHeaderFont = CreateFont(0, CFF_RAWSIZE, r.bottom / 2, FW_BOLD, DEFAULT_PITCH|FF_DONTCARE, ANSI_CHARSET, _T("Trebuchet MS")); // IE4.01SP2+
HGDIOBJ hOrgFont = SelectObject(dis.hDC, dd.hHeaderFont);
DrawHorzGradient(dis.hDC, r.left, r.top, r.right, r.bottom - line, RGB(22, 77, 160), RGB(29, 100, 207));
DrawHorzGradient(dis.hDC, r.left, r.bottom - line, r.right, r.bottom, RGB(255, 142, 42), RGB(190, 90, 2));
SetBkMode(dis.hDC, TRANSPARENT);
if (!dd.FinalHeaderPos)
{
r2 = r;
DrawText(dis.hDC, txt, cch, &r2, dt|DT_CALCRECT);
dd.FinalHeaderPos = r.right - (r2.right - r2.left);
dd.FinalHeaderPos -= DlgUnitToPixelX(hwndDlg, 7); // Margin
}
r.left += dd.AnimPos;
SetTextColor(dis.hDC, RGB(0, 0, 0)), OffsetRect(&r, +shadow, +shadow);
DrawText(dis.hDC, txt, cch, &r, dt);
SetTextColor(dis.hDC, RGB(255, 255, 255)), OffsetRect(&r, -shadow, -shadow);
DrawText(dis.hDC, txt, cch, &r, dt);
SelectObject(dis.hDC, hOrgFont);
return TRUE;
}
break;
case WM_TIMER:
if (wParam == ABOUTDLGDATA::TID_HEADER)
{
INT finalpos = dd.FinalHeaderPos, dir;
if (dd.AnimSpeed >= 4)
{
dd.AnimPos += (dir = (dd.AnimPos >= finalpos)) ? -(INT)dd.AnimSpeed : +(INT)dd.AnimSpeed;
if (dd.AnimDir != dir) dd.AnimDir = dir, dd.AnimSpeed /= 2;
}
else
{
dd.AnimPos = finalpos;
SetTimer(hwndDlg, ABOUTDLGDATA::TID_HEADER, INFINITE, NULL);
}
InvalidateRect(GetDlgItem(hwndDlg, IDC_ABOUTHEADER), NULL, false);
}
break;
case WM_DESTROY:
DeleteObject(dd.hFont);
DeleteObject(dd.hBoldFont);
break;
case WM_INITDIALOG:
{
CenterOnParent(hwndDlg);
HFONT fontnorm = CreateFont(13, FW_NORMAL, FIXED_PITCH|FF_DONTCARE, _T("Tahoma")),
fontbold = CreateFont(13, FW_BOLD, FIXED_PITCH|FF_DONTCARE, _T("Tahoma"));
if (!fontbold) {
fontnorm = CreateFont(12, FW_NORMAL, FIXED_PITCH|FF_DONTCARE, _T("MS Shell Dlg"));
fontbold = CreateFont(12, FW_BOLD, FIXED_PITCH|FF_DONTCARE, _T("MS Shell Dlg"));
HFONT fontnorm = CreateFontPt(hwndDlg, 8, FW_NORMAL, FIXED_PITCH|FF_DONTCARE, ANSI_CHARSET, _T("Tahoma")),
fontbold = CreateFontPt(hwndDlg, 8, FW_BOLD, FIXED_PITCH|FF_DONTCARE, ANSI_CHARSET, _T("Tahoma"));
if (!fontbold && (SupportsWNT4() || SupportsW95())) { // Tahoma shipped with 98+ and 2000+
fontnorm = CreateFontPt(hwndDlg, 8, FW_NORMAL, FIXED_PITCH|FF_DONTCARE, ANSI_CHARSET, _T("MS Shell Dlg"));
fontbold = CreateFontPt(hwndDlg, 8, FW_BOLD, FIXED_PITCH|FF_DONTCARE, ANSI_CHARSET, _T("MS Shell Dlg"));
}
dd.hFont = fontnorm, dd.hBoldFont = fontbold;
SendDlgItemMessage(hwndDlg, IDC_ABOUTVERSION, WM_SETFONT, (WPARAM)fontbold, FALSE);
SendDlgItemMessage(hwndDlg, IDC_ABOUTCOPY, WM_SETFONT, (WPARAM)fontnorm, FALSE);
SendDlgItemMessage(hwndDlg, IDC_ABOUTPORTIONS, WM_SETFONT, (WPARAM)fontnorm, FALSE);
@ -855,6 +890,7 @@ INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
SetDlgItemText(hwndDlg, IDC_ABOUTCOPY, COPYRIGHT);
SetDlgItemText(hwndDlg, IDC_OTHERCONTRIB, CONTRIB);
SetDlgItemText(hwndDlg, IDC_NSISVER, g_sdata.branding);
SetTimer(hwndDlg, ABOUTDLGDATA::TID_HEADER, 50, NULL);
break;
}
case WM_COMMAND:
@ -863,10 +899,6 @@ INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
// fall through
case WM_CLOSE:
return EndDialog(hwndDlg, TRUE);
case WM_DESTROY:
DeleteObject((HGDIOBJ)SendDlgItemMessage(hwndDlg, IDC_ABOUTVERSION, WM_GETFONT, 0, 0));
DeleteObject((HGDIOBJ)SendDlgItemMessage(hwndDlg, IDC_ABOUTCOPY, WM_GETFONT, 0, 0));
break;
case WM_APP: showversion:
{
TCHAR buf[200], showver = wParam != 0;
@ -878,6 +910,15 @@ INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
return FALSE;
}
INT_PTR ShowAboutDialog(HWND hwndOwner)
{
ABOUTDLGDATA dd;
g_ModalDlgData = ⅆ
dd.hHeaderFont = NULL, dd.FinalHeaderPos = 0;
dd.AnimSpeed = 55, dd.AnimPos = 0, dd.AnimDir = 0;
return DialogBox(g_sdata.hInstance, MAKEINTRESOURCE(DLG_ABOUT), hwndOwner, API_cast<DLGPROC>(AboutProc));
}
static void EnableSymbolSetButtons(HWND hwndDlg)
{
LRESULT n = SendDlgItemMessage(hwndDlg, IDC_SYMBOLS, LB_GETCOUNT, 0, 0);
@ -1052,10 +1093,7 @@ INT_PTR CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
break;
case IDC_LOAD:
case IDC_SAVE:
{
g_symbol_set_mode = IDC_LOAD == LOWORD(wParam) ? 1 : 2;
DialogBox(g_sdata.hInstance,MAKEINTRESOURCE(DLG_SYMBOLSET),hwndDlg,(DLGPROC)SymbolSetProc);
}
ShowSymbolSetDialog(hwndDlg, IDC_LOAD == LOWORD(wParam));
break;
case IDC_DEL:
{
@ -1134,23 +1172,32 @@ INT_PTR CALLBACK CompressorProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
return FALSE;
}
INT_PTR CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
static void FixSimpleComboBoxSizeBug(HWND hCombo) // Fix Win10 CBS_SIMPLE height drawing bug when DPI != 96
{
RECT r;
GetWindowRect(hCombo, &r);
SetWindowPos(hCombo, 0, 0, 0, RectW(r), RectH(r)-1, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE);
SetWindowPos(hCombo, 0, 0, 0, RectW(r), RectH(r), SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOMOVE|SWP_FRAMECHANGED);
}
#define SymbolSetDlgDpiChanged(hwndDlg) ( FixSimpleComboBoxSizeBug(GetDlgItem((hwndDlg), IDC_NAMES)) )
static INT_PTR CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
SYMSETDLGDATA &dd = *(SYMSETDLGDATA*) g_ModalDlgData;
switch(msg) {
case WM_INITDIALOG:
{
HWND hwndEdit;
HKEY hKey;
CenterOnParent(hwndDlg);
EnableWindow(GetDlgItem(hwndDlg, IDC_DEL), FALSE);
if (OpenRegSettingsKey(hKey)) {
HKEY hSubKey;
if (RegOpenKeyEx(hKey,REGSYMSUBKEY,0,KEY_READ,&hSubKey) == ERROR_SUCCESS) {
if (RegOpenKeyEx(hKey, REGSYMSUBKEY, 0, KEY_READ, &hSubKey) == ERROR_SUCCESS) {
TCHAR subkey[1024];
int i=0;
while (RegEnumKey(hSubKey,i,subkey,sizeof(subkey)) == ERROR_SUCCESS) {
while (RegEnumKey(hSubKey, i, subkey, sizeof(subkey)) == ERROR_SUCCESS) {
SendDlgItemMessage(hwndDlg, IDC_NAMES, CB_ADDSTRING, 0, (LPARAM)subkey);
i++;
}
@ -1158,11 +1205,9 @@ INT_PTR CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
}
RegCloseKey(hKey);
}
hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), 0, 0, 0); // Handle of list
hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), hwndEdit, 0, 0); //Handle of edit box
HWND hwndEdit = GetComboEdit(GetDlgItem(hwndDlg, IDC_NAMES));
SendMessage(hwndEdit, EM_LIMITTEXT, (WPARAM)SYMSETNAME_MAXLEN, 0);
if(g_symbol_set_mode == 1) { //Load
if (dd.LoadingMode) {
SetWindowText(hwndDlg, LOAD_SYMBOL_SET_DLG_NAME);
SetWindowText(GetDlgItem(hwndDlg, IDOK), LOAD_BUTTON_TEXT);
SendMessage(hwndEdit, EM_SETREADONLY, (WPARAM)TRUE, 0);
@ -1171,6 +1216,7 @@ INT_PTR CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
SetWindowText(hwndDlg, SAVE_SYMBOL_SET_DLG_NAME);
SetWindowText(GetDlgItem(hwndDlg, IDOK), SAVE_BUTTON_TEXT);
}
SymbolSetDlgDpiChanged(hwndDlg);
break;
}
case WM_COMMAND:
@ -1178,28 +1224,18 @@ INT_PTR CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
switch (LOWORD(wParam)) {
case IDOK:
{
HWND hwndEdit;
TCHAR name[SYMSETNAME_MAXLEN+1];
hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), 0, 0, 0); // Handle of list
hwndEdit = FindWindowEx(GetDlgItem(hwndDlg, IDC_NAMES), hwndEdit, 0, 0); //Handle of edit box
HWND hwndEdit = GetComboEdit(GetDlgItem(hwndDlg, IDC_NAMES));
SendMessage(hwndEdit, WM_GETTEXT, (WPARAM)COUNTOF(name), (LPARAM)name);
if(!*name) {
if(g_symbol_set_mode == 1) { //Load
MessageBox(hwndDlg,LOAD_SYMBOL_SET_MESSAGE,LOAD_SYMBOL_SET_DLG_NAME,MB_OK|MB_ICONEXCLAMATION);
}
else {
MessageBox(hwndDlg,SAVE_SYMBOL_SET_MESSAGE,SAVE_SYMBOL_SET_DLG_NAME,MB_OK|MB_ICONEXCLAMATION);
}
if (!*name) {
LPCTSTR msg = dd.LoadingMode ? LOAD_SYMBOL_SET_MESSAGE : SAVE_SYMBOL_SET_MESSAGE;
LPCTSTR tit = dd.LoadingMode ? LOAD_SYMBOL_SET_DLG_NAME : SAVE_SYMBOL_SET_DLG_NAME;
MessageBox(hwndDlg, msg, tit, MB_OK|MB_ICONEXCLAMATION);
}
else {
HWND hwndParent = GetParent(hwndDlg);
if(g_symbol_set_mode == 1) { //Load
SendMessage(hwndParent, WM_MAKENSIS_LOADSYMBOLSET, (WPARAM)name, (LPARAM)NULL);
}
else {
SendMessage(hwndParent, WM_MAKENSIS_SAVESYMBOLSET, (WPARAM)name, (LPARAM)NULL);
}
UINT msg = dd.LoadingMode ? WM_MAKENSIS_LOADSYMBOLSET : WM_MAKENSIS_SAVESYMBOLSET;
SendMessage(hwndParent, msg, (WPARAM)name, (LPARAM)NULL);
EndDialog(hwndDlg, TRUE);
}
break;
@ -1245,6 +1281,15 @@ INT_PTR CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
return FALSE;
}
INT_PTR ShowSymbolSetDialog(HWND hwndOwner, BOOL LoadingSet)
{
SYMSETDLGDATA dd = { g_ModalDlgData, LoadingSet };
g_ModalDlgData = &dd;
INT_PTR retval = DialogBox(g_sdata.hInstance, MAKEINTRESOURCE(DLG_SYMBOLSET), hwndOwner, API_cast<DLGPROC>(SymbolSetProc));
g_ModalDlgData = dd.pOldMDD; // Restore the old pointer
return retval;
}
void SetCompressor(NCOMPRESSOR compressor)
{
int i;

View file

@ -33,6 +33,11 @@
#undef _RICHEDIT_VER
// Defines
#define DpiAwarePerMonitor2() ( FALSE ) // Not yet
#define DpiAwarePerMonitor() ( FALSE )
#define SupportsWNT4() ( sizeof(void*) == 4 && !DpiAwarePerMonitor() ) // NT4 does not support the MultiMon API
#define SupportsW9X() ( sizeof(TCHAR) == 1 )
#define SupportsW95() ( FALSE && SupportsW9X() && !DpiAwarePerMonitor() )
#define NSIS_URL "http://nsis.sourceforge.net/"
#define NSIS_FORUM_URL "http://forums.winamp.com/forumdisplay.php?forumid=65"
#define NSIS_UC_URL "http://nsis.sourceforge.net/update.php?version="
@ -155,13 +160,25 @@ int compressor_strings[] = {IDS_SCRIPT,
// Extern Variables
extern const TCHAR* NSISW_VERSION;
extern void* g_ModalDlgData;
DWORD WINAPI MakeNSISProc(LPVOID TreadParam);
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK DialogResize(HWND hWnd, LPARAM /* unused*/);
INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
typedef struct {
enum { TID_HEADER = 1 };
HFONT hHeaderFont, hFont, hBoldFont;
INT AnimPos, AnimDir;
UINT AnimSpeed, FinalHeaderPos;
} ABOUTDLGDATA;
INT_PTR ShowAboutDialog(HWND hwndOwner);
INT_PTR CALLBACK SettingsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK SymbolSetProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
typedef struct {
void*pOldMDD;
BOOL LoadingMode;
} SYMSETDLGDATA;
INT_PTR ShowSymbolSetDialog(HWND hwndOwner, BOOL LoadingSet);
INT_PTR CALLBACK CompressorProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
void SetScript(const TCHAR *script, bool clearArgs = true);
void CompileNSISScript();

View file

@ -2,22 +2,14 @@
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="Nullsoft.NSIS.makensisw" type="win32"/>
<description>MakeNSIS Wrapper</description>
<dependency>
<dependentAssembly>
<dependency><dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
</dependentAssembly></dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"><security>
<requestedPrivileges><requestedExecutionLevel level="asInvoker" uiAccess="false"/></requestedPrivileges>
</security></trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"><application>
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
</application>
</compatibility>
</application></compatibility>
</assembly>

View file

@ -36,14 +36,12 @@
#define IDI_ASSOC_NSH 113
#define IDB_LOGO 115
#define DLG_SETTINGS 116
#define IDB_BITMAP1 120
#define IDB_TOOLBAR 122
#define DLG_COMPRESSOR 124
#define DLG_SYMBOLSET 125
#define IDB_TOOLBAR24 129
#define IDB_TOOLBAR24D 130
#define IDB_BITMAP2 131
#define IDB_TOOLBAR24H 132
#define IDB_TOOLBAR24H 131
#define DLG_WNDSPY 133
#define IDC_VERSION 200
@ -55,6 +53,7 @@
#define IDC_CONTRIB 223
#define IDC_NSISVER 224
#define IDC_OTHERCONTRIB 225
#define IDC_ABOUTHEADER 226
#define IDC_RIGHT 230
#define IDC_LEFT 231
#define IDC_CLEAR 232

View file

@ -179,14 +179,14 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP |
CAPTION "About MakeNSISW"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,174,104,49,15
CONTROL 115,IDC_STATIC,"Static",SS_BITMAP,0,0,233,25
LTEXT "MakeNSISW",IDC_ABOUTVERSION,14,31,219,8,SS_NOTIFY
DEFPUSHBUTTON "OK",IDOK,171,104,50,15
CONTROL "",IDC_ABOUTHEADER,"Static",SS_OWNERDRAW,0,0,233,25
LTEXT "",IDC_ABOUTVERSION,14,31,219,8,SS_NOTIFY
LTEXT "Copyright",IDC_ABOUTCOPY,14,43,220,8
LTEXT "Other Contributors:",IDC_ABOUTPORTIONS,14,56,220,10
LTEXT "",IDC_OTHERCONTRIB,27,68,206,22
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,15,97,208,1
LTEXT "NSIS",IDC_NSISVER,15,107,135,8,WS_DISABLED
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,13,97,209,1
LTEXT "NSIS",IDC_NSISVER,14,107,135,8,WS_DISABLED
END
DLG_SETTINGS DIALOGEX 0, 0, 292, 215
@ -231,7 +231,7 @@ BEGIN
WS_VSCROLL | WS_TABSTOP
END
DLG_SYMBOLSET DIALOGEX 0, 0, 190, 125
DLG_SYMBOLSET DIALOGEX 0, 0, 188, 125
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
FONT 8, "MS Shell Dlg", 0, 0, 0x0
@ -239,8 +239,8 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,78,102,50,14
PUSHBUTTON "Cancel",IDCANCEL,132,102,50,14
LTEXT "Symbol Definitions Set Name:",IDC_STATIC,6,6,101,10
COMBOBOX IDC_NAMES,6,17,174,85,CBS_SIMPLE | CBS_AUTOHSCROLL |
CBS_SORT | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_NAMES,6,17,176,80,CBS_SIMPLE | CBS_AUTOHSCROLL |
CBS_SORT | CBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "&Delete",IDC_DEL,6,102,50,14
END
@ -327,7 +327,7 @@ END
// Bitmap
//
IDB_LOGO BITMAP "logo.bmp"
//IDB_LOGO BITMAP "logo.bmp"
IDB_TOOLBAR BITMAP "toolbar.bmp"
IDB_TOOLBAR24 BITMAP "toolbar24.bmp"
IDB_TOOLBAR24D BITMAP "toolbar24d.bmp"

View file

@ -78,7 +78,7 @@ void CreateToolBar()
#ifndef _WIN64
HMODULE hMod = GetModuleHandle(_T("comctl32.dll"));
const FARPROC hasCC4_70 = sizeof(TCHAR) > 1 ? (FARPROC) TRUE : GetProcAddress(hMod, "InitCommonControlsEx"); // NT4 shipped with v4.70
const FARPROC hasCC4_71 = GetProcAddress(hMod, "DllGetVersion");
const FARPROC hasCC4_71 = (SupportsWNT4() || SupportsW95()) ? GetProcAddress(hMod, "DllGetVersion") : (FARPROC) TRUE; // IE4 shipped with v4.71
#else
const bool hasCC4_70 = true, hasCC4_71 = true;
#endif

View file

@ -199,6 +199,22 @@ void SetDialogFocus(HWND hDlg, HWND hCtl)
SendMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)hCtl, TRUE);
}
HWND GetComboEdit(HWND hCB)
{
/* CB_GETCOMBOBOXINFO crashes on 64-bit NT 5.x (KB947841).
We are left with GetComboBoxInfo(), FindWindowEx()*2 and
ChildWindowFromPoint(h,{1,1}) (docs.microsoft.com/en-us/windows/desktop/Controls/subclass-a-combo-box#). */
if (!SupportsWNT4() && !SupportsW95())
{
COMBOBOXINFO cbi;
cbi.cbSize = FIELD_OFFSET(COMBOBOXINFO, hwndList) + sizeof(HWND);
BOOL succ = GetComboBoxInfo(hCB, &cbi);
return succ ? cbi.hwndItem : (HWND)(INT_PTR) succ;
}
HWND hList = FindWindowEx(hCB, 0, 0, 0);
return FindWindowEx(hCB, hList, 0, 0);
}
void EnableDisableItems(HWND hwnd, int on)
{
const HWND hCloseBtn = GetDlgItem(hwnd, IDCANCEL);
@ -980,12 +996,79 @@ HMENU FindSubMenu(HMENU hMenu, UINT uId)
return GetMenuItemInfo(hMenu, uId, FALSE, &mii) ? mii.hSubMenu : 0;
}
HFONT CreateFont(int Height, int Weight, DWORD PitchAndFamily, LPCTSTR Face)
static FARPROC GetProcAddr(LPCSTR Mod, LPCSTR FuncName) { return GetProcAddress(LoadLibraryA(Mod), FuncName); }
static UINT DpiGetClassicSystemDpiY() { HDC hDC = GetDC(NULL); UINT dpi = GetDeviceCaps(hDC, LOGPIXELSY); ReleaseDC(NULL, hDC); return dpi; }
static HRESULT WINAPI DpiFallbackGetDpiForMonitor(HMONITOR hMon, int MDT, UINT*pX, UINT*pY) { return (*pX = *pY = DpiGetClassicSystemDpiY(), S_OK); }
static UINT WINAPI DpiFallbackGetDpiForWindow(HWND hWnd) { return 0; }
static UINT DpiNativeGetForMonitor(HMONITOR hMon)
{
return CreateFont(Height, 0, 0, 0, Weight, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
PitchAndFamily, Face);
static HRESULT(WINAPI*f)(HMONITOR, int, UINT*, UINT*);
if (!f && !((FARPROC&)f = GetProcAddr("SHCORE", "GetDpiForMonitor"))) f = DpiFallbackGetDpiForMonitor;
UINT x, y, mdt_effective_dpi = 0;
return SUCCEEDED(f(hMon, mdt_effective_dpi, &x, &y)) ? y : 0;
}
static UINT DpiGetForMonitor(HWND hWnd)
{
HMONITOR hMon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
return hMon ? DpiNativeGetForMonitor(hMon) : (UINT)(UINT_PTR) hMon;
}
UINT DpiGetForWindow(HWND hWnd)
{
UINT dpi;
if (DpiAwarePerMonitor() || DpiAwarePerMonitor2())
{
static UINT(WINAPI*f)(HWND);
if (!f && !((FARPROC&)f = GetProcAddr("USER32", "GetDpiForWindow"))) f = DpiFallbackGetDpiForWindow;
if ((dpi = f(hWnd))) return dpi;
}
if (DpiAwarePerMonitor() && (dpi = DpiGetForMonitor(hWnd))) return dpi;
return DpiGetClassicSystemDpiY();
}
int DpiScaleY(HWND hWnd, int Val)
{
return MulDiv(Val, DpiGetForWindow(hWnd), 96);
}
HFONT CreateFontHelper(INT_PTR Data, int Height, DWORD p1, LPCTSTR Face)
{
UINT16 w = LOBYTE(p1)<<2, flags = HIBYTE(p1), cs = HIWORD(LOBYTE(p1)), paf = HIWORD(HIBYTE(p1));
if (flags & CFF_DPIPT)
{
UINT dpi = (flags & CFF_DPIFROMHWND) ? DpiGetForWindow((HWND) Data) : (UINT) Data;
Height = -MulDiv(Height, dpi, 72);
}
return CreateFont(Height, 0, 0, 0, w, FALSE, FALSE, FALSE, cs, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, paf, Face);
}
static BOOL DrawHorzGradient(HDC hDC, const RECT&rect, COLOR16 r1, COLOR16 g1, COLOR16 b1, COLOR16 r2, COLOR16 g2, COLOR16 b2)
{
TRIVERTEX v[2] = { {rect.left, rect.top, r1, g1, b1, 0xffff}, {rect.right, rect.bottom, r2, g2, b2, 0xffff} };
GRADIENT_RECT r = { 0, 1 };
BOOL(WINAPI*gf)(HDC,TRIVERTEX*,ULONG,VOID*,ULONG,ULONG);
if (SupportsWNT4() || SupportsW95())
{
if (!((FARPROC&)gf = GetProcAddr("MSIMG32", "GradientFill")))
{
COLORREF orgclr = SetBkColor(hDC, RGB((((UINT)r1+r2)/2)>>8, (((UINT)g1+g2)/2)>>8, (((UINT)b1+b2)/2)>>8));
ExtTextOut(hDC, rect.left, rect.top, ETO_OPAQUE, &rect, _T(""), 0, NULL); // TODO: Actually try to draw a gradient
return TRUE|SetBkColor(hDC, orgclr);
}
}
else
gf = GradientFill;
return gf(hDC, v, 2, &r, 1, GRADIENT_FILL_RECT_H);
}
BOOL DrawHorzGradient(HDC hDC, LONG l, LONG t, LONG r, LONG b, COLORREF c1, COLORREF c2)
{
RECT rect = { l, t, r, b };
return DrawHorzGradient(hDC, rect, (UINT16)GetRValue(c1)<<8, (UINT16)GetGValue(c1)<<8, (UINT16)GetBValue(c1)<<8, (UINT16)GetRValue(c2)<<8, (UINT16)GetGValue(c2)<<8, (UINT16)GetBValue(c2)<<8);
}
long DlgUnitToPixelX(HWND hDlg, long x) { RECT r = { x, 0, 0, 0 }; MapDialogRect(hDlg, &r); return r.left; }
#ifndef SP_GRIPPER
#ifndef HTHEME

View file

@ -36,6 +36,8 @@
#define MRU_DISPLAY_LENGTH 40
#define SYMSETNAME_MAXLEN 40
template<class T> inline T API_cast(INT_PTR(CALLBACK*p1)(HWND,UINT,WPARAM,LPARAM)) { return (DLGPROC) p1; } // DLGPROC in really old SDKs return BOOL
void* MemAllocZI(SIZE_T cb);
void MemSafeFree(void*mem);
#define MemAlloc MemAllocZI
@ -53,6 +55,7 @@ void LogMessage(HWND hwnd,const TCHAR *str);
void ErrorMessage(HWND hwnd,const TCHAR *str);
void CenterOnParent(HWND hwnd);
void SetDialogFocus(HWND hDlg, HWND hCtl); // Use this and not SetFocus()!
HWND GetComboEdit(HWND hCB);
#define DisableItems(hwnd) EnableDisableItems(hwnd, 0)
#define EnableItems(hwnd) EnableDisableItems(hwnd, 1)
void EnableDisableItems(HWND hwnd, int on);
@ -82,7 +85,24 @@ bool FileExists(const TCHAR *fname);
bool OpenUrlInDefaultBrowser(HWND hwnd, LPCSTR Url);
HMENU FindSubMenu(HMENU hMenu, UINT uId);
HFONT CreateFont(int Height, int Weight, DWORD PitchAndFamily, LPCTSTR Face);
typedef enum { CFF_RAWSIZE = 0x00, CFF_DPIPT = 0x01, CFF_DPIFROMHWND = 0x02 } CREATEFONTFLAGS;
HFONT CreateFontHelper(INT_PTR Data, int Height, DWORD p1, LPCTSTR Face);
inline HFONT CreateFont(INT_PTR Data, UINT16 Flags, int Height, UINT16 Weight, BYTE PitchAndFamily, BYTE CharSet, LPCTSTR Face)
{
DWORD packed = MAKELONG(MAKEWORD(Weight>>2, Flags), MAKEWORD(CharSet, PitchAndFamily));
return CreateFontHelper(Data, Height, packed, Face);
}
inline HFONT CreateFontPt(HWND hWndDPI, int Height, UINT16 Weight, BYTE PitchAndFamily, BYTE CharSet, LPCTSTR Face)
{
return CreateFont((INT_PTR) hWndDPI, CFF_DPIFROMHWND|CFF_DPIPT, Height, Weight, PitchAndFamily, CharSet, Face);
}
BOOL DrawHorzGradient(HDC hDC, LONG l, LONG t, LONG r, LONG b, COLORREF c1, COLORREF c2);
inline long RectW(const RECT&r) { return r.right - r.left; }
inline long RectH(const RECT&r) { return r.bottom - r.top; }
long DlgUnitToPixelX(HWND hDlg, long x);
UINT DpiGetForWindow(HWND hWnd);
int DpiScaleY(HWND hWnd, int Val);
void DrawGripper(HWND hWnd, HDC hDC, const RECT&r);
static inline void GetGripperPos(HWND hwnd, RECT&r)