|
This place[^] has been around since the 90's and is always a good source to check out.
|
|
|
|
|
Hi All,
I have unsigned char * buffer in which some data are stored , now I want to move these all data to my CString variable for some operations.
I tried to copy but problem is that in my unsigned char * some data are padded as zero, So I hope that in CString it gets the null value so it can not copy whole data.
I tried to copy from unsigned char * to the CString using...
CString tmpMsg = CString(msg); // Here msg is the unsigned char *
Ashish Bhatt
|
|
|
|
|
|
Thanks ...
I used memcpy() as u told me, But I used like ........
memcpy(&tempMsg,(unsigned char*)msg,noOfBytes);
Then it gives me the run time Access violation error as below...
TestRTMP.exe: 0xC0000005: Access violation reading location 0x49468964.
So,plz help me , is there any other way to copying.
Ashish Bhatt
|
|
|
|
|
Does not surprise me that it gives you an access violation when doing that.
The first and foremost rule to remember is: DO NOT USE MEMCPY ON CLASSES.
Classes work independently, managing their own memory and so on. Therefore, you should use the exposed interfaces in the classes to do stuff.
In this case, you're overwriting important data in the class, not to mention that the class's internal buffer is nowhere large enough to hold your data.
As mentioned, use CString.GetBuffer(LengthOfBuffer). It returns a pointer to a buffer. Copy data using memcpy/CopyMemory. Then call CString.ReleaseBuffer(LengthOfData).
That should do the trick.
|
|
|
|
|
Actually you just need to keep the data in CString? Then use GetBuffer, and copy the data using CopyMemory. But remember, you should not perform any string operations because it is having null characters...
- NS -
|
|
|
|
|
The CString class is designed to handle C-style strings, meaning strings that are terminated with a character value of zero (AKA NUL ). It is not designed to handle raw data that contains embedded NUL characters, not double-NUL -terminated collections of strings.
Sounds like you may be a bit too comfortable with CString s...
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
i want to lern to draw a dynamic curve,but do not know how to do;
is there any good Activecontrol or methode,
my idea is, continuesly get data from a database or by some way else, then draw them on a picture, the curve should be dynamic.
thanks a lot
wuhuaiji
|
|
|
|
|
What is your problem?
In OnDraw() , you draw the curve (MoveTo() , LineTo() ) into the client rect . Whenever you get new data and fell the need to redraw, you Invalidate() .
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
hello
thanks for your answer
my problem is, how to make the curve move smoothly? it move from right to left with time going
wuhuaiji
|
|
|
|
|
Do you want algorithms to interpolate and smooth the curve-data?
Or do you want to reduce flicker on the screen?
Either case, there are articles here on codeproject and on the net.
E.G. here[^].
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
have you googled to for "Active X Control to draw a curve"
there are somany articles and active X controls related to that topic.
or if you want to develop one active X control, then i can guide you.
|
|
|
|
|
But why he must uses of Activexs control?
|
|
|
|
|
good question,
but as he said, he want to draw it on a picture.
so i thought, he would have to develop an AX to fulfil his task.
iam not sure, weather any existing control, has a mixture of both image and a graph on it.
|
|
|
|
|
Why are you so obsessed with ActiveX controls . Why not simply use a custom control ?
Do you know why ActiveX are used ? Do you know that the purpose of ActiveX is to have a control that can be used in different languages. If you just developping a C++ app, why bothering with an ActiveX when you can simply use a custom control.
|
|
|
|
|
yes you are right.
But i feel comfortable with AX because most of the times I use it in other languages also. Thats why i'm used to that.
Thank You.
|
|
|
|
|
Well, but for somebody that only wants to use a control in its C++ application, this is a bad advice to tell him to develop its own ActiveX control. Why do you want to make things even more complex to him ? Developping an ActiveX control is more complicated than developping a simple custom control.
|
|
|
|
|
yes and thanks,
i agree to your point.
|
|
|
|
|
thanks
i have googled, and now i know how to draw a static curve
but i want to draw a dynamic curve, which can move smoothly with time going
wuhuaiji
|
|
|
|
|
what is the difference you are referring to as static and dynamic curves.
you mean, you want to see the curve increasing from time to time, at run time?
if it is so, put your plotting code in a thread.
but i can suggest ful fledgedly, only, if u can provide a sample of code here, how you made it static.
gud luck.
|
|
|
|
|
|
Why you cant draw a curve with existing APIs? What kind of data and curve are you intended to use?
- NS -
|
|
|
|
|
thanks a lot
first, i am a newbie,
then, i just want draw a curve, which can move
now i have got many friends' help, thanks for all of your answer
and i think maybe i have found the solution
indeed, the question is a little problem, the big problem is that i am fresh in VC
wuhuaiji
|
|
|
|
|
You have two options:
1) Use an existing control, there are plenty existing on this website. I also developped one control that can do that (see the link in my sig). I think it is the easiest solution and the one that will save you a lot of troubles.
2) Create your own control. You seem to have some problems with the fact that the line should move. Well, there is no miracle: if you want to do such a thing, you have to make it move yourself (redraw the line completely).
I warn you that this is far from being the easiest solution. If you are completely new to this, I suggest you take the first option. But if you have some time and want to learn how it works, then it can be interesting to take that path. But then, start by reading some tutorials about how to create custom controls before starting to create your own.
|
|
|
|
|
Hi everybody,
i create my self a menu-object, so i can display the menu-items dynamically :
CMenu *Home = new CMenu();
Hom->AppendMenu(MF_STRING,ID_MYMENU_GO,"Go");
Home->TrackPopUpMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,Parent);
The ID_MYMENU_GO isn't known and the menu item is disabled.
If i create a new String-Ressource with the ID of ID_MYMENU_GO and set a String of "-"
the Menu-Element is displayed correctly ...
Is it also possible to set the Menu-Item ID to the project/mainform/.. so that
the application knows the ID ?
For example adding the String via programmation into the known ID's ...
Big thanks for help
|
|
|
|