|
Try to change the setting :
From the VC++ menu:
Project -> Settings...
Go to C/C++ tab, choose "Code generation" category.
Try other choices listed in "Use run-time library:",
for example: Debug ones or non debug ones, DLL ones or non DLL ones.....
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
How can i turn off the little blinking cursor in console c++?
i have a text game that is a big loop and the game field is stored to an array that is outputted, but when its run on slow computers u can see the cursor moving down in row in the array, is there a way to turn this off?
i asked a while back and Nish kindly gave me this code:
char abc[128];
int main(int argc, char* argv[]){
HANDLE h;
h= CreateConsoleScreenBuffer(GENERIC_WRITE|GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,CONSOLE_TEXTMODE_BUFFER,NULL);
SetConsoleActiveScreenBuffer(h);
CONSOLE_cursor_INFO cci;
cci.dwSize = 90; cci.bVisible=false;
SetConsolecursorInfo(h,&cci);
cin >> abc;
but i couldn't get it to work within my specific program,
can anyone help me out?
-ryan
|
|
|
|
|
After you check the case of some stuff there (struct name and function name), this code works as-is.
|
|
|
|
|
Ok THis should be really easy, but as you all know frustration is the number one killer of compurter keyboards, so i've given up.
I have a loop that refreshes a OpenGl screen rendering contect.
What is the easiest and most reliable way to measure the the time taken to run through the loop I.E FPS. What time functions can I use to get the elapsed time in ms.
Thank you.
|
|
|
|
|
The highest resolution timer that you can get is from a call to QueryPerformanceCounter. If you divide the result from this value by the result you get from QueryPerformanceFrequency, you will have a value in milliseconds.
Not all machines have access to a performance counter, therefore your next best choice is the multimedia counter. You can access this with a call to timeGetTime.
There is a really good timer function that is written inside of a set of DirectX utility classes in the SDK. It can be found in the samples/multimedia/Common/src folder and it is the dxutil.cpp file.
Also in the d3dutil.cpp file of the same directory there is some good code to generate the fps for a render sequence.
Good Luck!
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thanks I am now using QueryPerformanceCounter
Works good. Max fps is 30 Min 12
|
|
|
|
|
kilowatt wrote:
Not all machines have access to a performance counter
Is this really true? I've heard it before, but I've actually never found a machine that lacks them.
What are they using? Why whouldn't they be available?
Please also note that the highest resolution "timer" you can get is the IA32 rdtsc instruction, though it's not strictly a "timer".
|
|
|
|
|
you could also use the ZEN timer class which makes use of the timer chip on your motherboard.
you can take the code from Michael Abrash's Graphics Programming Black Book, Special Edition
or
Michael Abrash's Zen of Code Optimization
according to my knowledge thats as far as you can get since it is dependent on the clock frquency your hardware is using.
Best of luck.
|
|
|
|
|
vijayaramaraju wrote:
Michael Abrash's Graphics Programming Black Book, Special Edition
or
Michael Abrash's Zen of Code Optimization
both truly awesome books
"... and so i said to him ... if it can't dance and you can't eat it either f**k it or throw it away" 8028finder.com
|
|
|
|
|
I am currently working on the Window Media skins for my SDI application.
Skins can be Winamp skin also. Can someone advise me of this?
|
|
|
|
|
Every time I try to create an image object with a JPEG file, i get OutOfMemory status. The documentation says that a constructor can throw this error for other reasons even though you may have plenty of free memory on your machine.
Anybody ran into this issue??
Thanks.
---
Softomatix
http://www.pardesiservices.com/Softomatix.asp
|
|
|
|
|
hello,everyone:
help me . Is there anyone can tell me how to implement "Program Rollback"?
The key question is how to save the Program state at any time ,and how to restore the program state using C or C++.
|
|
|
|
|
I think I understand what you are asking.
Program state is just a bunch of variables stored (most likely) in several places. Serialize them to a file with iostream or CArchive and then reverse the process. To some degree it depends on how exact you want the "rollback" to be. Do you want screen sizes, window positions, etc to be exactly the same? If this is the case then it will require some more work but it is basically the same process.
Typically in a MFC application you can use Document/View architecture. This can make "rollback" easy because all you have to do is serialize the data in your document class through a CArchive object (Serialize function).
In non MFC applications this can be accomplished with iostreams, standard FILE access, ado and any other way you want to accomplish it.
|
|
|
|
|
thanks!
if i want to exactly save and restore the CPU registers' content in my C or C++ program ,when some error is detected ,then rollback to the previous saved CPU' state, how to do this?
|
|
|
|
|
I am still not 100% sure what you are attempting to do, but I'll take a shot at it.
You can use inline assembler to access the register values directly. Simply put them in a memory location somewhere and put them back when you're done. I never was any good at assembler so I can't spit out any code quickly.
This probably isn't enough to restore your app to its previous state though as the other memory (not in registers) modified by the app would also need to be replaced. This includes stack and heap memory.
I don't think you can programmatically alter the stack in a safe way. You can overwrite the stack and possibly do what you want but I don't think its a good idea. The heap is a little bit easier, though. You would just need to implement your own memory allocators OR hook the windows ones. Either way, not a small task.
|
|
|
|
|
I beleive what you're looking for is setjmp() and longjmp() defined in setjmp.h. These funstions will take a snapshot of your registers, and restore them when needed. They are well documented in MSDN with given examples.
|
|
|
|
|
You must collect your Program state data and write it to a (temporary file). The name convention should allow changing (i.e. data1230-08052002.tmp") and write the name to the registry "Last state OK" key in your program section.;)
|
|
|
|
|
There are just to many ways to do it to be able to liste them all.
Instead, I'll point you to the Memento pattern (from the GoF "Design Patterns").
|
|
|
|
|
Hi,
Look at this nasty type casting. any one can help?
(AFX_PMSG)(AFX_PMSGW)(int (AFX_MSG_CALL CWnd::*)(LPCREEATESTRUCT))OnCreate
note:
typedef void (AFX_MSG_CALL CCmdTarget::*AFX_PMSG)(void);
These codes come from MessageMapping and Message Rounting.
Thank you.
Best regard.
I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. One concrete prolem is worth a thousand unapplied abstractions.
|
|
|
|
|
What are you asking about?
But, in general you have to remember that the message map table just contains generic routine pointers. Thus, they have to be cast to the proper routine protocol when they are to be invoked.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Can you explain the code for me in detail? I mean word by word.
Thank you.
Best regard.
I confess that I am a stubborn guy, but why not put things thoroughly, logically and systematically clean. One concrete prolem is worth a thousand unapplied abstractions.
|
|
|
|
|
NicholasCougar wrote:
Can you explain the code for me in detail? I mean word by word.
There is no need to explain it more than to say that they cast a pointer to a member function into another type of function pointer.
But to spell it out, I think it's spelled something like:
Emm eff see sucks, partially because Microsoft lagged ~5 years behind the competing C++ implementation, and partially since the AFX (remember, it was Application Framework eXperimental - probably with emphasis on the experimental part) group wasn't too good at neither design nor C++.
Sure, using the inferior MS compiler they actually managed to make something work, sometimes... But the price we got to pay for this was un-typesafety that has wasted several hundred of thousands of developer hours around the globe to date.
|
|
|
|
|
can anybody tell me how to register a com dll with c++ code? better give me some piece of code, thanks!;P
Richy
Richy
|
|
|
|
|
You can simply call the DllRegisterServer function that is exported from the COM DLL. That is what regsvr32 does.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I'm trying to use a CPropertySheet as a child window to a dialog... It all works pretty ok exept for one small and extremely annoying bug:
If a child window of a CPropertyPage has the input focus when the main window loses focus (for instance if Alt+Tab is pressed or if another top-level window is activated) the application stops responding.
Has anyone experienced this problem before?
If yes do you know of a solution or workaround?
Demo project available for download here.
Cheers!
Marc
|
|
|
|