SetTimer() for my MainFrame

Hi guys,

I added a clock to my status bar, so in my CMainFrame I want OnTimer() to 
keep it updated.

Where should I start the timer with SetTimer() and kill it with KillTimer() 
? Probably in OnCreate() and OnDestroy(), does that sound right ?

Thanks.


0
satan1 (32)
5/24/2005 8:54:16 PM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
1153 Views

Similar Articles

[PageSpeed] 56

Guess What. You should probably call SetTimer in OnCreate anywhere after you
have already created the Status bar.

Call KillTimer in your OnClose Method.

AliR.

"Robert A." <satan@invalid.org> wrote in message
news:%23SfFBLKYFHA.228@TK2MSFTNGP12.phx.gbl...
> Hi guys,
>
> I added a clock to my status bar, so in my CMainFrame I want OnTimer() to
> keep it updated.
>
> Where should I start the timer with SetTimer() and kill it with
KillTimer()
> ? Probably in OnCreate() and OnDestroy(), does that sound right ?
>
> Thanks.
>
>


0
AliR1 (391)
5/24/2005 9:15:32 PM
Reply:

Similar Artilces:

How to pass data from mainframe to modal dialog?
I have a public member variable (user-defined structure) declared in MainFrame.cpp and I would like a modal dialog box to have access to this variable. What is the proper way to pass data to a modal dialog box? Thanks in advance. Create a pointer to this variable in the dialog, and set it before calling the dialog. The example below presumes that the dialog is being called from the mainframe. Otherwise, you will have to get access to the mainframe to get the pointer. Generally, accessing variables in another class is suspect. in mainframe.h Whatever data; in CMyDialog.h: public: Whatev...

Text file from mainframe system
We are working on extracting a data file from an IBM mainframe system to merge it into a .csv Excel file. The options for saving the file are either ASCII or carriage- return indicator at the end of each line. What is Excel looking for at the end of each line for it to merge the data into the spreadsheet correctly? We have tried both options and it merges all info into one row. How are you merging your data into excel? For most DOS/windows programs, the end of line character is crlf (carriage-return/Line-feed). It's really two different characters (hex 0D, followed by hex 0A)....

Receiving windows message after mainframe is destroyed
Hi I am posting this again - not having heard anything in several days. Please let me know if there is another group I shoudl post this to. ------ I am stuck and could use any suggestion. My application (MSVC 6 & MFC) uses a mainframe that is hidden soon after it is created & uses a tray icon for user interactions. I have had no problem for quite some time - till I upgraded from WinXP home - SP1 to WinXP rpo XP2. The application crashes on exit in the debug mode. The error is an ASSERT in CWnd::WalkPretranslateTree. This function is checking if any windows wants to translate the me...

How to route a message from MainFrame to Doc and View?
Hello everyone, I am working on an SDI application called Test. In the CTestApp::InitInstance() I create a worker thread to which I pass the HWND of the application (*m_pMainWnd) and the message ID. In the worker thread, when I post a message using PostMessage() to the main window, I can only catch it in the MainFrame. I tryied to catch it in the TestDoc or in the TestView without succeeding. From my understanding, whenever the MainFrame receives a message it routes it to the documents and views, if it didn't handle it! 1. How could I route the received message in the MainFrame to ...

mainframe title bar
In my SDI app, is it possible to change the text in the title bar at any point after startup? >In my SDI app, is it possible to change the text in the title bar at any >point after startup? Steve, You can change the caption using SetWindowText, however the MFC doc/view arrangement normally sets the caption for you. To prevent it doing this, remove the FWS_ADDTOTITLE style. Have a look at the MSDN topic titled "Changing the Styles of a Window Created by MFC" for more information. Dave -- MVP VC++ FAQ: http://www.mvps.org/vcfaq Thank you. I currently do alter the cap...

How to use SetTimer
Hi All, How to use SetTimer without a Window Class? Please help I have the following code, but the TimerProc() will never been called. class MyClass { public: MyClass() { ::SetTimer(NULL, NULL, 1000, (TIMERPROC) TimerProc); } ..... static void CALLBACK TimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) { // Do Something ......... } }; Rgds, Marco From the help: "When you specify a TimerProc callback function, the default window procedure calls the callback function when it processes WM_TIMER. Therefore, you need to...

Maximizing a child without docking it to the Mainframe
I have an MDI application, and want to implement the next feature: When the user hits the MAXIMIZE button in a child frame, it grows to a certain size, but DOESN'T dock to the mainframe. Right now, I've written some code overriding the OnGetMinMaxInfo event in the ChildFrame class, that does the part of maximizing the window just to the desired size, but the child in anyway docked to the mainframe. I tried commenting out the call to the base function (CMDIChildWnd::OnGetMinMaxInfo(lpMMI)) but without any results. I don't know if there's any other event I can override to avoid t...

How to change the menu's skin of the mainframe
Hi All: I have a requirement to change the look & feel of menu's skin in the mainframe. And I draw the title's backgroud color,but when the window moving or resizing,the color is not steady. why? And I cancle the function of " cs.style &=~(WS_SYSMENU)" in the function PreCreateWindow(), but when I double click the window's title,the window can't change into big. why? How do I can waiting for reply. Thanks & Regards, terrcy terrcy, You might want to check http://www.codeguru.com/Cpp/controls/menu/ and http://www.codeproject.com/menu...

Adding Edit Control to MainFrame.
I'm trying to add an Edit Control to MainFrame. I'm creating an instance of CEdit in the paint message like this: void SAFrame::OnPaint() { CFrameWnd::OnPaint(); CEdit *PEdit = new CEdit; PEdit->Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, CRect(10, 50, 150, 70), this, 0x1552); } But the control is not displayed. I think you have better ideas. -- Saint Atique [Novice MFC Programmer] "Saint Atique" <unix9n@gmail.com> wrote in message news:1db59444-17d4-4bc1-bc7a-1adcf3b75b9b@v8g2000vbh.googlegroups.com...

how to reset the mainframe title
Hello Guys, In my SDI application when I open a document I set main frame tilte to my own text using the following in CMyDoc::OnFileOpen(): CMainFrame* pFrame = (CMainFrame*)::AfxGetMainWnd(); pFrame->SetWindowText(MyOwnTitle); Now when I open print preview and close it, coming back to my original view I lose the frame title and it is initialized to standard MFC string "untitled...". Can somebody telll me how I can preserve my own title or where I can set it again when I am back from print preview window. Thanks in advance. Regards Nemo You should use CDocument::SetTitle(..) ...

trouble docking control bars vertically on the MainFrame
I'm attempting to attach a series of dockable control bars (of type CDialogBar) to the MainFrame of my application. The dialog bars should be placed in a single column on the right hand side of the MainFrame (i.e. each dialog bar should be docked immediately above the next). Unfortunately, when I add the dialog bars to the MainFrame, they get placed side by side (horizontally, instead of vertically) To change this behavior, I've tried the following .. 1.) setting the bar styles using the following flags CBRS_ORIENT_VERT vs. CBRS_ORIENT_HORZ 2.) overriding CControlBar::CalcDynamicLa...

problem with settimer
Hi i'm using Settimer in a service. I've called Set timer as UINT nid = ::SetTimer(NULL, 0,100,(TIMERPROC) MyTimerProc); where TimerProc is defined as void CALLBACK MyTimerProc( HWND hWnd, // handle of CWnd that called SetTimer UINT nMsg, // WM_TIMER UINT nIDEvent, // timer identification DWORD dwTime // system time ) { switch(nMsg) { case WM_TIMER: break; } } I dont know why but i dont get the WM_TIMER event in the callback function..i mean the function TimerProc is never called even after the time specified in SetTimer() func...

SetTimer()
I am using MFC's to develop and application that reads data from serial port every sec or 500ms Parse & update data into dialog boxes. This is what I have in mind, Let me know if this will work. I am really keeping it as simple as possible. I don't really need a high accuracy in Time.. CSerialIO::OnBnSerial() { ...... ...... //All Initializations here SetTimer(IDC_Time,500,Null) } CSerialIO::OnTimer(UINT nIDEvent) { ReadSerialport(); //All the data reading & Parsing is done in this function UpdateData(False); CDialog::OnTimer(UINT nIDEVENT) } Once I press...

SetTimer ?
In my VC6 MFC app, I establish a timer by using a call to SetTimer(...) for an elapsed time of 5 second intervals. All working fine in this manner, but... I need to reset this timer to start counting at zero if a certain unrelated event occurs. Can this be done in this rather primitive arrangement? I'm wondering if I could call KillTimer and immediately call SetTimer each time I need to reset this timer? Is there a better way? Essentially, I am recognizing when a mouse cursor enters a window and at that moment, I need to set the timer to trigger a message 5 seconds later. Any...

Recycling MainFrame View in an SDI
Hello: I have a CFrameWnd that overrides OnCreateClient to create a static splitter window with three views. I now have a need to support 2 different formats, 2 rows with the top row having 2 columns or 2 columns with the right column having 2 rows. Therefore, I need to be able to scrap the splitter window and force OnCreateClient to be called again (to create a splitter window in the correct format) I need this to occur at run time through a menu option. I have the code written, but I don't know how to successfully scrap the original splitter window and create another. Whe...

MainFrame Aborts When Created
I have an AppWizard-created MFC program that will not run on my development computer any longer. This just happened. It *will* run on other computers. Older versions of the same program which I know I debugged on my development computer will now not run. All other dialog-based and MDI programs run okay. This one just closes immediately and there are no error messages other than the memory leaks that I would expect. This is VC++ 6.0. The problem happens in Debug or Release mode. In Debug the program closes immediately after this line: CMainFrame* pFrame = new CMainFrame; If I de...

Message Box is hidden behind the mainframe
hello we use VC8 and develop an MFC SDI application ith several modeless windows (panes). (we use Codejock Xtreme toolkit for UI) we encounter the following bug which causes the application to hang: whenever the user edits an edit box in one of our modeless windows, and then presses alt-F4 to close the application (while still editing the edit box), the messagebox (prompting to save the document before closing) appears HIDDEN behind the mainframe. The application is not responding (because the messagebox is still open) but the message box is not shown and the user has no indication that a me...

timer functions-SetTimer(help-urgently)
hello, I am reading a file in chunks of 512 bytes(i am reading 2 such blocks).I am calling SetTimer function.And in corresponding OnTimer function I am writing code for displaying the file data on a graph control placed in my dialog box.I am calling the KillTimer function after the 2 chunks of data are displayed as graphs. But when i close the dialog or press OK/Cancel button the dialog MFC application error box appears which asks "whether to send the error report to microsoft".Why is this coming?First i thought maybe the KillTimer function isnt properly called but th...

Adding scroll bar to Mainframe
-------------------------------------------------------------------------------- hi, Can anyone let me know how to add a scroll bar to Mainframe in MDI application? Thanks Madhavi What good would this do? Note that the MDI children are contained in an MDI Frame Window. If you wanted to scroll the MDI children, you would have to put a scrollbar in this window. joe On 30 Sep 2004 23:41:33 -0700, jmadhavi@yahoo.com (madhavi) wrote: >-------------------------------------------------------------------------------- > >hi, > >Can anyone let me know how to add a scroll bar to ...

problem with SetTimer()
Hi All, I've a problem with SetTimer function. I've wrote this code: class myClass { void CALLBACK TimerProc( HWND hWnd, // handle of CWnd that called SetTimer UINT nMsg, // WM_TIMER UINT nIDEvent // timer identification DWORD dwTime // system time ){ //some code.... } myClass() { SetTimer (1, 1000, (TIMERPROC) TimerProc); } } the compiler returns a conversion error for 3th parameter of SetTimer (TimerProc) help me, what's wrong ?? System info: - Visual Studio 7.0 - Windows XP SP2 Make TimerProc() static. class myClass { static...

Why I couldn't SetTimer in ListView
I create new SDI project by AppWizard, at the final stage I modify the view class from CView to CListview. Everything is fine before I try to set a Timer in the ListView. I simply call CWnd::SetTimer to start a timer, then use classwizard to generate code to process WM_TIMER message Here comes the code: void CListView::OnTimer(UINT nIDEvent) { if (nIDEvent == 1) { .... } CListView::OnTimer(nIDEvent); } But the I found the message WM_TIMER is been delivered only once, then there are no more WM_TIMER after the first call to CListView::OnTimer. I am totally puzzled, could anyb...

Another SetTimer question
Why is it that the following settimer is not working? the call back function TimerProc_Wrapper is never called after 5 secs?Why? Thanks for any help rendered. I want to be able to interrupt the timedelay instead of using the sleep(5000). ------------------------------------------------------------------------------------------------------- Inside the testDoc.h class CTestDoc : public CDocument { //UINT MyThreadFunc(LPVOID lParam); static UINT_PTR m_TestTimer; static VOID CALLBACK CTestDoc::TestTimerProc( HWND hwnd, UINT uMsg, UINT idEvent, DWORD dw...

How can I import "Packed" mainframe data into Excel?
I've copied a file from an IBM Mainframe computer to my PC and need to do some analysis in Excel. Some of the fields in the file are "packed" - for example, the format of one field is " P(9.2). On the mainframe, that takes up six bytes, so $5.90 is stored as "00000000059F" (the last bit is the sign). This is NOT "hex" but an old convention that breaks each byte (EBCDIC 8-bit) into two, 4-bit parts and stores one decimal value in each part. Suggestions about how I can get this format into Excel without having to re-format the data in a mainframe ...

How to remove the menu on the mainframe?
How to remove the menu on the mainframe? Take a look at the following KB article HOWTO: Create MFC Applications that Do Not Have a Menu Bar http://support.microsoft.com/?id=131368 -- Cheers Check Abdoul [VC++ MVP] ----------------------------------- "Marco" <sorry@nomail.com> wrote in message news:%23woTN7pXEHA.3292@TK2MSFTNGP09.phx.gbl... > How to remove the menu on the mainframe? > > ...

Data from DialogBox to MainFrame
Hi, I have a CDialogBox class, which collects some information (Cstrings and ints), and stores them in internal variales. I would like to pass that information to the MainFrame class. how can i do that? I'm using Visual Stuido 6.0. SDI. thanks in advance Martin wrote: > Hi, I have a CDialogBox class, which collects some information > (Cstrings and ints), and stores them in internal variales. I would like > to pass that information to the MainFrame class. how can i do that? > I'm using Visual Stuido 6.0. SDI. > thanks in advance > Martin: Is this a modal or mod...