Форум пользователей ПО АСКОН

Профессиональные вопросы => Программирование приложений => C++ => Тема начата: Mitya от 13.07.03, 09:04:21

Название: Виснет компас при загрузке прикладной библиотеки
Отправлено: Mitya от 13.07.03, 09:04:21
Никто не знает, почему может виснуть Компас при загрузке библиотеки?
Библиотека написана в Builder. Если эту библиотеку грузить сразу из Builder’а, когда компилируешь, то все хорошо, если же ее грузить просто из компаса, то компас виснет.
Название: Re:Виснет компас при загрузке прикладной библиотеки
Отправлено: Mitya от 15.07.03, 14:37:34
Причем с Delphi такая же история
Название: Re:Виснет компас при загрузке прикладной библиотеки
Отправлено: Skiff от 15.07.03, 14:43:23
С кодом можно ознакомиться?
Название: Re:Виснет компас при загрузке прикладной библиотеки
Отправлено: Mitya от 15.07.03, 17:08:17
ЦитироватьС кодом можно ознакомиться?
Смотрите "Библиотека отрисовки рычажного механизма (ТММ)"
Кривые немного, но такие получились, дальше работать над ними не собираюсь в ближайшее время. Но глюк есть глюк, и разобраться с ним не помешает. :)
Название: Re:Виснет компас при загрузке прикладной библиотеки
Отправлено: Kоstаs МариупольСапр от 13.07.05, 00:48:40
Смотри.
#include
#include
#include "U.h"
#include "Roll_grad.h"
# include "LIB_ID.cpp"
#include "Ks_TLB.h"
#include "ldefin2d.h"
#include "ldefin3d.h"
#pragma hdrstop
//---------------------------------------------------------------------------
//   Important note about DLL memory management when your DLL uses the
//   static version of the RunTime Library:
//
//   If your DLL exports any functions that pass String objects (or structs/
//   classes containing nested Strings) as parameter or function results,
//   you will need to add the library MEMMGR.LIB to both the DLL project and
//   any other projects that use the DLL.  You will also need to use MEMMGR.LIB
//   if any other projects which use the DLL will be performing new or delete
//   operations on any non-TObject-derived classes which are exported from the
//   DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
//   EXE’s to use the BORLNDMM.DLL as their memory manager.  In these cases,
//   the file BORLNDMM.DLL should be deployed along with your DLL.
//
//   To avoid using BORLNDMM.DLL, pass string information using "char *" or
//   ShortString parameters.
//
//   If your DLL uses the dynamic version of the RTL, you do not need to
//   explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------------------------------------------

#pragma argsused

extern "C" IDispatch* far __export WINAPI CreateKompasObject();  //создать объект Компас
//void Forma ();//вызов формы
void Forma_GRAD  ();//запуск главной формы
void Forma_Log();//запуск формы заставки
KompasObject* kompas = NULL;
ksDocument2D* eskiz = NULL;
ksMathematic2D* math= NULL;
//ksDocument3D* doc3D = NULL;
bool flag=0;


int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
        return 1;
}
//---------------------------------------------------------------------------


extern "C" unsigned int far __export __pascal LibraryId()
{
   return 1000;
}
extern "C" unsigned int far __export __pascal LibraryIBmpSize()
{
return MAKELONG(160,140);
}

extern "C" void far __export __pascal  LibraryEntry( UINT Comm )
{
 //установка, что символ разделения дробной части - точка
DecimalSeparator = ’.’;
  kompas = (KompasObject*)::CreateKompasObject();
  if ( kompas )
   {
   Application->Handle= (HWND)kompas->ksGetHWindow();
         switch (Comm)
           {
            case 1001:
            Forma_Log();
              eskiz = (ksDocument2D*)kompas->Document2D() ;
              math = (ksMathematic2D*)kompas->GetMathematic2D();
             /* doc3D = (ksDocument3D*)kompas->Document3D(); */
               if(eskiz && math )Forma_GRAD  () ;break;

      }
  }
}
//=============================================================
void Forma_GRAD()//запуск формы
{
if (!flag) //проверка запуска формы
  {
 Application->Handle= (HWND)kompas->ksGetHWindow();
 //F_Rolls = new TForm_Rolls ( Application );
  CAM_Forma= new TCAM_Forma ( Application );
 // if (F_Rolls)
  if(CAM_Forma)
    {
    flag=true;//флаг запуска формы
   CAM_Forma->Show();
 //   CAM_Forma->ShowModal();
   kompas->ksSystemControlStart(StringToOleStr("Остановить АРМ"));
       delete  CAM_Forma;
   flag=false;
    }
   Application->Handle = 0;
   }
}

void Forma_Log()//запуск формы заставки
{
// Application->Handle= (HWND)kompas->ksGetHWindow();
Log=  new TLog ( Application );
  if(Log)
    {
   Log->ShowModal();
   delete  Log;
    }
   Application->Handle = 0;
}
Название: Re:Виснет компас при загрузке прикладной библиотеки
Отправлено: Kоstаs МариупольСапр от 13.07.05, 00:51:50
kons_gu@meil.ru
смотри примеры, компас до 5.11 был создан на Builder
Название: Re:Виснет компас при загрузке прикладной библиотеки
Отправлено: 333 от 14.07.05, 20:20:01
Для какого Компаса нужно?
В Компас 6 и выше имена экспортных функций большими буквами.


//-------------------------------------------------------------------------------
// Определить имя библиотеки
// ---
extern "C" char * __export __pascal LIBRARYNAME()
{
  return "Самая простая библиотекана (Borland C++ Builder)";
}


//-------------------------------------------------------------------------------
// Головная функция библиотеки
// ---
extern "C" void __export __pascal LIBRARYENTRY( unsigned int )
{
  // Выдача сообщения пользователю
  Message( "ПРИВЕТ!!!" );
}