|
Thanx friend,
I am already using Sleep() function in my animation program, furthermore, i calculate CPU clock speed and pass the number of milliseconds to Sleep according to the processor speed, and it works good.
But the problem is Sleep has a waiting loop, this loop captures some of CPU time, although i am not a professional programmer, i feel that there must be a way to use the cpu more efficiently.
what i mean here, if the program runs on a fast computer, and it wants to display just 1 frame/s, it will capture all free CPU time because this is the way Sleep works-its a loop.
I need a technique that will use cpu time just as needed, I dont want to waste any CPU time.
thanks for your time and patience.
|
|
|
|
|
Mohammad A Gdeisat wrote:
But the problem is Sleep has a waiting loop, this loop captures some of CPU time, although i am not a professional programmer, i feel that there must be a way to use the cpu more efficiently.
Don't you have something similar to:
while (more_pics == TRUE)
{
DisplayPic();
Sleep(1000);
} This should render a new picture every second regardless of the CPU speed.
I don't know how you've determined that Sleep() uses any CPU time because it does not. You can easily verify this by running the following code and using Task Manager to watch the CPU usage of the running processes.
void main( void )
{
for (int x = 0; x < 10; x++)
Sleep(2000);
} Looking at the Performance tab, the CPU usage should stay in the 3-4% range.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
thanx friend,
i think you are right, but i dont know why does my program capture 100% of available CPU resourses although it has Sleep in its loops!!!
I imagined that a simple animation with sleep would take at most 30% of CPU time on a 2GHz Intel P4 processor.
I am confused!!!!
thanks for your note
|
|
|
|
|
Without seeing your actual code, it's hard to say.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi all,
I was wondering if there is any way to register file type and icon other then adding keys to HKEY_CLASSES_ROOT\filetype.
The problem is that program I'm writing supposed to run under user mode credentials and application doesn't have any rights to add this registry values to the system registry.
Thanks in advance.
-wz.
|
|
|
|
|
|
Dear friends,
I developed an application in Visual C++. The application is completed and successfully deployed. Clients are satisfied as all their requirements are fulfilled.
In our application, there is a feature of 'scripting' i.e Users can enter their formula using VBScript , and then our application loads the script dynamically and executes it.
Now the problem is that users are having problem while manually entering formula. Users don't know how to code in VBScript. Ofcourse, VBScript is easy for all of us; but not for the general public.
Now you can say that we should hardcode all the formulas..no..this is not possible. Users define their own conditions using the formulas, ard there can be thousands of conditions..and..thats why we provided them scripting support.
We want to make the process of formula creation, somewhat user friendly. And i want your suggestions in this regard. If you know any such application that provides userinterface for entering formula, then please tell me about it, so that i can take impression from it. And please give your advices in this regard.
Thanks a lot.
Imtiaz
|
|
|
|
|
what do you mean by "general public" ?
as soon as there's an option for the user to enter new commands ( in you case, formulas ), it is a feature for power users; meaning that the user who need to enter such data will need to work a bit on their side to learn the scripting language, especially if it was part of the requirements.
Also, if this feature is really important, then, you can't underestimate the need to ship documentation for the scripting language, with as many example and sample you can offer.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Why not create a form or dialog or even a wizard that walks the user through creating a formula with drop downs, checkboxes, ie. standard UI controls and create the script behind the scenes? That allows your users to create custom formulas and at the same time, prevents them from having to learn a scripting language.
|
|
|
|
|
Why not provide a "tutorial by example" first?
Much more powerful than a wizard
we are here to help each other get through this thing, whatever it is Vonnegut jr. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
Well, its almost the same as Truistic said ... i saw something like this in the Wise Installation Studio scripting (yours may be a lot simpler than that ... ) editor. goto wise.com and download the trial version of wise installation system 9 (if you own a copy... its even better) and see how their scripting editor operates... maybe this will give you some idea on what your clients would like to have.
- tareq
|
|
|
|
|
If the most of the formulas are variations on a theme you can provide them in a simple torturial.
Provide the best documentation you can. Direct it at programers. Tell customers that programers can be hired to write these scripts. Perhaps even have a list of those willing to do the work.
For many customers the correct action is to have a standard contract rate to write them for the customers. Make sure you are fairly expensive, because you provide the highest quality results. That is you don't ask them for the math to translate into their program, you spend time finding out their needs in detail, to make sure it is the right thing for them.
|
|
|
|
|
I have built a SDI project in Visual C++ called HelloSDI. I used a book I bought
to learn about Windows applications. The project compiles 0 errors and 0 warnings.
The project has a simple dialog box added to it. When I run the program up pops a window that is blank.
The dialog is not there. On further searching I guess I have to add a override the OnInitialUpdate()
method of the CView class with this code
ChelloDlg HelloDlg;
HelloDlg.DoModal(); to make the dialog pop up at initialization.
My problem is I don’t know where the OnInitialUpdate code is put into my project. Some say you can use a menu
Handler to add the code into, but I can”t find away to do that either.
My book is unclear……. Can you help me. Jim
jim
|
|
|
|
|
OnInitialUpdate() is an overridable method of your view class. The method will be called by the framework after the view is first attached to the document, but before the view is initially displayed.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi everyone:
I wrote a MFC dialog-based program. My program need to use the GDI function FillRect to fill teh dialog in some specified color. But there are two buttons in that dialog, my problem is how to force them to be redrawn after I filled the dialog? Since the action of the function FillRect would fill whole dialog with my color and these 2 buttons would also be covered. Can somebody tell me how to do? I have no much time on this project. Thanks!
|
|
|
|
|
Invalidate() or InvalidateRect()
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Well if that is all it needs to do then just override OnEraseBkgnd() to fill the background.
class CMyDialog : public CDialog
{
int m_FillBrushIndex;
CBrush m_FillBrush[2];
};
afx_msg BOOL CMyDialogLLOnEraseBkgnd( CDC* pDC )
{
pDC->FillRect(&rect,&m_FillBrush[m_FillBrushIndex]);
return TRUE;
}
void CLineInfoDlg::OnButton1()
{
m_FillBrushIndex = 0;
InvalidateWindow();
}
void CLineInfoDlg::OnButton2()
{
m_FillBrushIndex = 1;
InvalidateWindow();
}
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi,
I need to parse text files to search some keywords. I split the search process into many different functions (because they search for different contents). So I thought I could open the file just once and then pass the file stream as a function parameter. In debug mode, the app runs, but in release mode it crashes. Can someone explain me why?
Here is a sample of the code:
void F1 (FILE* source)
{
...
}
void F2 (FILE* source)
{
...
}
void main()
{
FILE* source;
source = fopen("myfile.txt","r");
F1(source);
F2(source);
}
|
|
|
|
|
what error does it repport, and what is the code line like ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Nothing is wrong in above code. may be there is any thing wrong in your function that might be reason for failure in release.
anyway,Try to debug the Program,you may yourself find the error.
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
|
Hi friend,
I tried making a program and i got it worked for both release and debug modes
I don't know whats the problem in your code, but for ensurance here is my code and you can compare:
<br />
#include <stdio.h><br />
<br />
void f1(FILE *f)<br />
{<br />
<br />
while (!feof(f))<br />
{<br />
char s[256];<br />
fgets(s,255,f);<br />
printf("%s",s);<br />
}<br />
}<br />
<br />
<br />
void f2(FILE *f)<br />
{<br />
<br />
while (!feof(f))<br />
{<br />
char s[256];<br />
fgets(s,255,f);<br />
printf("%s",s);<br />
}<br />
}<br />
<br />
main()<br />
{<br />
FILE *file;<br />
file=fopen("c:\\dlls.txt","r");<br />
f1(file);<br />
f2(file);<br />
fcloseall();<br />
}<br />
Here are some advices:
1. may be you should check other parts of your program
2. you should use the object-oriented new C++ classes like ifstream
3. may be if two threads are trying to access the same file simaltanously a failure will occur.
4. you should check the return values from the functions like fopen and others to locate the bug.
I dont know if this helps, but it is all i can do for you friend.
Yours,
Mohammad
a candle looses nothing by lighting another candle
|
|
|
|
|
Ok,
you're right, I'm a dope!
It works. But I discovered that the real problem is in variables declaration.
I'm using fscanf instead of fgets because I need to read a text and analyze each word:
FILE* source;
char* word = new char[512];
fscanf (source,"%s",word)
So, fscanf needs a char* initialised this way, otherwise it won't work. But the pointer initialisation crashes the program.
Any suggestion?
Thanks
|
|
|
|
|
hmmmmmm
your code works on my machine. i feel that there is something wrong,
but i cant figure it out.
but here is a suggestion:
are u sure that scanf places a null-terminating character at the end of the buffer? if it does not, initialize the buffer to zeros.
Thats all i have
my apologises,
Mohammad
|
|
|
|
|
hello,
My MFC application is getting crash because of some message,i don't know which message.Is there any way to track the message which is causing crash?
Thanks.
|
|
|
|