trouble getting translated component on palette

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

trouble getting translated component on palette

Postby Azazaz » Sat Apr 15, 2017 3:57 am

Hi guys,

I'm not experienced as a component developer, so as usual am misunderstanding something.

I am using TMS components. One of them is DiagramEditor.pas. It doesn't do what I need to do, but it comes close, so I got the idea of translating it into C++ so I could work with it more easily. I've managed to get the code into a user components package and to compile and link, but it doesn't show up in the component palette.

If you have the TMS DiagramStudio components, you may notice I've left out the TNavigatorForm class in this translation. I really didn't know how to handle the TMetaClass assignment and am pretty sure I don't need it anyway, so ... that's why the difference.

Here's the CPP:
------------------
Code: Select all
#include <vcl.h>
#pragma hdrstop

#include "ADiagramEditor1.h"

#pragma package(smart_init)

TADiagramEditor *ADiagramEditor;
static inline void ValidCtrCheck(TADiagramEditor *)
{
    new TADiagramEditor(NULL);
}

__fastcall TADiagramEditor::TADiagramEditor(TComponent* Owner)
: TComponent(Owner)
{
    FTitle = "Diagram Designer";
    FALiveDiagramInstance = new TALiveDiagram(this);
    FShowNavigator = true;
    FNavigatorVisible = true;
}

void __fastcall TADiagramEditor::Execute()
{
    CreateDesignerForm();
    try
    {
   try
   {
           if (FOnCreateDesigner)
               FOnCreateDesigner(FForm);

           FForm->OnSaveDiagram = FOnSaveDiagram;
           FForm->OnNotifyShow = FOnShowDesigner;
           FForm->LibManager = FLibManager;
           FForm->Title = FTitle;
      
       FForm->ShowNavigator = ShowNavigator;
       FForm->NavigatorVisible = NavigatorVisible;
       FForm->ShowModal();
   }
   catch (...)
   {
   }
    }
  __finally
  {
   delete FForm;
   FForm = NULL;
  }
}

void __fastcall TADiagramEditor::FormClosed(TObject *Sender, TCloseAction &Action)
{
    if (FOnCloseDesigner)
        FOnCloseDesigner(FForm);
}

void __fastcall TADiagramEditor::Notification(TComponent *AComponent, TOperation Operation)
{
    if (Operation == opRemove)
    {
        if (AComponent == FLibManager)
            FLibManager = NULL;
    }
}

void __fastcall TADiagramEditor::SetLibManager(TDgrLibraryManager *Value)
{
    if (FLibManager != Value)
    {
   if (FLibManager)
     FLibManager->RemoveFreeNotification(this);
   FLibManager = Value;
   if (FLibManager)
     FLibManager->FreeNotification(this);
    }
}

void __fastcall TADiagramEditor::CreateDesignerForm()
{
    FForm = new TfmDiagramEditor(this);
     FForm->OnClose = FormClosed;
}

namespace Adiagrameditor
{
    void __fastcall PACKAGE Register()
    {   
        TComponentClass classes[1] = {__classid(TADiagramEditor)};
        RegisterComponents(L"i deaTech", classes, 0);
    }
}


And here's the .H:
------------------
Code: Select all
#ifndef ADiagramEditor1H
#define ADiagramEditor1H

#include <fDiagramEditor.hpp>
#include "ALiveDiagram.h"

class PACKAGE TADiagramEditor : public TComponent
{
  private:
    TNotifyEvent FOnCloseDesigner;
    TNotifyEvent FOnCreateDesigner;
    TNotifyEvent FOnShowDesigner;
    TfmDiagramEditor *FForm;
    UnicodeString FTitle;
   
    TNotifyEvent FOnSaveDiagram;
    TDgrLibraryManager *FLibManager;
    TALiveDiagram *FALiveDiagramInstance;
    bool FShowNavigator;
    bool FNavigatorVisible;
    void __fastcall CreateDesignerForm();
    void __fastcall FormClosed(TObject *Sender, TCloseAction &Action);

  protected:
    void __fastcall Notification(TComponent *AComponent, TOperation Operation);
    void __fastcall SetLibManager(TDgrLibraryManager *Value);

  public:
    __fastcall TADiagramEditor(TComponent* Owner);

    void __fastcall Execute();

    __property TALiveDiagram *ALiveDiagram = {read=FALiveDiagramInstance};
    __property TNotifyEvent OnCreateDesigner = {read=FOnCreateDesigner, write=FOnCreateDesigner};
    __property TNotifyEvent OnShowDesigner = {read=FOnShowDesigner, write=FOnShowDesigner};
    __property TNotifyEvent OnSaveDiagram = {read=FOnSaveDiagram, write=FOnSaveDiagram};
    __property bool ShowNavigator = {read=FShowNavigator, write=FShowNavigator};
    __property bool NavigatorVisible = {read=FNavigatorVisible, write=FNavigatorVisible};

  __published:

   __property UnicodeString Title = {read=FTitle, write=FTitle};
   __property TNotifyEvent OnCloseDesigner = {read=FOnCloseDesigner, write=FOnCloseDesigner};
   __property TDgrLibraryManager *LibManager = {read=FLibManager, write=SetLibManager};

};

extern PACKAGE TADiagramEditor *ADiagramEditor;
#endif


What am I not doing?

Thanks for any help!!
Azazaz
BCBJ Guru
BCBJ Guru
 
Posts: 105
Joined: Wed Sep 26, 2012 9:08 am

Return to Technical

Who is online

Users browsing this forum: Majestic-12 [Bot] and 7 guests