Gradients
-
you can do follow: void CBMSButton::GradientFillRect(HDC hDC, RECT& rc, COLORREF crLight, COLORREF crDark) { TRIVERTEX vert[2]; GRADIENT_RECT gRect; vert [0].x = rc.left; vert [0].y = rc.top; vert [0].Red = GetRValue(crLight) << 8; vert [0].Green = GetGValue(crLight) << 8; vert [0].Blue = GetBValue(crLight) << 8; vert [0].Alpha = 0x0000; // It's no use for GradientFill vert [1].x = rc.right; vert [1].y = rc.bottom; vert [1].Red = GetRValue(crDark) << 8; vert [1].Green = GetGValue(crDark) << 8; vert [1].Blue = GetBValue(crDark) << 8; vert [1].Alpha = 0x0000; gRect.UpperLeft = 0; gRect.LowerRight = 1; GradientFill(hDC, vert, 2 , &gRect, 1, GRADIENT_FILL_RECT_V); } You must import library: #pragma message(" Automatically linking with MSIMG32.LIB library") #pragma comment(lib, "MSIMG32.LIB")
-
Hi Dear...Try this.. ---------------------------------------- CRect rect,rcClient; GetClientRect(rcClient); rect = rcClient; int r1=32,g1=108,b1=244; //Any start color int r2=5,g2=55,b2=165; //Any stop color for(int i=0;iFillSolidRect(i,0,1,rect.Height(),RGB(r,g,b)); } ------------------------------------------- This is not mine code, I'm also user of this code...but work nice... OK! Good Bye ---Sumit Kapoor--- sumit_kapoor1980@hotmail.com
-
Hi Dear...Try this.. ---------------------------------------- CRect rect,rcClient; GetClientRect(rcClient); rect = rcClient; int r1=32,g1=108,b1=244; //Any start color int r2=5,g2=55,b2=165; //Any stop color for(int i=0;iFillSolidRect(i,0,1,rect.Height(),RGB(r,g,b)); } ------------------------------------------- This is not mine code, I'm also user of this code...but work nice... OK! Good Bye ---Sumit Kapoor--- sumit_kapoor1980@hotmail.com
yes, i found that artical earlier today, and i got it to work, but i had to put the code in the OnPaint overide but there is one thing i dont get about this formula r1 + (i * (r2-r1) / rect.Width()); i know what it does, and why its needed, but i dont understand how the writer came up with it.
-
hi.. for loop in above code consider < as HTML TAG so replace that with: for(int i=0;i
-
yes, i found that artical earlier today, and i got it to work, but i had to put the code in the OnPaint overide but there is one thing i dont get about this formula r1 + (i * (r2-r1) / rect.Width()); i know what it does, and why its needed, but i dont understand how the writer came up with it.
Actually... The writer do very nice thing in this code.. as u can see.. we ca make shading from any color to other in fix area.. this is only possible if we change color according to side of area..that is what he is doing.. change color but with eyes on area.. OK bye... Never consider anything Impossible before trying to solve that..---Sumit Kapoor---