diff --git a/Contrib/InstallOptions/InstallerOptions.cpp b/Contrib/InstallOptions/InstallerOptions.cpp index e744d43a..d9291c9a 100644 --- a/Contrib/InstallOptions/InstallerOptions.cpp +++ b/Contrib/InstallOptions/InstallerOptions.cpp @@ -32,17 +32,6 @@ static int WINAPI popstring(char *str) return 0; } -#define CC_TEXT 1 -#define CC_BK 4 - -typedef struct { - COLORREF text; - LOGBRUSH bk; - HBRUSH bkb; - int bkmode; - int flags; -} ctlcolors; - #define strcpy(x,y) lstrcpy(x,y) //#define strncpy(x,y,z) lstrcpyn(x,y,z) #define strdup(x) STRDUP(x) @@ -761,19 +750,8 @@ BOOL CALLBACK cfgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_CTLCOLORDLG: case WM_CTLCOLORBTN: case WM_CTLCOLORLISTBOX: - { - ctlcolors *c = (ctlcolors *) GetWindowLong((HWND) lParam, GWL_USERDATA); - - if (c) { - SetBkMode((HDC)wParam, c->bkmode); - if (c->flags & CC_BK) - SetBkColor((HDC)wParam, c->bk.lbColor); - if (c->flags & CC_TEXT) - SetTextColor((HDC)wParam, c->text); - - return (BOOL)c->bkb; - } - } + // let the NSIS window handle colors, it knows best + return mySendMessage(hMainWindow, WM_CTLCOLORSTATIC, wParam, lParam); } return 0; } diff --git a/Plugins/InstallOptions.dll b/Plugins/InstallOptions.dll index 28c0462a..93dcc54a 100644 Binary files a/Plugins/InstallOptions.dll and b/Plugins/InstallOptions.dll differ diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index 7ab8a535..13896f57 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -104,13 +104,32 @@ static BOOL NSISCALL _HandleStaticBkColor(UINT uMsg, WPARAM wParam, LPARAM lPara case WM_CTLCOLORBTN: { ctlcolors *c = (ctlcolors *)GetWindowLong((HWND)lParam, GWL_USERDATA); - + if (c) { - SetBkMode((HDC)wParam, c->bkmode); - if (c->flags & CC_BK) - SetBkColor((HDC)wParam, c->bk.lbColor); + COLORREF text; + LOGBRUSH lh; + + text = c->text; + if (c->flags & CC_TEXT_SYS) + text = GetSysColor(text); if (c->flags & CC_TEXT) - SetTextColor((HDC)wParam, c->text); + SetTextColor((HDC)wParam, text); + + SetBkMode((HDC)wParam, c->bkmode); + + lh.lbColor = c->bkc; + if (c->flags & CC_BK_SYS) + lh.lbColor = GetSysColor(lh.lbColor); + if (c->flags & CC_BK) + SetBkColor((HDC)wParam, lh.lbColor); + + if (c->flags & CC_BKB) + { + lh.lbStyle = c->lbStyle; + if (c->bkb) + DeleteObject(c->bkb); + c->bkb = CreateBrushIndirect(&lh); + } return (BOOL)c->bkb; } @@ -364,7 +383,6 @@ static int CALLBACK WINAPI BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lPara BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - BOOL bNextPage=FALSE; if (uMsg == WM_INITDIALOG || uMsg == WM_NOTIFY_OUTER_NEXT) { page *this_page; @@ -414,7 +432,6 @@ BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) SendMessage(m_curwnd, WM_NOTIFY_INIGO_MONTOYA, 0, 0); nextPage: - bNextPage=FALSE; m_page+=m_delta; this_page+=m_delta; @@ -459,8 +476,8 @@ nextPage: my_SetWindowText(hwndDlg,g_tmp); #ifdef NSIS_SUPPORT_CODECALLBACKS + // custom page or user used abort in prefunc if (ExecuteCodeSegment(this_page->prefunc, NULL) || !this_page->dlg_id) { - bNextPage=TRUE; goto nextPage; } #endif //NSIS_SUPPORT_CODECALLBACKS @@ -516,9 +533,6 @@ skipPage: ui_dlg_visible = 1; } - if (bNextPage) - goto nextPage; - return FALSE; } diff --git a/Source/exehead/bgbg.c b/Source/exehead/bgbg.c index 7384d90c..e0bdd902 100644 --- a/Source/exehead/bgbg.c +++ b/Source/exehead/bgbg.c @@ -29,7 +29,11 @@ LRESULT CALLBACK BG_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) PAINTSTRUCT ps; HDC hdc=BeginPaint(hwnd,&ps); RECT r; + LOGBRUSH lh; int ry; + + lh.lbStyle = BS_SOLID; + GetClientRect(hwnd,&r); // this portion by Drew Davidson, drewdavidson@mindspring.com ry=r.bottom; @@ -42,7 +46,8 @@ LRESULT CALLBACK BG_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) rv = (GetRValue(c2) * r.top + GetRValue(c1) * (ry-r.top)) / ry; gv = (GetGValue(c2) * r.top + GetGValue(c1) * (ry-r.top)) / ry; bv = (GetBValue(c2) * r.top + GetBValue(c1) * (ry-r.top)) / ry; - brush = CreateSolidBrush(RGB(rv,gv,bv)); + lh.lbColor = RGB(rv,gv,bv); + brush = CreateBrushIndirect(&lh); // note that we don't need to do "SelectObject(hdc, brush)" // because FillRect lets us specify the brush as a parameter. FillRect(hdc, &r, brush); @@ -53,18 +58,31 @@ LRESULT CALLBACK BG_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (header->bg_textcolor != -1) { - HFONT newFont, oldFont; - newFont = CreateFont(40,0,0,0,FW_BOLD,TRUE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,"Garamond"); + HFONT oldFont; + HFONT newFont = CreateFont( + 40, + 0, + 0, + 0, + FW_BOLD, + TRUE, + FALSE, + FALSE, + DEFAULT_CHARSET, + OUT_DEFAULT_PRECIS, + CLIP_DEFAULT_PRECIS, + DEFAULT_QUALITY, + DEFAULT_PITCH, + "Garamond" + ); if (newFont) { - static char buf[256]; r.left=16; r.top=8; - my_GetWindowText(hwnd,buf,sizeof(buf)); SetBkMode(hdc,TRANSPARENT); SetTextColor(hdc,header->bg_textcolor); oldFont = SelectObject(hdc,newFont); - DrawText(hdc,buf,-1,&r,DT_TOP|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX); + DrawText(hdc,g_caption,-1,&r,DT_TOP|DT_LEFT|DT_SINGLELINE|DT_NOPREFIX); SelectObject(hdc,oldFont); DeleteObject(newFont); } diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index d086c4c9..328589e5 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -739,16 +739,6 @@ static int NSISCALL ExecuteEntry(entry *entry_) case EW_SETCTLCOLORS: { ctlcolors *c = (ctlcolors *)(g_blocks[NB_CTLCOLORS].offset + parm1); - - if (c->flags & CC_TEXT_SYS) - c->text = GetSysColor(c->text); - if (c->flags & CC_BK_SYS) - c->bk.lbColor = GetSysColor(c->bk.lbColor); - if (c->flags & CC_BKB) - c->bkb = CreateBrushIndirect(&c->bk); - - c->flags &= ~(CC_BK_SYS|CC_TEXT_SYS|CC_BKB); - SetWindowLong((HWND) GetIntFromParm(0), GWL_USERDATA, (long) c); } break; diff --git a/Source/exehead/fileform.h b/Source/exehead/fileform.h index 1346452a..79c2755b 100644 --- a/Source/exehead/fileform.h +++ b/Source/exehead/fileform.h @@ -397,7 +397,8 @@ typedef struct typedef struct { COLORREF text; - LOGBRUSH bk; + COLORREF bkc; + UINT lbStyle; HBRUSH bkb; int bkmode; int flags; diff --git a/Source/exehead/util.c b/Source/exehead/util.c index 51444765..9c2e6505 100644 --- a/Source/exehead/util.c +++ b/Source/exehead/util.c @@ -58,10 +58,10 @@ HANDLE NSISCALL myCreateProcess(char *cmd, char *dir) return ProcInfo.hProcess; } -BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val) +/*BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val) { return SendMessage(hWnd,WM_SETTEXT,0,(LPARAM)val); -} +}*/ BOOL NSISCALL my_SetDialogItemText(HWND dlg, UINT idx, const char *val) { diff --git a/Source/exehead/util.h b/Source/exehead/util.h index cf559469..df409ef8 100644 --- a/Source/exehead/util.h +++ b/Source/exehead/util.h @@ -16,8 +16,8 @@ WIN32_FIND_DATA * NSISCALL file_exists(char *buf); char * NSISCALL my_GetTempFileName(char *buf, const char *dir); int NSISCALL my_PIDL2Path(char *out, LPITEMIDLIST idl); -BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val); -//#define my_SetWindowText SetWindowText +//BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val); +#define my_SetWindowText SetWindowText BOOL NSISCALL my_SetDialogItemText(HWND dlg, UINT idx, const char *val); //int NSISCALL my_GetWindowText(HWND hWnd, char *val, int size); #define my_GetWindowText GetWindowText diff --git a/Source/script.cpp b/Source/script.cpp index 4113ebe5..87b72f73 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -3573,18 +3573,18 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) if (!strcmpi(line.gettoken_str(a+1),"transparent")) { c.flags|=CC_BKB; - c.bk.lbStyle=BS_NULL; + c.lbStyle=BS_NULL; c.bkmode=TRANSPARENT; } else { p=line.gettoken_str(a+1); if (*p) { int v=strtoul(p,&p,16); - c.bk.lbColor=((v&0xff)<<16)|(v&0xff00)|((v&0xff0000)>>16); + c.bkc=((v&0xff)<<16)|(v&0xff00)|((v&0xff0000)>>16); c.flags|=CC_BK|CC_BKB; } - c.bk.lbStyle=BS_SOLID; + c.lbStyle=BS_SOLID; c.bkmode=OPAQUE; } @@ -3599,10 +3599,10 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) if (a == 3) { c.flags|=CC_BK|CC_BKB; - c.bk.lbStyle=BS_NULL; + c.lbStyle=BS_NULL; if (!*line.gettoken_str(a)) { - c.bk.lbColor=COLOR_BTNFACE; + c.bkc=COLOR_BTNFACE; c.flags|=CC_BK_SYS; } c.flags|=CC_TEXT;