Board index » cppbuilder » THintWindow linking problem

THintWindow linking problem


2008-02-03 07:57:10 PM
cppbuilder9
Hi all,
I have made an own class to overwrite the Paint method of the THintWindow
class:
Header file:
class TExtraHintWindow : public THintWindow
{
protected:
void __fastcall Paint(void);
public:
__fastcall TExtraHintWindow(TComponent *Owner);
};
//---------------------------------------------------------------------------
Source file:
__fastcall TExtraHintWindow::TExtraHintWindow(TComponent *Owner)
: THintWindow(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TExtraHintWindow::Paint(void)
{
Canvas->Font->Color = clRed;
THintWindow::Paint();
}
//---------------------------------------------------------------------------
Main form source file:
class THauptformular : public TForm
{
....
private:
TExtraHintWindow *HintFenster;
.....
}
//---------------------------------------------------------------------------
When I compile this and link my program it works fine.
But when I use the new statement in the coding:
__fastcall THauptformular::THauptformular(TComponent *Owner)
: TForm(Owner)
{
HintFenster = new TExtraHintWindow(this);
}
//---------------------------------------------------------------------------
then I get no compiling but linking errors:
[Linking Error] Error: Unsolved external '__fastcall
Controls::THintWindow::NCPaint(void *)' referenced from
C:\DOKUMENTE UND EINSTELLUNGEN\MARIUS\EIGENE DATEIEN\BORLAND
STUDIO-PROJEKTE\MAURO MANAGER 1.5\DEBUG_BUILD\HAUPTFENSTER.OBJ
This file Hauptfenster is my main form source file. I don't understand the
problem here. Has someone an idea?
Regards,
Mauro
 
 

Re:THintWindow linking problem

Hi Mauro
Mauro says:
Quote
Hi all,

I have made an own class to overwrite the Paint method of the THintWindow
class:

Header file:

class TExtraHintWindow : public THintWindow
{
protected:
void __fastcall Paint(void);
paint functions are usually virtual and there is no need to write void:
virtual void __fastcall Paint();
Have You added the TExtraHintWindow unit to Your project ?
Have You at some point had a procedure called NCPaint ?
if so then do a save file and a Build All Project sometimes when
undo is used it is not registered.
In my source files (BCB5) there are no NCPaint there are some WMNCPaint
thats the closest, so the error does look strange.
Kind regards
Asger
 

Re:THintWindow linking problem

Hi Asger,
yes, it is virtual, but why should I not write void? Could you explain it to
me?
Quote
Have You added the TExtraHintWindow unit to Your project ?
Yes, my Hauptfenster.h where the class is defined is included in
Hauptfenster.cpp
Quote
Have You added the TExtraHintWindow unit to Your project ?
No, I haven't
Quote
if so then do a save file and a Build All Project sometimes when
undo is used it is not registered.
I know the problem with undo, I have tried to build All Projects, but
without success.
Quote
thats the closest, so the error does look strange.
For me it is very strange, too. I mean my project is a very big one, but I
don't understand why NCPaint method is mentioned by linker...
Best regards,
Marius
"Asger Joergensen" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote

Hi Mauro

Mauro says:
>Hi all,
>
>I have made an own class to overwrite the Paint method of the THintWindow
>class:
>
>Header file:
>
>class TExtraHintWindow : public THintWindow
>{
>protected:
>void __fastcall Paint(void);

paint functions are usually virtual and there is no need to write void:
virtual void __fastcall Paint();

Have You added the TExtraHintWindow unit to Your project ?

C
if so then do a save file and a Build All Project sometimes when
undo is used it is not registered.
In my source files (BCB5) there are no NCPaint there are some WMNCPaint
thats the closest, so the error does look strange.

Kind regards
Asger
 

{smallsort}

Re:THintWindow linking problem

Sorry I have make a mistake in my answers, it shoul be:
Quote
Have You added the TExtraHintWindow unit to Your project ?
Yes, my Hauptfenster.h where the class is defined is included in
Hauptfenster.cpp
Quote
Have You at some point had a procedure called NCPaint ?
No, I haven't
 

Re:THintWindow linking problem

I have added the virtual method NCPaint to my class:
class TExtraHintWindow : public THintWindow
{
protected:
virtual void __fastcall Paint();
virtual void __fastcall NCPaint(HDC DC);
public:
__fastcall TExtraHintWindow(TComponent *Owner);
};
This NCPaint method is a method in the class THint window.
Then in my source file I made:
void __fastcall TExtraHintWindow::NCPaint(HDC DC)
{
THintWindow::NCPaint(DC);
}
With this coding the linkg error comes again but when I remove the line
inside the linkg error disappears but in my program sometimes a border is
drawn
around the hint and somethimes not. (Because of the missing NCPaint method
that is responsible for painting the border of the hint element,
mysterious...)
 

Re:THintWindow linking problem

Hi Mauro
Mauro says:
Quote

Hi Asger,

yes, it is virtual, but why should I not write void? Could you explain it to
me?
I'm not sure, but I think You can write void if You want to,
but the normal pactice is not to write void, it is only done
in the help files to show that is not parameters.
Quote

>Have You added the TExtraHintWindow unit to Your project ?

Yes, my Hauptfenster.h where the class is defined is included in
Hauptfenster.cpp

>Have You added the TExtraHintWindow unit to Your project ?

No, I haven't
If not, You should add Hauptfenster.cpp to Your project,
but I think You must have done that.
Kind regards
Asger
 

Re:THintWindow linking problem

Hi Mauro
Quote
With this coding the linkg error comes again but when I remove the line
inside the linkg error disappears but in my program sometimes a border is
drawn
around the hint and somethimes not. (Because of the missing NCPaint method
that is responsible for painting the border of the hint element,
mysterious...)
I have no solution, only a work arround.
Take care of all the painting Your self:
TRect Rct = ClientRect;
Canvas->Brush->Color = TheBackgroundColorYouWant;
Canvas->FillRect(Rct);
Canvas->Brush->Color = TheBorderColorYouWant;
int B = YourBorderWidth;
while(B>0)
{
Canvas->FrameRect(Rct);
::InflateRect(&Rct, -1,-1);
--B;
}
::DrawText(Canvas->Handle, Caption.c_str(),Caption.Length(), &Rct,
DT_CENTER | DT_VCENTER // text-drawing flags
);
If You use DT_CALCRECT in the flags You get the window size
needed for the text.
You can see more about the different flags in the DrawText help
This way You can have multiline hinst that are nicely centered.
Kind regards
Asger
 

Re:THintWindow linking problem

Hi Asger,
yes, I have also thought about this solution and it works. :-)
Thanks for all hints!
Regards,
Marius
 

Re:THintWindow linking problem

"Mauro" < XXXX@XXXXX.COM >wrote in message
Quote
[Linking Error] Error: Unsolved external '__fastcall
Controls::THintWindow::NCPaint(void *)' referenced from
This has been discussed many times before. Pleas go to www.deja.com
and search through the newsgroup archives.
Gambit