|
|
Type
TNO11
TNO33
in MSDN
Note: it is alphabet O and not zero
|
|
|
|
|
ccpptrain wrote: Type
TNO11
TNO33
in MSDN
Note: it is alphabet O and not zero
Correction - It is 0 (zero - digit) and not alphabet O.
Regards,
Paresh.
|
|
|
|
|
I want to store data of distinct datatype at runtime.
so how can i do this?
Is there any provision for this kind of support in MFC?
Manish Patel
B.E. - Information Technology
|
|
|
|
|
What do you mean exactly ? Your question isn't clear at all. Are you looking for something like an union ?
|
|
|
|
|
I have one class which store two values, one of type CString and another i want which can store any data type
Manish Patel
B.E. - information Technology
|
|
|
|
|
Manish_mnp wrote: another i want which can store any data type
Why do you need to do such a thing ? Can you explain in details why this is needed ?
C++ is type safe, so you cannot just have any kind of data (or you could use a void pointer and cast it to what you need but this is ugly and will bring you a lot of problems).
|
|
|
|
|
I am recieving RTMP packet from flash.
It is for flash Object.
Now the data in object may get change runtime.
So how can i do same thing as like flash in MFC?
Is there any facility in MFC through which i can do this?
|
|
|
|
|
I still don't know what you are trying to do. So you receive a packet and it contains some data. How is this packet structured and how do you know which kind of data is contained in the packet ? What are the different data types that you can receive ?
When you need to use this data later, how will you use it ? What will you do with it and how will you identify what kind of data it is ?
You cannot just store any kind of data (well, not easily and it is in general far from being good practice), so what I'm trying to do is understand what you are trying to do in order to help. So, if you don't give enough information, I cannot help (and saying that you want to store any kind of data is not really usefull information). So, please be complete in your answer.
|
|
|
|
|
packet can contain array or object
If it is a objet then it can contain many values like int, double, char *, or another object, etc.
Thats not problem, my program can identify it at run time.
Now the problem is that how can i store these values so that i can access it again?
Is there any facility of assigning properties of object at runtime?
Any idea??
Manish Patel
B.E. - Information Technology.
|
|
|
|
|
Well, you don't give a lot of information do you ?
Manish_mnp wrote: packet can contain array or object
And how are you supposed to make the difference ? How do you know that the packet contains an object or an array ?
Manish_mnp wrote: If it is a objet then it can contain many values like int, double, char *, or another object, etc.
Same, how do you know which kind of data it is ? How is this information coded ? Qnd zhqt qre the other objects you can put in the packet ?
Manish_mnp wrote: Thats not problem, my program can identify it at run time
Yeah, but that's my problem. I cannot understand your problem until you explain it clearly. How can you identify what is contained in this damn packet ?
Manish_mnp wrote: Is there any facility of assigning properties of object at runtime?
Ok, stop focusing on that and try to explain your problem as if it was impossible to do that. Then, we can discuss a possible solution. But honnestly, I hardly see a reason to use things like VARIANT because it will probably cause a lot of troubles.
Please, post some code snippet and the description of a typical packet. Without more information it is quite difficult to help you. And what are you supposed to do with what is contained in the packet ??
|
|
|
|
|
I am doing it through VARIANT
Now i am providing you a sample code here
<br />
VARIANT var, var2;<br />
var.dblVal = 2.0;
var.vt = VT_DECIMAL;<br />
<br />
MyObject *myObj, *myObj2, *retObj;
myObj = new MyObject();<br />
myObj2 = new MyObject();<br />
myObj->setProperty(CString("DOUBLE"), var);
var2.byref = myObj;<br />
var2.vt = VT_PTR;<br />
<br />
myObj2->setProperty(CString("OBJECT"), var2);<br />
retObj = (MyObject *)myObj2->getProperty(CString("OBJECT")).byref;<br />
<br />
CString st;<br />
st.Format(CString("Val::%f"), retObj->getProperty(CString("DOUBLE")).dblVal);<br />
AfxMessageBox(st);<br />
<br />
This code run perfactly but it is required that we have to provide perticular value(as .byres, .dblVal)
Is there any alternative to this code so that i can assigen all values by using only one Type(like obj.val = value)
Any Sugession ?
Manish Patel
B.E. - Information Technology.
|
|
|
|
|
|
I want the facility such that i can store my variable of different data type like double, int, char *, My own Object.
Any idea?
Manish Patel
B.E. - Information Technology
|
|
|
|
|
Have a look to MFC support for VARIANT datatype (or create a custom union by yourself).
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.
|
|
|
|
|
Ya i know it but how can it store my custom class refernce(object)?
Manish Patel
B.E. - Information Technology
|
|
|
|
|
Manish_mnp wrote: Ya i know it
And you know also about pointers ?
Hint: try to be more specific, or post the relevant code snippet.
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.
|
|
|
|
|
now data can be anything
-int
-float
-char*
-an object of your class (object will also contain data in the form of int, float, char* )
etc..
So all the data can be converted in the form of char*
like this
<br />
char data[4]<br />
int i<br />
float f<br />
memcpy(data, &i, sizeof(i));<br />
memcpy(data, &f, sizeof(f));<br />
if there is any object of a class
provide a member function which will
- take char*
- allocate memory that is used by all the data in class
- and finally convert all the data in the form of char *
just a kind of Serialization that is provided by MFC
|
|
|
|
|
Have you considered a void* to hold such data?
"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
|
|
|
|
|
I have a 3 thread MFC application. Out of these one sub thread should be used for displaying video at intervals of 40ms. How do i create a periodic timer to accomplish this job. I have seen the SetTimer function. How to manage the timer from the display thread. How to get the parameters such as HWND,TimerProc parameter etc.
|
|
|
|
|
Try the following:
//You can set the timer in one of the funtions of some class
//probably in some constructor
//m_nTimer1 will be declared as unsigned int in that class
m_nTimer1 =CWnd::SetTimer(1,40,0);//for 40 ms
//After 40 ms the following function will get called
void YourClass::OnTimer(UINT nIDEvent)
{
if(nIDEvent==1)
{
CWnd::KillTimer(m_nTimer1);
/***Call your display function here****/
m_nTimer1 =CWnd::SetTimer(1,40,0);//Then again set your timer
//for 40 ms
}
}
|
|
|
|
|
Since you have a thread to show the video, timer is not needed. You can use Sleep API in the loop. But the problem is that it cannot give you a much precision. You have to play the video on by looking at the time (I think GetTickCount is useful) instead of using sleep for a real time video show.
- NS -
|
|
|
|
|
For the display of the video should use the main MFC thread (your app). So use the normal OnTimer() handling.
For standard use I create a main MFC app, and for special use a "worker" thread for communicating with devices or greater mathematical operations.
Greetings from Germany
|
|
|
|
|
I am using CreateThread() function to create worker threads. Are there any other ways to create threads in MFC applications. Why I have this doubt is because my application is utilizing full 100% of CPU all the time. My application has one serial port reading thread which should take only very little CPU another a fully mathematical thread and third a display thread.
|
|
|
|
|
The high CPU utilization is very bad. It is in best case a missdesign in worst a bug.
Identify and eliminate this via Sleep(), a Timer or Waiting for a Event.
Greetings from Germany
|
|
|
|