YOU CAN CODE!

 

With The Case Of UCanCode.net  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Overview
Features Tour 
Electronic Form Solution
Visualization & HMI Solution
Power system HMI Solution
CAD Drawing and Printing Solution

Bar code labeling Solution
Workflow Solution

Coal industry HMI Solution
Instrumentation Gauge Solution

Report Printing Solution
Graphical modeling Solution
GIS mapping solution

Visio graphics solution
Industrial control SCADA &HMI Solution
BPM business process Solution

Industrial monitoring Solution
Flowchart and diagramming Solution
Organization Diagram Solution

Graphic editor Source Code
UML drawing editor Source Code
Map Diagramming Solution

Architectural Graphic Drawing Solution
Request Evaluation
Purchase
ActiveX COM Products
Overview
Download
Purchase
Technical Support
  General Q & A
Discussion Board
Contact Us

Links

Get Ready to Unleash the Power of UCanCode .NET


UCanCode Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!

"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"


VC++ Example: Draw or fill Gradient

 
 
Carrying out a gradient fill is something very simple to do. The following code carries this out.

Aside from this function, you need to either have a CRect attribute in the class (m_rcClient), or set the width and height of the fill in the function itself. Also.

This example carries out a blue gradient fill. If you want to use other colours, then you can do so easily for Red and Green (place the calculation in the Red or Green component of the RGB call!).

It really depends how sophisticated you want to get, you typically need to balance flexibility with speed when it comes to drawing.


void PaintRect(CDC* pDC, const CRect &rc, const COLORREF& color)
{
CBrush brush(color);
pDC->FillRect(rc, &brush);
brush.DeleteObject();
}

// Fill with gradient color
void GradientFill(CDC* pDC, CRect* prc, int iSegments,COLORREF cptStart, COLORREF cptEnd)
{
COLORREF cr;
int iR = GetRValue(cptStart);
int iG = GetGValue(cptStart);
int iB = GetBValue(cptStart);

int ieB = GetBValue(cptEnd);
int ieG = GetGValue(cptEnd);
int ieR = GetRValue(cptEnd);

if(iSegments > prc->Width())
{
iSegments = prc->Width();
}

int idR = 256 * (ieR - iR) / (iSegments);
int idG = 256 * (ieG - iG) / (iSegments);
int idB = 256 * (ieB - iB) / (iSegments);

iR *= 256;
iG *= 256;
iB *= 256;

ieR *= 256;
ieG *= 256;
ieB *= 256;

int icx = prc->Width() / iSegments, iLeft = prc->left, iRight;
pDC->SelectStockObject(NULL_PEN);

for (int i = 0; i < iSegments; i++, iR += idR, iG += idG, iB += idB)
{
if (i == (iSegments - 1))
{
iRight = prc->right;
}
else
{
iRight = iLeft + icx;
}

if(iR > ieR)
iR = ieR;

if(iG > ieG)
iG = ieG;

if(iB > ieB)
iB = ieB;

cr = RGB(iR / 256, iG / 256, iB / 256);
{
PaintRect(pDC,iLeft,prc->top,iRight+1-iLeft,prc->bottom - prc->top,cr);
}
iLeft = iRight;
}
}

 

Copyright ?1998-2009 UCanCode.Net Software , all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to webmaster@ucancode.net