0

I was looking into getting a breadcrumbs 'bar' for my application (that list files and folders that I explore myself from raw data (so not via system calls)) and ran into this article:

Is there an edit control for Delphi that allows path editing?

There I noticed an interesting post and piece of code:

http://specials.rejbrand.se/dev/controls/breadcrumb/readme.html

So I wanted to give it a test drive. But I have to be honest, I know very little about components and how to make them etc. and even less about Delphi / Object Pascal so I sought guidance here:

How to install a component from .pas file in delphi?

That worked to the point where I tried to compile the resulting package, using C++ Builder 2009.

I ran into a linker error I can't quite fix:

[ILINK32 Error] Error: Unresolved external 'PathCanonicalizeW' referenced from ...

I wonder if you would know how to fix this ?

I must say I don't like the dependency on installed components much, I like to be able to move the project to a new PC with a clean compiler install and just build it. But if this works easily from just the PAS file then I should be able to do that first during a move.

Your feedback appreciated.

Community
  • 1
  • 1
Peter
  • 1,334
  • 12
  • 28

1 Answers1

1

Components must be installed into the IDE in order for them to appear in design-time editors. Otherwise, simply add the .pas file to your app project and manually instantiate the component class in code at runtime.

As for the linker error, you need to link to Shlwapi.lib to resolve the function reference. Either add the .lib file directly to your project, or at least add a #pragma comment(lib, "Shlwapi.lib") statement to one of your .cpp files. You can find the .lib file in the $(BDS)\lib\psdk folder.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Thanks. I tried your suggestion to add to a (new) project and added the pragma, and that compiles, but when I try to instanciate a class ( TDirBreadcrumbBar *MyBar = new TDirBreadcrumbBar ; ) I get [BCC32 Error] Unit1.cpp(19): E2451 Undefined symbol 'TDirBreadcrumbBar' There obviously is no .h file to include here, so how would I proceed from here ? – Peter Sep 20 '15 at 16:31
  • Compile the .pas file first. An .hpp file will be generated. Then `#include` that in your C++ code. – Remy Lebeau Sep 20 '15 at 16:45
  • Thanks @Remy that works but now I run into other BCC32 compiler issues (E2109) in the .hpp file. – Peter Sep 21 '15 at 13:14
  • I made the component instead (to test) and added the component to a fresh project. Compiled it and eventually ran into the same errors. Is it possible a (working) .pas file is not always meant to work in C++ Builder ? – Peter Sep 22 '15 at 15:42
  • It is possible. Not everything in Delphi has a direct C++ equivilent, and vice versa. Hard to say for sure what is causing the error in your situation without seeing the actual code and the specific line that is causing the error. – Remy Lebeau Sep 22 '15 at 16:37
  • I (temporary) edited the initial Q to contain the hpp code and error – Peter Sep 22 '15 at 19:50
  • You should not be getting that error on every single line. Which line is #80 exactly? On the other hand, everything is being declared as `__published`, because the original .pas file was doing that, which it should not be doing in the first place. That needs to be fixed. Those declarations should be `public` instead. Only properties and events can be `published`. – Remy Lebeau Sep 22 '15 at 22:21
  • Ah, so I suppose `type TRectState = (rsNormal, rsHover, rsDown); TRectStateArray = array of TRectState; const ARROW_SIZE = 8; ARROW_BOX_SIZE = 16; SEP_PADDING = 16; INDENT = 3; VERT_PADDING = 3;` should be moved outside the class or made `private` or `public`. – Andreas Rejbrand Sep 22 '15 at 22:44
  • In Delphi, the first members of a class are implicitly `published` until a different access specifier is declared. So yes, I would suggest you move them to `public` (`published` members are implicitly `public` anyway). – Remy Lebeau Sep 23 '15 at 04:54
  • Thanks guys. Making those declarations public fixed the compile issue. I'm also finding that the TDirBreadcrumbBar is not what I need because my content is custom. So I tried the TBreadcrumbBar but now I run into other issues (division by zero). I'll ask Andreas privately first, since the code online will be changed anyway I assume. – Peter Sep 23 '15 at 09:10