First you have to write an OnTimer() event handler. That is a function that you want MFC to call every second. This example has it in CMainFrame, but you can put it in any of the CWnd derived classes, such as CMyDialog. You can have up to 10 timer events active at the same time, so nIDEvent parameter just tells which event is being called. You set that event number when you start the timer, explained below.
Next, you have to turn on the timer somewhere in the code.
m_nTimer = SetTimer(1, 2000, 0);
The first parameter is an id number that you want MFC to use to identify the timer event. The OnTimer() function will be passed that number (see above)
The second number is the number of milliseconds you want the timer event handler to be called. The example shows it wants the event to be fired every two seconds.
The last parameter is a pointer to the function you want to be called. If that parameter is 0 (or NULL) it is assumed to be the OnTimer() method of the MFC class in which SetTimer() is called. Otherwise, if the prameter is Not called then it can be any function you want. See the SetTimer link for a more detailed explaination.
The return value is the MFC id of the timer event, if SetTimer() is successful. Use this value to pass to KillTimer() to stop the events.
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...