Click here to Skip to main content
15,388,904 members

Comments by Cedric Moonen (Top 31 by date)

Cedric Moonen 20-Jun-11 4:26am View
Yes, so ? What is the problem with the solutions I provided you ? Did you even read my answer ?
Cedric Moonen 20-Jun-11 4:15am View
Your buffer is NULL, so how can you add bytes to a non-existent buffer ? You will first need to allocate a buffer for 40 bytes (using new in C++ or malloc in C). Of course, you won't be able to add bytes to that buffer after that except if you use one of the solutions I provided.
Cedric Moonen 20-Jun-11 2:22am View
Could you also post the exact error message displayed when your code crashes ?
Cedric Moonen 17-Jun-11 3:26am View
In fact this "trick" comes handy in some specific situations: for a specific factory design pattern. If you make the factory a singleton, then each element that has to be created by the factory can register itself (before the main starts) using this technique. This allows to decouple the factory from the elements it has to create.
Cedric Moonen 17-Jun-11 2:48am View
Look at the solution I provided (solution 7), this is doing something similar as your java code...
Cedric Moonen 21-Feb-11 6:58am View
Is your xml format always the same or should your application dynamically adapt to different xsd files ?
In case you have one format, did you consider generating code based on the xsd ? If you are developping an open source software, you can have a look at codesynthesis ( They also have commercial licences.
On the other hand, you can also consider a lightweight XML parser like TinyXML ( but in that case there's no databinding involved.
Cedric Moonen 21-Feb-11 6:10am View
Yes, but as you didn't reply mine, I can't really give an appropriate one. Can you please describe precisely the situation that you have ? Why is the XSD important in your case? Because it looks like it's not used...
Cedric Moonen 17-Feb-11 4:58am View
You can't distribute the dll's anymor, you have to install the C++ redistributable package on the target machine.
Cedric Moonen 26-Jan-11 9:08am View
Please read the documentation of GetLine, it is stated explicitely that: "If the function stops reading because this size is reached, the failbit internal flag is set". They are talking about the second parameter of the GetLine function (you pass 2). This is also the reason why it looping infinitely: the fail bit is set so no data is read anymore but the end of file is not reached. Check the function documentation here:
Cedric Moonen 26-Jan-11 4:51am View
I'm afraid this is not possible, I can't just give an example like that in OpenGL. OpenGL is a quite complex library (but also very powerful) and it will require some time to learn how to use it properly. If you really want to do that, I suggest you buy a book about OpenGL (this one for instance: and start learning from that. There are also some nice tutorials on this website: (but it is a bit more targeted to games).
I'm not aware of other cross-platform graphical libraries which are easier to use. Maybe you should google for it and see if you find something interesting.
Cedric Moonen 14-Jan-11 2:08am View
mmc ? What's that ? Please be specific in your question because it doesn't make a lot of sense right now.
Cedric Moonen 23-Dec-10 14:00pm View
Only if it is a Win32 application. We still don't know which kind of app he is developping.
Cedric Moonen 21-Dec-10 13:49pm View
Yeah but you can write a Win32 application with Code:Blocks. So, is it a win32 app or a console app ?
Cedric Moonen 6-Dec-10 4:49am View
This is still not clear. Why do you want to hand out the sources of your dll ? There's no need for that. As I said in my previous reply, just distribute the library file and the header files. You don't need to distribute the cpp files.
Cedric Moonen 15-Nov-10 6:51am View
Did you have a look at the link I provided ?
Cedric Moonen 15-Nov-10 6:04am View
What you could do is have an update(int timeElapsed) method of the class. The timeElapsed argument represent the amount of msec elapsed since the last class to update. Inside the class, you can specify its speed and easily calculate the new position of the sprite (based on the previous position and time elapsed). The update method is constantly called from your main loop (you have control over your main loop so you can adjust the update rate).
Cedric Moonen 10-Nov-10 13:18pm View
That's something different. What you asked for is be able to send data with a delay, not at a different rate. You can't send data faster than you receive it (and sending data slower than you receive it is not possible neither, since you will need to accumulate the data and at a certain point, your system will break). The popping thread isn't faster, it just pops data with a certain delay.
Cedric Moonen 10-Nov-10 10:49am View
Well, you have your thread which is already receiving the data that will push the data in the queue, and you have one additional thread that is responsible for extracting data from the queue. What you could do is when you put data in the queue, you also keep the time at which it should be sent. Your thread that pops data from the queue will be notified via an event when data is pushed into the queue. At that time, it looks at the first data in the queue and wait for a certain period of time (until it reaches the specified time).

It is a bit complicated to explain but basically you have one event which is shared by the two threads: when data is pushed into the queue, the first thread signal the event to wake up the second thread, signaling it that data is available. This second thread, when woken up, will take the first data and look at the time at which it has to wake up. If the wait times out (meaning that no data has been pushed into the queue and that we reached the time at which we need to send data), the second thread takes the first data, sends it and looks if there's more data availble. If not, it wait for an "infinite" time on the event, otherwise it waits until the next data should be sent.
Cedric Moonen 9-Nov-10 7:22am View
Very vague question. Please clarify what you want to achieve exactly, what you already tried and where you are stuck precisely. Nobody's going to provide the full code.
Cedric Moonen 9-Nov-10 3:42am View
What does it have to do with C++ ? Are you aware that this is a programming forum ?
Cedric Moonen 14-Oct-10 4:28am View
I don't have much experience with that but if that's what you want to do, then it is much elegant solution than using MSPaint (basically, you want to redo what paint is doing internally). You can have a look at the CImage class for instance:
Or even CxImage:
You will need to do some research but it is definitively a much better option than using paint.

If you want an example, you can have a look at the code of my charting control ( In the ChartCtrl.cpp file there is a SaveAsImage function, which does exactly what you want. It is rather easy to create a CImage, draw to it and save to a file (much easier than your solution).
Cedric Moonen 13-Oct-10 5:37am View
You still didn't answer my questions. I know that you are migrating Java to C++. But migrating doesn't mean blindy "translate" from java to C++. You have to understand what the program does and in this case what the program is doing with the objects in the map. So please, read my post once again carefully and try to answer my questions. The more precise you'll answer, the more chance you'll have to receive a precise answer.
Cedric Moonen 13-Oct-10 4:57am View
Your code snippet is unreadable. Anyway, your design is probably very bad if you have to store any kind of object in the same container. What is its purpose ? What will you do with the contained objects ? What do you mean also by "system defined" ?
The important point here is that the objects in the container have to be used in some way. And you can't use an object if you don't know what it is (of course you can later check its type but still, I don't see clearly what you're going to do with that).
Cedric Moonen 5-Sep-10 14:36pm View
Reason for my vote of 1
You could try asking Santa
Cedric Moonen 5-Aug-10 6:56am View
Did you realize that the question was posted in september 2008 ? Chances are that the OP is not interested in the answer anymore...
Cedric Moonen 5-Jul-10 4:47am View
I don't know the mp3 format, but isn't there any header ? I would guess a header is needed at least to define the bit rate. So, you can't simply concatenate the files this way.
Cedric Moonen 2-Jul-10 3:53am View
You certainly won't put your edit control as a global variable. Instead, when the user pressed the Ok button, you get the text from the edit control and store it in the global variable (which is a string).
Cedric Moonen 24-Jun-10 6:51am View
I don't agree: calling lock on a CCriticalSection which has already been locked by the SAME thread is not a blocking call. This is safe and in certain conditions perfectly acceptable. See the link that Iain provided (well, it is for CRITICAL_SECTION and not for CCriticalSection but the principle is the same).
Cedric Moonen 22-Jun-10 6:18am View
Reason for my vote of 1
No, nobody is going to go through all the code without even knowing what is wrong with your progam. Ask a SPECIFIC question.
Cedric Moonen 17-Jun-10 4:26am View
Nah, such a program should at least contain the mandatory "Hello World" words :-)
Cedric Moonen 11-Jun-10 5:48am View
Then it might be that your exe and your dll do not use the same heap. Make sure that they are both using the same version of the C runtime library (check that both the DLL and your exe have the same value for the "Runtime library" option in the project settings.