BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Linker Error - GradientFill

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics)
View previous topic :: View next topic  
Author Message
DreamChaser
Guest





PostPosted: Sun Feb 25, 2007 8:23 am    Post subject: Linker Error - GradientFill Reply with quote



I keep getting the following error

[Linker Error] Unresolved external 'GradientFill' referenced from
C:\PROGRAM FILES\BORLAND\CBUILDER5\PROJECTS\...\FRMMAIN.OBJ

But code insight shows the prototype/parameters

it is declared in Windows.hpp
function GradientFill; external msimg32 name 'GradientFill';

& wingdi.h
WINGDIAPI BOOL WINAPI GradientFill( IN HDC, IN PTRIVERTEX, IN ULONG, IN
PVOID, IN ULONG, IN ULONG);


Anybody get this to work? Can think of what I might be doing wrong? Know
the phase of the moon? :)

Any help would be greatly appreciated. Code follows:

DC
BCB5ent

//---------------------------------------------------------------------------
void __fastcall TMainForm::FormPaint(TObject *Sender)
{
int startColor = ColorToRGB(clBlue);
int endColor = ColorToRGB(clBlack);
TRIVERTEX vert[2];
GRADIENT_RECT gRect;

vert[0].x = 0;
vert[0].y = 0;
vert[0].Red = GetRValue(startColor);
vert[0].Green = GetGValue(startColor);
vert[0].Blue = GetBValue(startColor);
vert[0].Alpha = 0x0000;

vert[1].x = 0;
vert[1].y = 0;
vert[1].Red = GetRValue(endColor);
vert[1].Green = GetGValue(endColor);
vert[1].Blue = GetBValue(endColor);
vert[1].Alpha = 0x0000;

gRect.UpperLeft = 0;
gRect.LowerRight = 1;
GradientFill(pnlEventEditor->Handle,
vert, 2,
&gRect, 1,
GRADIENT_FILL_RECT_H
);
} //End FormPaint()
//---------------------------------------------------------------------------
Back to top
DreamChaser
Guest





PostPosted: Sun Feb 25, 2007 9:10 am    Post subject: Re: Linker Error - GradientFill Reply with quote



DreamChaser wrote:
Quote:
Remy Lebeau (TeamB) wrote:
You did not add the .lib file that tells the linker where to find the
implementation of GradientFill(). You need to add msimg32.lib to your
project. It is located in the $(BCB)\Lib\PSDK folder.

Thanks Gambit. Now is there a way to Options to include it all the time?
or is that a bad idea?
dc

OK, I tried it no errors, but now Form background is all black :(

TRect clRect = ClientRect;
int startColor = ColorToRGB(clBlue);
int endColor = ColorToRGB(clBlack);
TRIVERTEX vert[2];
GRADIENT_RECT gRect;

vert[0].x = clRect.Left;
vert[0].y = clRect.Top;
vert[0].Red = 0x0000;
vert[0].Green = 0x0000;
vert[0].Blue = 0x00FF;
vert[0].Alpha = 0x0000;

vert[1].x = clRect.Right;
vert[1].y = clRect.Bottom;
vert[1].Red = 0x0000;
vert[1].Green = 0x0000;
vert[1].Blue = 0x00FF;
vert[1].Alpha = 0x0000;

gRect.UpperLeft = 0;
gRect.LowerRight = 1;
GradientFill(Canvas->Handle,
vert, 2,
&gRect, 1,
GRADIENT_FILL_RECT_V
);
Back to top
DreamChaser
Guest





PostPosted: Sun Feb 25, 2007 9:10 am    Post subject: Re: Linker Error - GradientFill Reply with quote



Remy Lebeau (TeamB) wrote:
Quote:
"DreamChaser" <jkofsky@No-Spam.net> wrote in message
news:45e0f2e8$1 (AT) newsgroups (DOT) borland.com...

I keep getting the following error

[Linker Error] Unresolved external 'GradientFill' referenced from
C:\PROGRAM FILES\BORLAND\CBUILDER5\PROJECTS\...\FRMMAIN.OBJ

You did not add the .lib file that tells the linker where to find the
implementation of GradientFill(). You need to add msimg32.lib to your
project. It is located in the $(BCB)\Lib\PSDK folder.

Thanks Gambit. Now is there a way to Options to include it all the time?

or is that a bad idea?
dc
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sun Feb 25, 2007 9:10 am    Post subject: Re: Linker Error - GradientFill Reply with quote

"DreamChaser" <jkofsky@No-Spam.net> wrote in message
news:45e10894$1 (AT) newsgroups (DOT) borland.com...

Quote:
Now is there a way to Options to include it all the time?

No. But what you can do is alter wingdi.h to include a #pragma
comment statement that will pull in the .lib file automatically, ie:

#pragma comment(lib, "msimg32.lib")

Quote:
or is that a bad idea?

That depends on your needs.


Gambit
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sun Feb 25, 2007 9:10 am    Post subject: Re: Linker Error - GradientFill Reply with quote

"DreamChaser" <jkofsky@No-Spam.net> wrote in message
news:45e113b2$1 (AT) newsgroups (DOT) borland.com...

Quote:
OK, I tried it no errors, but now Form background is all black Sad

That is because you are specifying a very dark blue (not pure black)
as the starting and ending color. You are not using your startColor
and endColor variables anymore. Even when you were using them in your
earlier posting, you were not specifying the color values correctly,
however. Try the following instead:

// you won't find this documented by Microsoft!!!
// the color value has to be specified in the hi-order byte
#define ByteToColor16(b) (((COLOR16)(b)) << 8)

void __fastcall TForm1::FormPaint(TObject *Sender)
{
TRect clRect = ClientRect;
int startColor = ColorToRGB(clBlue);
int endColor = ColorToRGB(clBlack);
TRIVERTEX vert[2];
GRADIENT_RECT gRect;

vert[0].x = clRect.Left;
vert[0].y = clRect.Top;
vert[0].Red = ByteToColor16(GetRValue(startColor));
vert[0].Green = ByteToColor16(GetGValue(startColor));
vert[0].Blue = ByteToColor16(GetBValue(startColor));
vert[0].Alpha = 0x0000;

vert[1].x = clRect.Right;
vert[1].y = clRect.Bottom;
vert[1].Red = ByteToColor16(GetRValue(endColor));
vert[1].Green = ByteToColor16(GetGValue(endColor));
vert[1].Blue = ByteToColor16(GetBValue(endColor));
vert[1].Alpha = 0x0000;

gRect.UpperLeft = 0;
gRect.LowerRight = 1;

GradientFill(Canvas->Handle,
vert, 2,
&gRect, 1,
GRADIENT_FILL_RECT_V);
}


Gambit
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sun Feb 25, 2007 9:10 am    Post subject: Re: Linker Error - GradientFill Reply with quote

"DreamChaser" <jkofsky@No-Spam.net> wrote in message
news:45e0f2e8$1 (AT) newsgroups (DOT) borland.com...

Quote:
I keep getting the following error

[Linker Error] Unresolved external 'GradientFill' referenced from
C:\PROGRAM FILES\BORLAND\CBUILDER5\PROJECTS\...\FRMMAIN.OBJ

You did not add the .lib file that tells the linker where to find the
implementation of GradientFill(). You need to add msimg32.lib to your
project. It is located in the $(BCB)\Lib\PSDK folder.

Quote:
But code insight shows the prototype/parameters

Code Insight works off of the header files, not the libraries.


Gambit
Back to top
JD
Guest





PostPosted: Sun Feb 25, 2007 6:56 pm    Post subject: Re: Linker Error - GradientFill Reply with quote

DreamChaser <jkofsky@No-Spam.net> wrote:
Quote:

[...] Now is there a way to Options to include it all the time?

You can dynamically load it using the Win32 API LoadLibrary
instead of statically linking it. It's just a bit more code
but it allows your application to make choices should it fail
for any reason.

Quote:
[...] no errors, but now Form background is all black

I wrote a method where you pass in the parameters and it does
the work setting everything up correctly. The parameter list
is self-explainitory except for the Factor parameter.

Windows will clip any drawing that exceeds the area of the HDC
(Canvas::Handle) and Factor takes advantage of this by causing
the math to calculate a greater surface area than what actually
physically exists. The result is a much smoother gradient.

//-------------------------------------------------------------
void __fastcall TGradientListView::GradientFillObject( HDC hDC, TColor StartColor, TColor EndColor, int Width, int Height, unsigned long Mode, int Factor )
{
void *pMesh;
int NumberOfVertices, FFactor;

TRIVERTEX Vertices[3];
GRADIENT_RECT GradientRect;
GRADIENT_TRIANGLE GradientTriangle;

memset( &Vertices, 0, sizeof(TRIVERTEX) * 3 );
AssignRGBToV( StartColor, &Vertices[0] );
AssignRGBToV( EndColor, &Vertices[1] );

if( Mode == GRADIENT_FILL_TRIANGLE )
{
Vertices[ 2 ] = Vertices[ 1 ];
Vertices[ 1 ].y = (Height - 1) * Factor * 2;
Vertices[ 2 ].x = (Width - 1) * Factor * 2;
GradientTriangle.Vertex1 = 0;
GradientTriangle.Vertex2 = 1;
GradientTriangle.Vertex3 = 2;
pMesh = &GradientTriangle;
NumberOfVertices = 3;
}
else
{
Vertices[ 1 ].x = (Width - 1) * Factor;
Vertices[ 1 ].y = (Height - 1) * Factor;
GradientRect.UpperLeft = 0;
GradientRect.LowerRight = 1;
pMesh = &GradientRect;
NumberOfVertices = 2;
}
GradientFill( hDC, (TRIVERTEX*)&Vertices, NumberOfVertices, pMesh, 1, Mode );
}
//-------------------------------------------------------------
void __fastcall TGradientListView::AssignRGBToV( TColor Color, TRIVERTEX *V )
{
int C = ColorToRGB( Color );
V->Red = ( GetRValue(C) << 8 );
V->Green = ( GetGValue(C) << 8 );
V->Blue = ( GetBValue(C) << 8 );
}
//-------------------------------------------------------------

~ JD
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.