03-28-2019, 01:07 PM
Hi Gambit, thank you for the answer. I find a way to make it work, but not exactly as i wanted.
The way is follow:
First i need to create a function (callback) in my C++ code, like that:
void __fastcall TIWForm1::function(TStringList *EventParams)
{
ShowMessage("Hello Cruel World!");
}
Then i need to register this function as a callback function. In the OnCreate Event of my form, i just add this code:
WebApplication->RegisterCallBack("function",function);
After that, i need to send to client side what Ajax event i will use to trigger my server side C++ function:
AddToInitProc("function myAjaxFunction(){ executeAjaxEvent('&value=1234', null,'function',false, null, false);}") ;
So i create some div dynamically in OnCreate event:
AddToInitProc("var myDiv = document.createElement('div');") ;
AddToInitProc("myDiv.id = 'MyDivID'") ;
AddToInitProc("myDiv.className = 'MyDivClass'") ;
AddToInitProc("document.getElementById('OtherDiv').appendChild(myDiv)) ;
AddToInitProc("myDiv.onclick = myAjaxFunction") ;
When i click on myDiv i can call the "function" in the server side but ONLY IF MY INTRAWEB FORM HAVE THIS CODE ON IT:
void setAsMainForm() {
TWebMainForm::SetAsMainForm();
}
#pragma startup setAsMainForm
The problem is that i need to handle Ajax events in all my forms.
How to solve this?
Thank you!
The way is follow:
First i need to create a function (callback) in my C++ code, like that:
void __fastcall TIWForm1::function(TStringList *EventParams)
{
ShowMessage("Hello Cruel World!");
}
Then i need to register this function as a callback function. In the OnCreate Event of my form, i just add this code:
WebApplication->RegisterCallBack("function",function);
After that, i need to send to client side what Ajax event i will use to trigger my server side C++ function:
AddToInitProc("function myAjaxFunction(){ executeAjaxEvent('&value=1234', null,'function',false, null, false);}") ;
So i create some div dynamically in OnCreate event:
AddToInitProc("var myDiv = document.createElement('div');") ;
AddToInitProc("myDiv.id = 'MyDivID'") ;
AddToInitProc("myDiv.className = 'MyDivClass'") ;
AddToInitProc("document.getElementById('OtherDiv').appendChild(myDiv)) ;
AddToInitProc("myDiv.onclick = myAjaxFunction") ;
When i click on myDiv i can call the "function" in the server side but ONLY IF MY INTRAWEB FORM HAVE THIS CODE ON IT:
void setAsMainForm() {
TWebMainForm::SetAsMainForm();
}
#pragma startup setAsMainForm
The problem is that i need to handle Ajax events in all my forms.
How to solve this?
Thank you!

