| | |
Addres accses violation in DLL (Borland C++ Builder 6)
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2008
Posts: 25
Reputation:
Solved Threads: 0
I'm developming a programm thet will use a dll forms, the problem i'm getting i have several forms in each dll, some of them have to use functions from other forms. For example, i have a DLL "Customers" which includes Customers form, Customer Selection List, which is a a different form in the same DLL, the problem is thet i'm getting an error message when i try to call function located on a CustomerForm, from CustomerSearch form.
here is the cod i'm trying to build
The Search Function works pirfect internaly, when it is called from the CustomerForm.cpp But once i call teh function from the Search Customer form it gives an error
"Access violation at address 00E41F03 in module 'Customer.dll' Read of Address 00000360."
Can any one help me ??????? please
here is the cod i'm trying to build
C++ Syntax (Toggle Plain Text)
//$$---- Form CPP ---- CustSearch.Cpp //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "CustSearch.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TSearchCustomerF *SearchCustomerF; //--------------------------------------------------------------------------- __fastcall TSearchCustomerF::TSearchCustomerF(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TSearchCustomerF::Button1Click(TObject *Sender) { CustomerF->Search(Edit1->Text, "NAME", CustomerF->IBTable1); } //--------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////////////////////// CustomerForm.Cpp //$$---- Form CPP ---- //--------------------------------------------------------------------------- #include <vcl.h> #include <Inifiles.hpp> #pragma hdrstop #include "CustomerForm.h" #include "DataModul.h" #include "CustSearch.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "IBCustomDataSet" #pragma link "IBDatabase" #pragma link "IBTable" #pragma resource "*.dfm" TSearchCustomerF* DllCustomerSearch; TCustomerF *CustomerF; Pointer GenPointer; //--------------------------------------------------------------------------- __fastcall TCustomerF::TCustomerF(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __stdcall CreateCustomerSearch(TComponent* Owner) { DllCustomerSearch = new TSearchCustomerF (Owner); DllCustomerSearch->ShowModal(); } //--------------------------------------------------------------------------- void __fastcall TCustomerF::Search (AnsiString NameP, AnsiString FieldP, TIBTable* Table) { TLocateOptions Opts; Opts.Clear(); Opts << loPartialKey; Opts << loCaseInsensitive; Table->Locate(FieldP,NameP, Opts ); Table->IndexFieldNames=FieldP; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::Search1 (AnsiString NameP, AnsiString FieldP, int i) { if (i==1) { Search(NameP, FieldP, IBTable1); } } //--------------------------------------------------------------------------- void __fastcall TCustomerF::Save(TIBTable* Table, TIBTransaction* Transaction) { int i=0; AnsiString a; if (Table==IBTable1) { if (Table->State==dsInsert) { i=1; } if (Table->State==dsEdit) { i=2; a=IBTable1->FieldByName("ID")->Value; } } Table->Post(); Transaction->Commit(); Table->Active=true; if (i==1) { Table->Last(); } if (i==2) { Search(a, "ID", Table); } } //--------------------------------------------------------------------------- AnsiString __fastcall TCustomerF::GetPath() { AnsiString Path; TIniFile * newIniFile = new TIniFile(ChangeFileExt(Application->ExeName, ".INI")); try{ Path = newIniFile->ReadString("OUTLOOK","PathStr", "C:"); return Path; } __finally { delete newIniFile; } return Path; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::Button3Click(TObject *Sender) { Save(IBTable1, IBTransaction1); } //--------------------------------------------------------------------------- void __fastcall TCustomerF::Button1Click(TObject *Sender) { IBTable1->Append(); } //--------------------------------------------------------------------------- void __fastcall TCustomerF::IBTable1AfterEdit(TDataSet *DataSet) { Button1->Enabled=false; Button3->Enabled=true; Button2->Enabled=true; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::IBTable1AfterInsert(TDataSet *DataSet) { Button1->Enabled=false; Button3->Enabled=true; Button2->Enabled=true; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::IBTable1AfterTransactionEnd(TObject *Sender) { Button3->Enabled=false; Button1->Enabled=true; Button2->Enabled=false; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::IBTable1AfterOpen(TDataSet *DataSet) { Button3->Enabled=false; Button1->Enabled=true; Button2->Enabled=false; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::Button2Click(TObject *Sender) { IBTable1->Cancel(); } //--------------------------------------------------------------------------- void __fastcall TCustomerF::IBTable1AfterCancel(TDataSet *DataSet) { Button3->Enabled=false; Button1->Enabled=true; Button2->Enabled=false; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::TabSheet4Enter(TObject *Sender) { if (IBTable1->State==dsInsert ||IBTable1->State==dsEdit) { Save(IBTable1, IBTransaction1); } } //--------------------------------------------------------------------------- void __fastcall TCustomerF::TabSheet5Enter(TObject *Sender) { if (IBTable1->State==dsInsert ||IBTable1->State==dsEdit) { Save(IBTable1, IBTransaction1); } } //--------------------------------------------------------------------------- void __fastcall TCustomerF::FormCreate(TObject *Sender) { this->Position=poDesktopCenter; IBTable1->Active=true; IBTable2->Active=true; IBTable3->Active=true; IBTable4->Active=true; IBTable5->Active=true; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::Button4Click(TObject *Sender) { IBTable3->Insert(); } //--------------------------------------------------------------------------- void __fastcall TCustomerF::Button5Click(TObject *Sender) { Save(IBTable3, IBTransaction3); } //--------------------------------------------------------------------------- void __fastcall TCustomerF::Button6Click(TObject *Sender) { IBTable3->Delete(); IBTransaction3->Commit(); IBTable3->Active=true; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::Button7Click(TObject *Sender) { IBTable5->Insert(); } //--------------------------------------------------------------------------- void __fastcall TCustomerF::Button8Click(TObject *Sender) { Save(IBTable5, IBTransaction4); } //--------------------------------------------------------------------------- void __fastcall TCustomerF::Button9Click(TObject *Sender) { IBTable5->Delete(); IBTransaction4->Commit(); IBTable5->Active=true; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::IBTable3AfterTransactionEnd(TObject *Sender) { Button4->Enabled=true; Button6->Enabled=true; Button5->Enabled=false; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::IBTable3AfterOpen(TDataSet *DataSet) { Button4->Enabled=true; Button6->Enabled=true; Button5->Enabled=false; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::IBTable3AfterInsert(TDataSet *DataSet) { Button4->Enabled=false; Button6->Enabled=false; Button5->Enabled=true; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::IBTable3AfterEdit(TDataSet *DataSet) { Button4->Enabled=false; Button6->Enabled=false; Button5->Enabled=true; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::IBTable5AfterTransactionEnd(TObject *Sender) { Button7->Enabled=true; Button8->Enabled=false; Button9->Enabled=true; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::IBTable5AfterPost(TDataSet *DataSet) { Button7->Enabled=true; Button8->Enabled=false; Button9->Enabled=true; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::IBTable5AfterOpen(TDataSet *DataSet) { Button7->Enabled=true; Button8->Enabled=false; Button9->Enabled=true; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::IBTable5AfterInsert(TDataSet *DataSet) { Button7->Enabled=false; Button8->Enabled=true; Button9->Enabled=false; } //--------------------------------------------------------------------------- void __fastcall TCustomerF::SpeedButton3Click(TObject *Sender) { AnsiString Addres="/c ipm.note /m "+DBEdit17->Text; ShellExecute(NULL, "open", GetPath().c_str(),Addres.c_str() , NULL, SW_SHOWNORMAL); } //--------------------------------------------------------------------------- void __fastcall TCustomerF::SpeedButton4Click(TObject *Sender) { AnsiString Addres="/c ipm.note /m "+DBEdit18->Text; ShellExecute(NULL, "open", GetPath().c_str(),Addres.c_str() , NULL, SW_SHOWNORMAL); } //--------------------------------------------------------------------------- void __fastcall TCustomerF::SpeedButton5Click(TObject *Sender) { AnsiString Addres="/c ipm.note /m "+DBEdit25->Text; ShellExecute(NULL, "open", GetPath().c_str(),Addres.c_str() , NULL, SW_SHOWNORMAL); } //--------------------------------------------------------------------------- void __fastcall TCustomerF::SpeedButton6Click(TObject *Sender) { AnsiString Addres="/c ipm.note /m "+DBEdit37->Text; ShellExecute(NULL, "open", GetPath().c_str(),Addres.c_str() , NULL, SW_SHOWNORMAL); } //--------------------------------------------------------------------------- void __fastcall TCustomerF::SpeedButton7Click(TObject *Sender) { AnsiString Addres="/c ipm.note /m "+DBEdit55->Text; ShellExecute(NULL, "open", GetPath().c_str(),Addres.c_str() , NULL, SW_SHOWNORMAL); } //--------------------------------------------------------------------------- void __fastcall TCustomerF::SpeedButton8Click(TObject *Sender) { AnsiString Addres="/c ipm.note /m "+DBEdit56->Text; ShellExecute(NULL, "open", GetPath().c_str(),Addres.c_str() , NULL, SW_SHOWNORMAL); } //--------------------------------------------------------------------------- void __fastcall TCustomerF::DBEdit3KeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (Key==VK_F9) { Search(DBEdit3->Text, "NAME", IBTable1); } if (Key==VK_F8) { IBTable1->Next(); } if (Key==VK_F7) { IBTable1->Prior(); } } //--------------------------------------------------------------------------- void __fastcall TCustomerF::DBEdit1KeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (Key==VK_F9) { Search(DBEdit1->Text, "ID", IBTable1); } if (Key==VK_F8) { IBTable1->Next(); } if (Key==VK_F7) { IBTable1->Prior(); } } //--------------------------------------------------------------------------- void __fastcall TCustomerF::SpeedButton1Click(TObject *Sender) { CreateCustomerSearch(this); } //--------------------------------------------------------------------------- void __fastcall TCustomerF::SpeedButton2Click(TObject *Sender) { GenPointer=Addr( } //---------------------------------------------------------------------------
The Search Function works pirfect internaly, when it is called from the CustomerForm.cpp But once i call teh function from the Search Customer form it gives an error
"Access violation at address 00E41F03 in module 'Customer.dll' Read of Address 00000360."
Can any one help me ??????? please
![]() |
Other Threads in the C++ Forum
- Previous Thread: Where is the Memory Leak ?
- Next Thread: SOLVE
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





