|
Hence WriteBlk works fine while ReadBlk not. Could you post ReadBlk 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- )
|
|
|
|
|
Ya i tried the control is passing from project to ocx nad vice versa but the problemis that the data is not coming back to my project and not printing on the screen. please give some solution.
Thanku in advance,
savitri
|
|
|
|
|
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 code
BOOL 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
|
|
|
|
|
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 within ReadBlk() . Once ReadBlk() goes out of scope, MemId goes back to pointing to whatever it pointed to before ReadBlk() was called. If you want MemId to point elsewhere, you'll likely need to change the parameters to char ** instead. You can also change it to a char * and use strcpy() 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 (like GetWindowText 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
|
|
|
|
|
CPallini 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
|
|
|
|
|
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
|
|
|
|
|
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,
|
|
|
|
|
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
|
|
|
|
|
hi
i have a newbie question
how to pause execution of a code block
without sleep effect
for example :
void somefunc()<br />
{<br />
SetWindowText(hWnd,"hello");<br />
WaitFor(5000); <br />
SetWindowText(hWnd,"good bye");<br />
}
when WaitFor() called, application must continue
execution other functions and application must response to other function calls
finally i don't want to sleep complete application when waiting
thans
|
|
|
|
|
Use a timer for that. This will be different than your code snippet because the two calls to SetWindowText will be located in two different parts: the second one will be in response of a timer event.
You can't "wait" in a function a still continue to process messages from the UI (which is in the same thread), unless you pump the message loop, but it is quite ugly in your situation.
|
|
|
|
|
thanks for your quick reply
but it is a Dll how can i use a timer in a dll
is there any idea for that
when i call , a wait function from dll
i want to call another function from dll at a time
but first call freezes main application already
and dll is not responding
thanks
|
|
|
|
|
You can also use a multimedia timer. The timer callback will occur on
a different thread so you don't have to worry about your UI going dead
or pumping messages.
Multimedia Timer Reference[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
One technique that sometimes works is simply pumping the message que while waiting.
void YourClass::somefunc()
{
SetWindowText(hWnd,"hello");
SleepWithEvents(5000);
SetWindowText(hWnd,"good bye");
}
VOID YourClass::SleepWithEvents(int Millisecs)
{
ULONG Ticks = GetTickCount();
while(GetTickCount() < Ticks + Millisecs)
DoEvents();
}
VOID YourClass::DoEvents()
{
MSG oMSG;
while(::PeekMessage(&oMSG, NULL, 0, 0, PM_NOREMOVE))
{
if(::GetMessage(&oMSG, NULL, 0, 0))
{
::TranslateMessage(&oMSG);
::DispatchMessage(&oMSG);
}
else
{
break;
}
}
}
Best Wishes,
-David Delaune
|
|
|
|
|
OPen a thread, wait for n number of second there and initimate the windows to print setwindow again!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
ThatsAlok wrote: OPen a thread, wait for n number of second there and initimate the windows to print setwindow again!
i tried it,but i could not figure it out,and not successed
but success one of my attempts, taken a sleep effect
can you show me a working example
|
|
|
|
|
i have a modeless dialog box. and in my first dialog box i have some values. the same values needs to be shown in the modeless dialog box also. i am getting an exception. not being able o figure out what it is.
i have created a member variable for the class and i can also access the members of the class. but i am not being able to pass the value.
in the second dialog box i have an edit control which is of type CString.
|
|
|
|
|
Chandrasekharanp wrote: i am getting an exception.
Did you try to debug your program to pinpoint where the problem occurs exactly ? Use the callstack to locate the problem in your code when the crash occurs.
Without having more information, we can't really help you. We need some relevant piece of code (don't paste the complete source files ). If you can't fix the problem using your debugger, provide also the info you gathered with it.
|
|
|
|
|
i had added DoModal() which i should not have done.. now i am not getting that exception. but the value is not being updated on dialog2. but when i debug in the watch list the value is updating.
|
|
|
|
|
Please read my previous answer and provide the required information. I'm still not able to read what's written on your screen (although I'm trying hard, it's probably because of the distance...)
|
|
|
|
|
Hey man, you're a CP 's MVP : charge your CPMRU 's (Code Project Mind Reader Unit) battery pack and start helping that guy!
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
|
|
|
|
|
It seems broken, I probably tried to use it too much recently
|
|
|
|