Addres accses violation in DLL (Borland C++ Builder 6)

Reply

Join Date: Oct 2008
Posts: 25
Reputation: uim_1977 is an unknown quantity at this point 
Solved Threads: 0
uim_1977 uim_1977 is offline Offline
Light Poster

Addres accses violation in DLL (Borland C++ Builder 6)

 
1
  #1
Oct 26th, 2008
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
  1. //$$---- Form CPP ----
  2. CustSearch.Cpp
  3. //---------------------------------------------------------------------------
  4.  
  5. #include <vcl.h>
  6. #pragma hdrstop
  7.  
  8. #include "CustSearch.h"
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. #pragma resource "*.dfm"
  12. TSearchCustomerF *SearchCustomerF;
  13. //---------------------------------------------------------------------------
  14. __fastcall TSearchCustomerF::TSearchCustomerF(TComponent* Owner)
  15. : TForm(Owner)
  16. {
  17. }
  18. //---------------------------------------------------------------------------
  19. void __fastcall TSearchCustomerF::Button1Click(TObject *Sender)
  20. {
  21.  
  22. CustomerF->Search(Edit1->Text, "NAME", CustomerF->IBTable1);
  23.  
  24. }
  25. //---------------------------------------------------------------------------
  26.  
  27. ////////////////////////////////////////////////////////////////////////////////////////////////
  28.  
  29.  
  30. CustomerForm.Cpp
  31. //$$---- Form CPP ----
  32. //---------------------------------------------------------------------------
  33.  
  34. #include <vcl.h>
  35. #include <Inifiles.hpp>
  36. #pragma hdrstop
  37.  
  38. #include "CustomerForm.h"
  39. #include "DataModul.h"
  40. #include "CustSearch.h"
  41. //---------------------------------------------------------------------------
  42. #pragma package(smart_init)
  43. #pragma link "IBCustomDataSet"
  44. #pragma link "IBDatabase"
  45. #pragma link "IBTable"
  46. #pragma resource "*.dfm"
  47.  
  48. TSearchCustomerF* DllCustomerSearch;
  49. TCustomerF *CustomerF;
  50. Pointer GenPointer;
  51.  
  52.  
  53. //---------------------------------------------------------------------------
  54. __fastcall TCustomerF::TCustomerF(TComponent* Owner)
  55. : TForm(Owner)
  56. {
  57.  
  58. }
  59. //---------------------------------------------------------------------------
  60.  
  61. void __stdcall CreateCustomerSearch(TComponent* Owner)
  62. {
  63. DllCustomerSearch = new TSearchCustomerF (Owner);
  64. DllCustomerSearch->ShowModal();
  65. }
  66. //---------------------------------------------------------------------------
  67.  
  68.  
  69.  
  70. void __fastcall TCustomerF::Search (AnsiString NameP, AnsiString FieldP, TIBTable* Table)
  71. {
  72.  
  73. TLocateOptions Opts;
  74. Opts.Clear();
  75. Opts << loPartialKey;
  76. Opts << loCaseInsensitive;
  77. Table->Locate(FieldP,NameP, Opts );
  78. Table->IndexFieldNames=FieldP;
  79. }
  80. //---------------------------------------------------------------------------
  81. void __fastcall TCustomerF::Search1 (AnsiString NameP, AnsiString FieldP, int i)
  82. {
  83. if (i==1) {
  84. Search(NameP, FieldP, IBTable1);
  85. }
  86.  
  87. }
  88.  
  89.  
  90.  
  91. //---------------------------------------------------------------------------
  92.  
  93. void __fastcall TCustomerF::Save(TIBTable* Table, TIBTransaction* Transaction)
  94. {
  95. int i=0;
  96. AnsiString a;
  97. if (Table==IBTable1) {
  98.  
  99. if (Table->State==dsInsert) {
  100. i=1;
  101. }
  102. if (Table->State==dsEdit) {
  103. i=2;
  104.  
  105. a=IBTable1->FieldByName("ID")->Value;
  106. }
  107. }
  108. Table->Post();
  109. Transaction->Commit();
  110. Table->Active=true;
  111. if (i==1) {
  112. Table->Last();
  113. }
  114. if (i==2) {
  115. Search(a, "ID", Table);
  116. }
  117.  
  118. }
  119. //---------------------------------------------------------------------------
  120.  
  121.  
  122.  
  123. AnsiString __fastcall TCustomerF::GetPath()
  124. {
  125. AnsiString Path;
  126. TIniFile * newIniFile = new TIniFile(ChangeFileExt(Application->ExeName, ".INI"));
  127. try{
  128. Path = newIniFile->ReadString("OUTLOOK","PathStr", "C:");
  129. return Path;
  130. }
  131. __finally {
  132. delete newIniFile;
  133. }
  134. return Path;
  135. }
  136. //---------------------------------------------------------------------------
  137.  
  138.  
  139. void __fastcall TCustomerF::Button3Click(TObject *Sender)
  140. {
  141. Save(IBTable1, IBTransaction1);
  142. }
  143. //---------------------------------------------------------------------------
  144.  
  145. void __fastcall TCustomerF::Button1Click(TObject *Sender)
  146. {
  147. IBTable1->Append();
  148. }
  149. //---------------------------------------------------------------------------
  150.  
  151.  
  152. void __fastcall TCustomerF::IBTable1AfterEdit(TDataSet *DataSet)
  153. {
  154. Button1->Enabled=false;
  155. Button3->Enabled=true;
  156. Button2->Enabled=true;
  157. }
  158. //---------------------------------------------------------------------------
  159.  
  160. void __fastcall TCustomerF::IBTable1AfterInsert(TDataSet *DataSet)
  161. {
  162. Button1->Enabled=false;
  163. Button3->Enabled=true;
  164. Button2->Enabled=true;
  165. }
  166. //---------------------------------------------------------------------------
  167.  
  168. void __fastcall TCustomerF::IBTable1AfterTransactionEnd(TObject *Sender)
  169. {
  170. Button3->Enabled=false;
  171. Button1->Enabled=true;
  172. Button2->Enabled=false;
  173. }
  174. //---------------------------------------------------------------------------
  175.  
  176. void __fastcall TCustomerF::IBTable1AfterOpen(TDataSet *DataSet)
  177. {
  178. Button3->Enabled=false;
  179. Button1->Enabled=true;
  180. Button2->Enabled=false;
  181. }
  182. //---------------------------------------------------------------------------
  183.  
  184. void __fastcall TCustomerF::Button2Click(TObject *Sender)
  185. {
  186. IBTable1->Cancel();
  187. }
  188. //---------------------------------------------------------------------------
  189.  
  190. void __fastcall TCustomerF::IBTable1AfterCancel(TDataSet *DataSet)
  191. {
  192. Button3->Enabled=false;
  193. Button1->Enabled=true;
  194. Button2->Enabled=false;
  195. }
  196. //---------------------------------------------------------------------------
  197.  
  198.  
  199. void __fastcall TCustomerF::TabSheet4Enter(TObject *Sender)
  200. {
  201. if (IBTable1->State==dsInsert ||IBTable1->State==dsEdit) {
  202. Save(IBTable1, IBTransaction1);
  203. }
  204.  
  205. }
  206. //---------------------------------------------------------------------------
  207.  
  208.  
  209. void __fastcall TCustomerF::TabSheet5Enter(TObject *Sender)
  210. {
  211. if (IBTable1->State==dsInsert ||IBTable1->State==dsEdit) {
  212. Save(IBTable1, IBTransaction1);
  213. }
  214. }
  215. //---------------------------------------------------------------------------
  216.  
  217. void __fastcall TCustomerF::FormCreate(TObject *Sender)
  218. {
  219. this->Position=poDesktopCenter;
  220. IBTable1->Active=true;
  221. IBTable2->Active=true;
  222. IBTable3->Active=true;
  223. IBTable4->Active=true;
  224. IBTable5->Active=true;
  225.  
  226. }
  227. //---------------------------------------------------------------------------
  228.  
  229. void __fastcall TCustomerF::Button4Click(TObject *Sender)
  230. {
  231. IBTable3->Insert();
  232. }
  233. //---------------------------------------------------------------------------
  234.  
  235. void __fastcall TCustomerF::Button5Click(TObject *Sender)
  236. {
  237. Save(IBTable3, IBTransaction3);
  238. }
  239. //---------------------------------------------------------------------------
  240.  
  241. void __fastcall TCustomerF::Button6Click(TObject *Sender)
  242. {
  243. IBTable3->Delete();
  244. IBTransaction3->Commit();
  245. IBTable3->Active=true;
  246. }
  247. //---------------------------------------------------------------------------
  248.  
  249. void __fastcall TCustomerF::Button7Click(TObject *Sender)
  250. {
  251. IBTable5->Insert();
  252. }
  253. //---------------------------------------------------------------------------
  254.  
  255. void __fastcall TCustomerF::Button8Click(TObject *Sender)
  256. {
  257. Save(IBTable5, IBTransaction4);
  258. }
  259. //---------------------------------------------------------------------------
  260.  
  261. void __fastcall TCustomerF::Button9Click(TObject *Sender)
  262. {
  263. IBTable5->Delete();
  264. IBTransaction4->Commit();
  265. IBTable5->Active=true;
  266. }
  267. //---------------------------------------------------------------------------
  268.  
  269. void __fastcall TCustomerF::IBTable3AfterTransactionEnd(TObject *Sender)
  270. {
  271. Button4->Enabled=true;
  272. Button6->Enabled=true;
  273. Button5->Enabled=false;
  274.  
  275. }
  276. //---------------------------------------------------------------------------
  277.  
  278. void __fastcall TCustomerF::IBTable3AfterOpen(TDataSet *DataSet)
  279. {
  280. Button4->Enabled=true;
  281. Button6->Enabled=true;
  282. Button5->Enabled=false;
  283.  
  284. }
  285. //---------------------------------------------------------------------------
  286.  
  287. void __fastcall TCustomerF::IBTable3AfterInsert(TDataSet *DataSet)
  288. {
  289. Button4->Enabled=false;
  290. Button6->Enabled=false;
  291. Button5->Enabled=true;
  292.  
  293. }
  294. //---------------------------------------------------------------------------
  295.  
  296. void __fastcall TCustomerF::IBTable3AfterEdit(TDataSet *DataSet)
  297. {
  298. Button4->Enabled=false;
  299. Button6->Enabled=false;
  300. Button5->Enabled=true;
  301.  
  302. }
  303. //---------------------------------------------------------------------------
  304.  
  305. void __fastcall TCustomerF::IBTable5AfterTransactionEnd(TObject *Sender)
  306. {
  307. Button7->Enabled=true;
  308. Button8->Enabled=false;
  309. Button9->Enabled=true;
  310.  
  311. }
  312. //---------------------------------------------------------------------------
  313.  
  314. void __fastcall TCustomerF::IBTable5AfterPost(TDataSet *DataSet)
  315. {
  316.  
  317. Button7->Enabled=true;
  318. Button8->Enabled=false;
  319. Button9->Enabled=true;
  320. }
  321. //---------------------------------------------------------------------------
  322.  
  323. void __fastcall TCustomerF::IBTable5AfterOpen(TDataSet *DataSet)
  324. {
  325.  
  326. Button7->Enabled=true;
  327. Button8->Enabled=false;
  328. Button9->Enabled=true;
  329. }
  330. //---------------------------------------------------------------------------
  331.  
  332. void __fastcall TCustomerF::IBTable5AfterInsert(TDataSet *DataSet)
  333. {
  334.  
  335. Button7->Enabled=false;
  336. Button8->Enabled=true;
  337. Button9->Enabled=false;
  338. }
  339. //---------------------------------------------------------------------------
  340.  
  341. void __fastcall TCustomerF::SpeedButton3Click(TObject *Sender)
  342. {
  343.  
  344. AnsiString Addres="/c ipm.note /m "+DBEdit17->Text;
  345. ShellExecute(NULL, "open", GetPath().c_str(),Addres.c_str() , NULL, SW_SHOWNORMAL);
  346. }
  347. //---------------------------------------------------------------------------
  348.  
  349. void __fastcall TCustomerF::SpeedButton4Click(TObject *Sender)
  350. {
  351.  
  352. AnsiString Addres="/c ipm.note /m "+DBEdit18->Text;
  353. ShellExecute(NULL, "open", GetPath().c_str(),Addres.c_str() , NULL, SW_SHOWNORMAL);
  354. }
  355. //---------------------------------------------------------------------------
  356.  
  357. void __fastcall TCustomerF::SpeedButton5Click(TObject *Sender)
  358. {
  359.  
  360. AnsiString Addres="/c ipm.note /m "+DBEdit25->Text;
  361. ShellExecute(NULL, "open", GetPath().c_str(),Addres.c_str() , NULL, SW_SHOWNORMAL);
  362. }
  363. //---------------------------------------------------------------------------
  364.  
  365. void __fastcall TCustomerF::SpeedButton6Click(TObject *Sender)
  366. {
  367.  
  368. AnsiString Addres="/c ipm.note /m "+DBEdit37->Text;
  369. ShellExecute(NULL, "open", GetPath().c_str(),Addres.c_str() , NULL, SW_SHOWNORMAL);
  370. }
  371. //---------------------------------------------------------------------------
  372.  
  373. void __fastcall TCustomerF::SpeedButton7Click(TObject *Sender)
  374. {
  375.  
  376. AnsiString Addres="/c ipm.note /m "+DBEdit55->Text;
  377. ShellExecute(NULL, "open", GetPath().c_str(),Addres.c_str() , NULL, SW_SHOWNORMAL);
  378. }
  379. //---------------------------------------------------------------------------
  380.  
  381. void __fastcall TCustomerF::SpeedButton8Click(TObject *Sender)
  382. {
  383.  
  384. AnsiString Addres="/c ipm.note /m "+DBEdit56->Text;
  385. ShellExecute(NULL, "open", GetPath().c_str(),Addres.c_str() , NULL, SW_SHOWNORMAL);
  386. }
  387. //---------------------------------------------------------------------------
  388.  
  389. void __fastcall TCustomerF::DBEdit3KeyDown(TObject *Sender, WORD &Key,
  390. TShiftState Shift)
  391. {
  392. if (Key==VK_F9)
  393. {
  394. Search(DBEdit3->Text, "NAME", IBTable1);
  395. }
  396. if (Key==VK_F8) {
  397. IBTable1->Next();
  398. }
  399. if (Key==VK_F7) {
  400. IBTable1->Prior();
  401. }
  402. }
  403. //---------------------------------------------------------------------------
  404.  
  405. void __fastcall TCustomerF::DBEdit1KeyDown(TObject *Sender, WORD &Key,
  406. TShiftState Shift)
  407. {
  408. if (Key==VK_F9)
  409. {
  410. Search(DBEdit1->Text, "ID", IBTable1);
  411. }
  412. if (Key==VK_F8) {
  413. IBTable1->Next();
  414. }
  415. if (Key==VK_F7) {
  416. IBTable1->Prior();
  417. }
  418. }
  419. //---------------------------------------------------------------------------
  420.  
  421.  
  422. void __fastcall TCustomerF::SpeedButton1Click(TObject *Sender)
  423. {
  424. CreateCustomerSearch(this);
  425. }
  426. //---------------------------------------------------------------------------
  427.  
  428. void __fastcall TCustomerF::SpeedButton2Click(TObject *Sender)
  429. {
  430. GenPointer=Addr(
  431. }
  432. //---------------------------------------------------------------------------

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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC