A common trick is to measure multiple executions of a function and then calculate the execution time from the result. For example, you could run your functions 100,000 times. Then you divide the result by 100,000 to get the time for a single execution. Off course a lot of things can and do go wrong with this. On Windows you will not get really good data for many reasons. But this method produces an upper bound of maybe higher precision than what you have now. Lorenz Prem Microsoft Corporation
PremL
Posts
-
precise time measuring -
How do I declare a function ?As an accomplished Java programmer you should consider C# as an option. You would have a much easier time learning it than managed C++. But everything depends on what you want to do. Lorenz Prem Microsoft Corporation
-
need some codeproject c++ expertise...I would think if there are no exceptions or errors when the program disappears, it must have terminated properly. Or, if it is a console app, you might need to run it from the console to see the errors when the program terminates. I suggest you have the program produce a very detailed log of its activities in a file somewhere. This data should get you started. Lorenz Prem Microsoft Corporation
-
How to create a VC program to read textConsider using a CStdioFile for reading your file. Construct an instance of the class for the file you want to read from. You can call the ReadString method on it to get a line of text from your file into a CString. Then you can make use of all the methods of CString to get to only the part of the line in the string you are interested in. Technically you are reading the whole line. You then parse the string for what you need. Lorenz Prem Microsoft Corporation
-
Opening a file to write toThe CFileDialog does not create the file, nor does it open it. All the dialog does is give you a standard interface for choosing a file. You have to create the file afterwards. First you construct the dialog. When you call DoModal(), the dialog appears. When the user clicks open, the dialog returns IDOK. At this point your code can access the path to the file selected by the user using the GetPathName() member function.
CFileDialog InputDlg(TRUE, "*.txt", "Message.txt", NULL, "Text Files (*.txt)|*.txt", NULL); if(IDOK==InputDlg.DoModal()){ CString filename = InputDlg.GetPathName(); //create the file here }
I suggest you have a look at the documentation for CFileDialog on the MSDN. It will tell you about some other member functions you can use and also about a little error with the file filter you had in the constructor. Lorenz Prem Microsoft Corporation -
how to show data in internet explorerYou don’t necessarily have to directly integrate your program with IE to display XML. One solution is to write the XML data into a file. Then start the iexplore.exe process and give it the filename of your XML file as a parameter. IE will come up with your XML data displayed. Lorenz Prem Microsoft Corporation
-
Passing PointersSuppose you have the following:
class ClassB { public: void ActionB(); }; class ClassA { public: ClassB* m_pB; void ActionA(); };
Then you can access ClassB from ClassA using the following:ClassA a; //create an instance of each ClassB b; a.ActionA(); //call methods from A directly a.m_pB = &b; //pass a pointer to the instance of B to A a.m_pB->ActionB(); //call B through A using the stored pointer
This is just one of many ways of doing this. The situation dictates what you actually implement. You need to learn about objects, instances, pointers, call by value, call by reference and lots of other concepts. I suggest you get yourself a good C++ book. Lorenz Prem Microsoft Corporation -
DirectX Help pleaseIf you want to switch to full screen mode, in d3d use the Windowed parameter in PresentParameters. In directdraw have a look at the SetCooperativeLevel() function. Lorenz Prem Microsoft Corporation
-
key pressed and bitmap button pressed !You can find out how to make the three buttons with bitmaps on them here on the code project. The MSDN library also has information on this topic. Once you are done with the buttons, you should have a function associated with each button. From there you have to listen for keyboard events. Should a key you are interested in be pressed, you just call the function for the proper button you want to press. Lorenz Prem Microsoft Corporation
-
I need help in timers or conversionsI suggest you keep the counter and the target value in integer format. This way you can compare them easily and perform a lot of other operations like increment easily. You’ll need to convert from string to int, when the user enters the value. For display purposes you can either format the integer into a nice looking string, or display it directly. Lorenz Prem Microsoft Corporation
-
how can I access variable in View class from my dialog member function?Getting your data directly from the view in a single document application is bad design to some degree, because it breaks the SDI template. You can expect major reusability issues when you link your dialog directly to the view, since the view in turn is linked to the document. If you can help it, try declaring member variables for the data in the dialog and fill those members with the actual data from the document just before you call domodal. After the dialog returns, read the changes from the member variables back to the document. This way you’ll get a dialog class, which does not ‘directly’ depend on a particular view or document class. Concepts like this will not make your app work any different, but they will help maintenance and improve reusability. Lorenz Prem Microsoft Corporation
-
How to create a text field within a dialog boxI agree that your solution is much more elegant and readable, but getting a pointer to the control is also a vital step in many other not so basic scenarios. I figure I better answer the question the way it is most useful, not necessarily in the shortest way. That includes the cast, which might be necessary for other things besides setting the text. Lorenz Prem Microsoft Corporation
-
How to create a text field within a dialog boxI assume you already have a dialog working. Got to the resource editor and add a static text control. Its ID is going to be IDC_STATIC change that to your own ID. Like IDC_MYTEXT. What you put as the text of the static control is going to be the text that is initially displayed. Now, in one of your dialog message handler, wherever you want to change the text on the dialog, put the following: CStatic* pText = (CStatic*) GetDlgItem(IDC_MYTEXT); //get a pointer to the control pText->SetWindowText(“Hello World”); //set the text When the message handler is called the text is going to change to Hello World. This works with an edit box too. Make an Edit box on your resource template with ID IDC_MYEDIT. The following code will display the text. CEdit* pEdit = (CEdit*) this->GetDlgItem(IDC_MYEDIT); pEdit->SetWindowText("Hello World"); I hope this helps. Lorenz Prem Microsoft Corporation