about parameter passing
-
Hi everyone, Please Help me that how to pass the parameters to the activex controls.Please tell me. i am writing one OCX file.in that file i am doing read and write functions. and in another project i am using that OCX.When i am passing parameters to that function then that time values taking as null.in runtime when i given some values to that parameters that time also they are takingas null only.in VC++ how can i pass the parameters by refence please. In OCX file write function is READBLK(LPCTSTR MemId, LPCTSTR MemName, LPCTSTR eDate, LPCTSTR Balance, LPCTSTR TagId); and in my main project write block is like this: OCX.READBLK(MemId,Memname,Date,Balance,Tagig) {m_MemId=MemId;}like this i am assigning the value. these MemId,Memname,Date,Balance and Tagid are of type CString after writing the data in the card.after writing i want read that data from the card but the data is not printing on the form or not returning to my project from OCX file. Please Help me i am in tension. THANKU IN ADVANCE, savitriX|
-
Hi everyone, Please Help me that how to pass the parameters to the activex controls.Please tell me. i am writing one OCX file.in that file i am doing read and write functions. and in another project i am using that OCX.When i am passing parameters to that function then that time values taking as null.in runtime when i given some values to that parameters that time also they are takingas null only.in VC++ how can i pass the parameters by refence please. In OCX file write function is READBLK(LPCTSTR MemId, LPCTSTR MemName, LPCTSTR eDate, LPCTSTR Balance, LPCTSTR TagId); and in my main project write block is like this: OCX.READBLK(MemId,Memname,Date,Balance,Tagig) {m_MemId=MemId;}like this i am assigning the value. these MemId,Memname,Date,Balance and Tagid are of type CString after writing the data in the card.after writing i want read that data from the card but the data is not printing on the form or not returning to my project from OCX file. Please Help me i am in tension. THANKU IN ADVANCE, savitriX|
You post is not clear. Please explain you problem neatly and elaborate whenever necessary. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
You post is not clear. Please explain you problem neatly and elaborate whenever necessary. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarkeok i will explain. i am creating one ACtiveX control called ACRRW. in that ACTiveX control i am writing methods called ReadBlk() and WriteBlk(). ReadBlk(LPCTSTR MemId,LPCTSTR MemName,LPCTSTR eData,LPCTSTR balance,LPCTSTR TagId); and Write(LPCTSTR MemId,LPCTSTR MemName,LPCTSTR eData,LPCTSTR balance,LPCTSTR TagId); and i am using this ACtiveX Control in my another project called ACRReadWrite Automation Project. in this project i am creating m_ACRRW variable as ActiveX control. in my i am putting two buttons called Read and Write.in this Read and Write button functions i am calling the functions those are already present in ACtiveX Control. m_ACRRW.ReadBlk(MemId,MemName,eDate,Balance,TagId); MemId,MemName,eDate,Balance and TagId are of type CString. m_ACRRW.WriteBlk(m_MemId,m_MemName,m_eDate,m_Balance,m_TagId); m_MemId...m_TagId are of type CString. i am facing problem in Read Block that is my values are written in card but after reading those data they are not printing on the screen. i thought that i did mistake in passing parameters.PLEASE HELP ME OUT. give me some solution. THANKU IN ADVANCE, savitri :doh:
-
ok i will explain. i am creating one ACtiveX control called ACRRW. in that ACTiveX control i am writing methods called ReadBlk() and WriteBlk(). ReadBlk(LPCTSTR MemId,LPCTSTR MemName,LPCTSTR eData,LPCTSTR balance,LPCTSTR TagId); and Write(LPCTSTR MemId,LPCTSTR MemName,LPCTSTR eData,LPCTSTR balance,LPCTSTR TagId); and i am using this ACtiveX Control in my another project called ACRReadWrite Automation Project. in this project i am creating m_ACRRW variable as ActiveX control. in my i am putting two buttons called Read and Write.in this Read and Write button functions i am calling the functions those are already present in ACtiveX Control. m_ACRRW.ReadBlk(MemId,MemName,eDate,Balance,TagId); MemId,MemName,eDate,Balance and TagId are of type CString. m_ACRRW.WriteBlk(m_MemId,m_MemName,m_eDate,m_Balance,m_TagId); m_MemId...m_TagId are of type CString. i am facing problem in Read Block that is my values are written in card but after reading those data they are not printing on the screen. i thought that i did mistake in passing parameters.PLEASE HELP ME OUT. give me some solution. THANKU IN ADVANCE, savitri :doh:
Hence
WriteBlk
works fine whileReadBlk
not. Could you postReadBlk
relevant code?If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Hence
WriteBlk
works fine whileReadBlk
not. Could you postReadBlk
relevant code?If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Did you try to debug the OCX project putting a breakpoint in the ReadBlk and see what is happening?
Demian. "I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." -Bjarne Stroustrup, computer science professor, designer of C++ programming language (1950- )
-
Did you try to debug the OCX project putting a breakpoint in the ReadBlk and see what is happening?
Demian. "I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." -Bjarne Stroustrup, computer science professor, designer of C++ programming language (1950- )
-
The problem is in your approach on passing strings that actually are OUT parameters. As simple solution you may mimic
WIN32 API
GetWindowText
behaviour, i.e. for each string that must be filled by the ActiveX control, pass the pointer of a buffer (allocated by the client) and the buffer size to the control. A simple example: ActiveX codeBOOL ReadBlk(LPSTR MemId, LONG MemIdSize)
{
if ( !MemId || MemIdSize < 1)
return FALSE;strncpy(MemId, "Hello Client!", MemIdSize-1);
MemId[MemIdSize-1]='\0';
return true;
}Client code
const int SIZE=0x100;
CHAR MemId[SIZE];
m_ActiveX.ReadBlk((LPSTR) MemId, SIZE);:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Hi everyone, Please Help me that how to pass the parameters to the activex controls.Please tell me. i am writing one OCX file.in that file i am doing read and write functions. and in another project i am using that OCX.When i am passing parameters to that function then that time values taking as null.in runtime when i given some values to that parameters that time also they are takingas null only.in VC++ how can i pass the parameters by refence please. In OCX file write function is READBLK(LPCTSTR MemId, LPCTSTR MemName, LPCTSTR eDate, LPCTSTR Balance, LPCTSTR TagId); and in my main project write block is like this: OCX.READBLK(MemId,Memname,Date,Balance,Tagig) {m_MemId=MemId;}like this i am assigning the value. these MemId,Memname,Date,Balance and Tagid are of type CString after writing the data in the card.after writing i want read that data from the card but the data is not printing on the form or not returning to my project from OCX file. Please Help me i am in tension. THANKU IN ADVANCE, savitriX|
savitri wrote:
...or not returning to my project from OCX file.
Exactly how are you expecting this to happen? You effectively have the following:
BOOL CACR120RWCtrl::ReadBlk( LPCTSTR MemId )
{
CString dStr;
...
MemId = dStr;
}In this context, the
MemId
can be changed to point to something else, but only withinReadBlk()
. OnceReadBlk()
goes out of scope,MemId
goes back to pointing to whatever it pointed to beforeReadBlk()
was called. If you wantMemId
to point elsewhere, you'll likely need to change the parameters tochar **
instead. You can also change it to achar *
and usestrcpy()
to change its contents."Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
savitri wrote:
...or not returning to my project from OCX file.
Exactly how are you expecting this to happen? You effectively have the following:
BOOL CACR120RWCtrl::ReadBlk( LPCTSTR MemId )
{
CString dStr;
...
MemId = dStr;
}In this context, the
MemId
can be changed to point to something else, but only withinReadBlk()
. OnceReadBlk()
goes out of scope,MemId
goes back to pointing to whatever it pointed to beforeReadBlk()
was called. If you wantMemId
to point elsewhere, you'll likely need to change the parameters tochar **
instead. You can also change it to achar *
and usestrcpy()
to change its contents."Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
Of course you are right. However I don't think passing a
char **
will be the best approach there. Probably passing an allocated buffer (likeGetWindowText
behaviour) will be better. I know it's a matter of taste but whenever the OP isn't an expert I'm afraid of suggesting the "server-memory-allocation, client-memory-deallocation" approach. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
Of course you are right. However I don't think passing a
char **
will be the best approach there. Probably passing an allocated buffer (likeGetWindowText
behaviour) will be better. I know it's a matter of taste but whenever the OP isn't an expert I'm afraid of suggesting the "server-memory-allocation, client-memory-deallocation" approach. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain ClarkeCPallini wrote:
However I don't think passing a char ** will be the best approach there.
I never said it was. It was merely a suggestion for the OP to explore.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
savitri wrote:
...or not returning to my project from OCX file.
Exactly how are you expecting this to happen? You effectively have the following:
BOOL CACR120RWCtrl::ReadBlk( LPCTSTR MemId )
{
CString dStr;
...
MemId = dStr;
}In this context, the
MemId
can be changed to point to something else, but only withinReadBlk()
. OnceReadBlk()
goes out of scope,MemId
goes back to pointing to whatever it pointed to beforeReadBlk()
was called. If you wantMemId
to point elsewhere, you'll likely need to change the parameters tochar **
instead. You can also change it to achar *
and usestrcpy()
to change its contents."Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
hi DavidCrow, I modified Cstring to char** but the control is not passing.i modified in OCX project.but i am not getting anything.please tell me how can i do it. PLEASE HELP ME.I am TRYING MY LEVEL BEST BUT I AM FED UP.PLEASE HELP ME. I AM VERY THANK FUL TO U ALL.REALLY I LEARNED SO MUCH BUT I AM NOT GETTING ONLY THIS OUTPUT.i am having data in OCX but it is not returning to my project.PLEASE...... THANKU, savitri :rolleyes:
-
hi DavidCrow, I modified Cstring to char** but the control is not passing.i modified in OCX project.but i am not getting anything.please tell me how can i do it. PLEASE HELP ME.I am TRYING MY LEVEL BEST BUT I AM FED UP.PLEASE HELP ME. I AM VERY THANK FUL TO U ALL.REALLY I LEARNED SO MUCH BUT I AM NOT GETTING ONLY THIS OUTPUT.i am having data in OCX but it is not returning to my project.PLEASE...... THANKU, savitri :rolleyes:
savitri wrote:
I modified Cstring to char**...
Why?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
savitri wrote:
I modified Cstring to char**...
Why?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
u only mentioned that if it is Cstring then data will pass to the parameters so i did like this.in ocx or in my project shall i change that data. REPLY ME AS SOON AS POSSIBLE: Thakns in advance, savitri,:confused:
savitri wrote:
u only mentioned that if it is Cstring then data will pass to the parameters...
This makes no sense. Go back and read this thread again, and then reply with a bit more coherency.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne