I'm trying to follow Dave Millington's code rage example from 2016 on how to use a Delphi abstract class to make an abstract class for use in a C++ Builder bpl library where you need to link to a lib file that is only available in C.
https://learndelphi.org/this-is-how-to-use-c-builder-to-extend-the-reach-of-delphi/
https://github.com/Embarcadero/CodeRage2016
I made a function called about in my concrete class called TBridge::About derived for a pure abstract delphi class which I can call sucessfully.
However when I do so Application->MessageBox falls over as it doesn't seem able to create a font resource or lacks resources.
I am assuming in am not linking some sort of necessary resource file into my C++ BPL ?
The question is I don't know which files I should be linking into the BPL to get it to display standard VCL dialogs. MessageDlg doesn't work either.
//---------------------------------------------------------------------------
#pragma hdrstop
#include "SolidBridge.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#include <windows.h>
#include <vcl.h>
#include <Vcl.Controls.hpp>
#include <Vcl.stdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Dialogs.hpp>
#include <Vcl.Dialogs.hpp>
void __fastcall TBridge::About()
{
//Application->MessageBox('Hello world!','About',MB_OK);
UnicodeString txt = "Hello world";
Application->MessageBox(L"Hello world",L"About", MB_OKCANCEL);
//MessageDlg(txt,mtInformation,TMsgDlgButtons() << mbOK,0);
}
TAbstractBridge* __stdcall SolidBridgeFactory()
{
return (TAbstractBridge*)new TBridge();
}
ResData is passed in a zero so the first line
ResHash := VCL.Graphics.GetHashCode(ResData, ResDataSize);
throws an exception
in VCL.Graphics
{$IF NOT DEFINED(CLR)}
function TResourceManager.AllocResource(const ResData): PResource;
var
ResHash: Word;
LOwner: TThreadID;
begin
ResHash := Vcl.Graphics.GetHashCode(ResData, ResDataSize);
Lock;
try
LOwner := TThread.CurrentThread.ThreadID;
Result := ResList;
while (Result <> nil) and ((Result^.Owner <> LOwner) or (Result^.HashCode <> ResHash) or
not CompareMem(@Result^.Data, @ResData, ResDataSize)) do
Result := Result^.Next;
if Result = nil then
begin
GetMem(Result, ResDataSize + ResInfoSize);
with Result^ do
begin
Next := ResList;
RefCount := 0;
Handle := TResData(ResData).Handle;
HashCode := ResHash;
Owner := LOwner;
Move(ResData, Data, ResDataSize);
end;
ResList := Result;
end;
Inc(Result^.RefCount);
finally
Unlock;
end;
end;
{$ENDIF}