Никто не знает, почему может виснуть Компас при загрузке библиотеки?
Библиотека написана в Builder. Если эту библиотеку грузить сразу из Builder’а, когда компилируешь, то все хорошо, если же ее грузить просто из компаса, то компас виснет.
Причем с Delphi такая же история
С кодом можно ознакомиться?
ЦитироватьС кодом можно ознакомиться?
Смотрите "Библиотека отрисовки рычажного механизма (ТММ)"
Кривые немного, но такие получились, дальше работать над ними не собираюсь в ближайшее время. Но глюк есть глюк, и разобраться с ним не помешает. :)
Смотри.
#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;
}
kons_gu@meil.ru
смотри примеры, компас до 5.11 был создан на Builder
Для какого Компаса нужно?
В Компас 6 и выше имена экспортных функций большими буквами.
//-------------------------------------------------------------------------------
// Определить имя библиотеки
// ---
extern "C" char * __export __pascal LIBRARYNAME()
{
return "Самая простая библиотекана (Borland C++ Builder)";
}
//-------------------------------------------------------------------------------
// Головная функция библиотеки
// ---
extern "C" void __export __pascal LIBRARYENTRY( unsigned int )
{
// Выдача сообщения пользователю
Message( "ПРИВЕТ!!!" );
}