Archive: A faster but limited implementation of Blue Gredient Background feature


A faster but limited implementation of Blue Gredient Background feature
Hello,
Thank you for providing us such a great little installer tool. It's really my favorate ones. I know you can make it even better. Here is my suggestion for a faster but limited :-( implementation of Blue Gredient Background feature. It relays on a new GDI routine included with windows 98/2k/me or later (as said in M$DN).

Modifications:

exehead\bgbg.c, add link Msimg32.lib to project

static LRESULT CALLBACK BG_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
...
...

// JF: made slower, reduced to 4 pixels high, because I like how it looks better/
#if 1 // YYD, if it is win 98/2k/nt, there is an new faster and good looking way
{
TRIVERTEX vert[2] ;
GRADIENT_RECT gRect;
vert [0] .x = r.left;
vert [0] .y = r.top;
vert [0] .Red = GetRValue(m_color1)<<8;
vert [0] .Green = GetGValue(m_color1)<<8;
vert [0] .Blue = GetBValue(m_color1)<<8;
vert [0] .Alpha = 0x0000;

vert [1] .x = r.right;
vert [1] .y = r.bottom;
vert [1] .Red = GetRValue(m_color2)<<8;
vert [1] .Green = GetGValue(m_color2)<<8;
vert [1] .Blue = GetBValue(m_color2)<<8;
vert [1] .Alpha = 0x0000;

gRect.UpperLeft = 0;
gRect.LowerRight = 1;
GradientFill(hdc,vert,2,&gRect,1,GRADIENT_FILL_RECT_V);
}
#else
for (y = r.top; y < r.bottom; y += 4)
{
int rv,gv,bv;
RECT rect;
HBRUSH brush;
rv = GetRValue(m_color2) * y / r.bottom + GetRValue(m_color1) * (r.bottom - y) / r.bottom;
gv = GetGValue(m_color2) * y / r.bottom + GetGValue(m_color1) * (r.bottom - y) / r.bottom;
bv = GetBValue(m_color2) * y / r.bottom + GetBValue(m_color1) * (r.bottom - y) / r.bottom;
brush = CreateSolidBrush(RGB(rv,gv,bv));
SetRect(&rect, r.left, y, r.right, y+4);
// note that we don't need to do "SelectObject(hdc, brush)"
// because FillRect lets us specify the brush as a parameter.
FillRect(hdc, &rect, brush);
DeleteObject(brush);
}
#endif


Sincerely,
YYD
http://www.dv99.com


Only problem is that as you point out, Msimg32.dll is not a standard dll on older versions of windows. Otherwise, looks okay ;)