|
Hello,
Thanks
But I aam using 2 DLLs and How should I debug starting from my client project?
Pritha
|
|
|
|
|
prithaa wrote: But I aam using 2 DLLs and How should I debug starting from my client project?
Set your dll project as the startup/active project. So when you press F5 you get a dialog prompting you to enter an exe name which will be hosting or using this dll, here browse and select the main exe which runs using this dll.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
MFC has issues with multiple threads and possibly also with dlls. In this case GetParentFrame() is the culprit as it makes an internal call to CWnd::FromHandle which looks like this:
CWnd* PASCAL CWnd::FromHandle(HWND hWnd)
{
CHandleMap* pMap = afxMapHWND(TRUE);
ASSERT(pMap != NULL);
CWnd* pWnd = (CWnd*)pMap->FromHandle(hWnd);
#ifndef _AFX_NO_OCC_SUPPORT
pWnd->AttachControlSite(pMap);
#endif
ASSERT(pWnd == NULL || pWnd->m_hWnd == hWnd);
return pWnd;
}
The afxMapHWND func is probably trying to use global structures that aren't visible from the dll.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
hello,
thanks for the reply.
So I should not use the GetParentFrame() function.And what care should be taken regarding functions that go into the DLLs
Pritha
|
|
|
|
|
Can you avoid using MFC functions from the dll? Here you could use ::GetParent(m_hWnd) instead of GetParentFrame(), but it would give you a HWND, not CFrameWnd. If you can use only raw winapi calls it should be OK.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
If you use MFC with DLLs properly, you won't have a problem.
Everything you need to know can be found here:
Kinds of DLLs[^]
Read carefully
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hey guys,
I'd really appreciate any help you have to offer on this doozy of a problem:
I have a simulation process that I animate to screen using OnDraw() and CMemDC. I use a Timer with an Invalidate() call to call the OnDraw() funstion. In the OnDraw function the simulation is told to progress X number of steps - X being variable because it's important the user can speed the simulation up (real-time is waaaay too slow).
So here's the rub: if the timer is set to, say 50 ms (ie 20 frames per second - a reasonably slow animation rate) and the user requests say 5 simulation steps (each step representing say 100 ms of the real world), then the simulation process takes longer to exectue than 50 ms and we end up backing the message queue up so that the application fails to respond for quite some time.
I tried to do it by keeping a single simulation step per OnDraw call, and reduce the Timer interval, but with the resolution of the system clock this is limited to about 10 ms on my PC, so I only get about 10 x real world speed - still not enough.
I think the solution is to have the simulation and the animation operating seperately, with the animation *only* being called every 50 ms, but I don't know how to interrupt the running simulation. Plus, running the simulation at full speed means the program is not-reponsive and even further, if I could animate this, full speed may be too fast for the user - they need to be able to control the *Time Warp*.
I hope I've made this clear - apologies if not. I think this must be a common enough problem but I can't find anything on it really. If you've any suggestions I'd love to hear them!
Thanks in advance
|
|
|
|
|
Hi,
I have two inputs to offer you:
1.
timing behavior is the subject of my timers article; although it deals with .NET timer classes
the observations would be valid in C/C++/MFC environments too.
2.
I would never interrupt an ongoing simulation, it sounds like a waste of cycles already spent.
Instead I would make sure the increment of simulated time is sufficient for the simulator to stay
ahead of the requirements; one way of doing that would be to entirely skip simulations that are
in the queue but could not possibly get done in time. I hope I made myself clear on this.
|
|
|
|
|
Luc,
Thanks for your help. Your timer article is certainly valid - thanks. Your point about not interrupting the simulation is taken - in any case it would be very hard to code. So that's a given - a SimStep gets completed!
I've carried on searching and think I've got a close match - the game loop. For example using OnIdle() or other such functions. I found a good article here (through CP again ). My problem is the same as the problem he discusses with one important exception - my simulation step is variable (trust me on this!) and usually takes longer than an Invalidate(). So the game loop is close but not ideal.
I'll keep reading
|
|
|
|
|
Hi again,
I have been reading the article you referred to, and I liked it very much (except for the white-
on-black layout). Of course my preference is with "Constant Game Speed independent of Variable FPS",
which if I understood you correctly, for you would be ""Constant Game Speed with adaptable constant
speed, independent of Variable FPS"
I have one comment: the remark that more but smaller steps may yield larger overall errors is
correct when things are implemented like that, just accumulating numbers that are inaccurate to
begin with, but it doesn't have to be done that way.
It reminds me of (a lot of theory regarding) automatic numeric integration, as is used both
in mathematics in general, and in electronics; circuit simulators (such as SPICE) that handle say a
resistor-capacitor integrator really don't do just a sequence of predict-and-accumulate steps,
there are better ways to predict what in this simple case basically is an exponential curve without
spending lots of iterations and small time steps; I do recall the principles but not the official
name right now; I do remember it is very much like a regular feedback mechanism in control theory,
whereby the inherent accumulation error or prediction error corrects itself away to a very
large extent. It might be worth looking into.
[ADDED]Seems "backward integration rule" is something Google knows about... [/ADDED]
|
|
|
|
|
Luc,
I think you're right that my "game" speed needs to be adaptable.
I found this discussion which considers three solutions to a similar problem. Maybe I should be running a number of simulation steps in a worker thread as per this CP article?
Thanks again!
|
|
|
|
|
Hi,
I will try and read these tomorrow, it is getting late now.
Anyway, I feel threads could be useful, but they do not fundamentally solve the problem.
First thing to do is figure out what you want to achieve, i.e. which kind of game loop.
Then threads may or may not be the right choice.
If you do game updating in one thread, and screen updating in another, then that simplifies
the code development, since two important parts got decoupled but that is only true
at first sight, since:
- you have to pass game state to the paint routines (easily solved by copying the state);
- you have to decide which thread gets which part of the CPU cycles. Hence back to the fundamental
questions in the white-on-black article.
|
|
|
|
|
Hmmm food for thought. Thanks so much for taking the time to help Luc I'll respond back here with whatever I come up with.
|
|
|
|
|
|
Hi all,
I just want to know how to put a value in a string pointer for example
std::string *text;
How do I put a wstring value in there because everytime I try even with the use of USES_CONVERSION and WideCharToMultiByte I get a
bad ptr
Thanks,
Jayjay
modified on Monday, July 28, 2008 9:30 PM
|
|
|
|
|
First, since text is a pointer, it needs to be assigned the
address of a string object to point to. You could use the
new operator to allocate a string.
Two ways to assign a value to the string are using a constructor
and using the string class' assignment operator overload:
std::string *text;
text = new std::string("Assigned Text");
std::string *text;
text = new std::string();
*text = "Assigned Text";
Or automatic variable (stack based)/class member semantics:
std::string text("Assigned Text");
std::string text;
text = "Assigned Text";
This is fundamental C++ stuff...you may want to study
basic_string Class[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I think still you're in trouble with wstring to string conversion. http://www.codeproject.com/script/Forums/View.aspx?fid=1647&msg=2653980[^]
Well, the capsule answer for your query is this -
#include "atlconv.h"
string* WstringToString( wstring& WideString )
{
string* pString = new string;
{
USES_CONVERSION;
*pString = W2A( WideString.c_str());
}
return pString;
}
void ConversionFunction()
{
wstring WideString = L"Hello";
string* pString = WstringToString( WideString );
delete pString;
}
Hope its clear now!
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi all, I'm using VC++ with Windows API, no MFC. I want to create a dialog that is entirely owner-drawn, but I can't find a style to use with it (buttons being BS_OWNERDRAW, etc). Is there a style for owner-drawing entire dialogs or do I have to do this in some other way?
Thanks!
KR
|
|
|
|
|
Just register your own window class and run a message pump.
Steve
|
|
|
|
|
The dialog is created as a popup for my application which is already registered. I'm not sure how registering the dialog would help as it already has a message pump? Or maybe I don't understand what you mean? How can I use the dialog's message pump to custom draw the dialog? If I use WM_PAINT I can only draw in the client area of the dialog, right? If I set the dialog's border to "None" then I can basically draw the entire thing as long as I use a square bitmap... but I don't want it to be square, and if I draw the bitmap transparently I see the gray crap beneath it... isn't there a way I can just override the default drawing behavior of the dialog in the same way that I catch the WM_DRAWITEM message for my other custom controls? Thanks!
KR
|
|
|
|
|
What I'm saying is that if you want a dialog-like window that's totally user drawn then just make one: don't use the CreateDialog function and friends. If the dialog is to be modal all you have to do is disable it's parent and you may want to run a your own message pump.
Steve
|
|
|
|
|
Oh ok, I get it. Thanks!
KR
|
|
|
|
|
I need an Efficient Object Management Class to add, remove, get and set (Manage Actually) objects of my own class.
I read somewhere that std::list will do this job but i did not find the function for removing objects or get or set properties of existing objects.
Any suggestions?
|
|
|
|
|
Your question is not really clear but it sesems that you simply need some kind of container (std::list is a container class). Why do you call the an "Object Management Class" ?
Anyway, the way to access elements in a std::list is by using an iterator. The iterator overload * and -> operators that give you access to the object pointed by the iterator. To remove objects, simply erase the iterator (it has an erase member function).
But I suggest that you first read some tutorial about how to use those classes from the STL because it could be quite difficult to start with that without a good tutorial. Just google for it and I am sure you'll find plenty.
|
|
|
|
|
thanks for your help
|
|
|
|