SetTimer -> OnTimer driving me crazy

Hi,

I found numerous examples of SetTimer and OnTimer examples on the web and 
they all look similiar to what I have tried here, but my OnTimer function is 
never executed.

I created a SDF Application and launched a dialog off of the menu.  In the 
Dialog I call a SetTimer and then delcared a OnTimer function also a member 
of the same dialog object.  I never get the TRACE statement in the OnTimer 
to fire and a button displays that the global_sent variable is never 
updated.

Here's where I set the timer in the dialog's OnItit function:

--------------------------------------------------------------------------------------
BOOL CMyDialog::OnInitDialog()
{
 int success;
 CDialog::OnInitDialog();

 global_sent = 0;
 success = SetTimer(3,2000,NULL);


 TRACE("Succes = %d\n", success);


 // TODO: Add extra initialization here

 return TRUE;  // return TRUE unless you set the focus to a control
               // EXCEPTION: OCX Property Pages should return FALSE
}
--------------------------------------------------------------------------------------


Here's where I defined the OnTimer function:


--------------------------------------------------------------------------------------
void CMyDialog::OnTimer(UINT nIDEVENT)
{

 global_sent++;

 TRACE("Here\n");

 AfxMessageBox("hello");

}
--------------------------------------------------------------------------------------

Thanks for any info....  It seems that it should be so easy...

Mark Reap
mdreap@swbell.net


0
mdreap (4)
5/21/2006 9:42:30 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
1058 Views

Similar Articles

[PageSpeed] 59

Mark D. Reap wrote:

> Hi,
> 
> I found numerous examples of SetTimer and OnTimer examples on the web and 
> they all look similiar to what I have tried here, but my OnTimer function is 
> never executed.
> 
> I created a SDF Application and launched a dialog off of the menu.  In the 
> Dialog I call a SetTimer and then delcared a OnTimer function also a member 
> of the same dialog object.  I never get the TRACE statement in the OnTimer 
> to fire and a button displays that the global_sent variable is never 
> updated.
> 
> Here's where I set the timer in the dialog's OnItit function:
> 
> --------------------------------------------------------------------------------------
> BOOL CMyDialog::OnInitDialog()
> {
>  int success;
>  CDialog::OnInitDialog();
> 
>  global_sent = 0;
>  success = SetTimer(3,2000,NULL);
> 
> 
>  TRACE("Succes = %d\n", success);
> 
> 
>  // TODO: Add extra initialization here
> 
>  return TRUE;  // return TRUE unless you set the focus to a control
>                // EXCEPTION: OCX Property Pages should return FALSE
> }
> --------------------------------------------------------------------------------------
> 
> 
> Here's where I defined the OnTimer function:
> 
> 
> --------------------------------------------------------------------------------------
> void CMyDialog::OnTimer(UINT nIDEVENT)
> {
> 
>  global_sent++;
> 
>  TRACE("Here\n");
> 
>  AfxMessageBox("hello");
> 
> }
> --------------------------------------------------------------------------------------
> 
> Thanks for any info....  It seems that it should be so easy...
> 
> Mark Reap
> mdreap@swbell.net
> 
> 

Mark:

When you pass NULL as the third parameter to CWnd::SetTimer(), you must 
handle WM_TIMER message. Did you do this? If not, get rid of your 
existing OnTimer() declaration and definition, and let the ClassWizard 
regenerate them for you with the correct mesage map entry.

David Wilkinson
0
no-reply8010 (1791)
5/21/2006 10:00:53 PM
David,

Thanks very much.  This worked right away.  I don't program that often and 
the last time was in Linux and I may have thinking in terms of Unix 
callbacks...

Thanks again.

Mark


"David Wilkinson" <no-reply@effisols.com> wrote in message 
news:OExxGISfGHA.356@TK2MSFTNGP02.phx.gbl...
> Mark D. Reap wrote:
>
>> Hi,
>>
>> I found numerous examples of SetTimer and OnTimer examples on the web and 
>> they all look similiar to what I have tried here, but my OnTimer function 
>> is never executed.
>>
>> I created a SDF Application and launched a dialog off of the menu.  In 
>> the Dialog I call a SetTimer and then delcared a OnTimer function also a 
>> member of the same dialog object.  I never get the TRACE statement in the 
>> OnTimer to fire and a button displays that the global_sent variable is 
>> never updated.
>>
>> Here's where I set the timer in the dialog's OnItit function:
>>
>> --------------------------------------------------------------------------------------
>> BOOL CMyDialog::OnInitDialog()
>> {
>>  int success;
>>  CDialog::OnInitDialog();
>>
>>  global_sent = 0;
>>  success = SetTimer(3,2000,NULL);
>>
>>
>>  TRACE("Succes = %d\n", success);
>>
>>
>>  // TODO: Add extra initialization here
>>
>>  return TRUE;  // return TRUE unless you set the focus to a control
>>                // EXCEPTION: OCX Property Pages should return FALSE
>> }
>> --------------------------------------------------------------------------------------
>>
>>
>> Here's where I defined the OnTimer function:
>>
>>
>> --------------------------------------------------------------------------------------
>> void CMyDialog::OnTimer(UINT nIDEVENT)
>> {
>>
>>  global_sent++;
>>
>>  TRACE("Here\n");
>>
>>  AfxMessageBox("hello");
>>
>> }
>> --------------------------------------------------------------------------------------
>>
>> Thanks for any info....  It seems that it should be so easy...
>>
>> Mark Reap
>> mdreap@swbell.net
>>
>>
>
> Mark:
>
> When you pass NULL as the third parameter to CWnd::SetTimer(), you must 
> handle WM_TIMER message. Did you do this? If not, get rid of your existing 
> OnTimer() declaration and definition, and let the ClassWizard regenerate 
> them for you with the correct mesage map entry.
>
> David Wilkinson 


0
mdreap (4)
5/22/2006 1:15:09 AM
Reply:

Similar Artilces:

Can I Test Flash Drive?
Hi y'all, I posted awhile back about a seriously compromised PC and although you may not need them for my questions below, I am providing the link to *said* posts: http://groups.google.com/group/microsoft.public.windowsxp.general/browse_thread/thread/75b9dbdca208430a/3e09082b8bd649a2?hl=en&lnk=gst&q=%7ESage#3e09082b8bd649a2 Since then, my friend decided to buy a new PC (yeah!), and I decided not to try and post logs from her bad one, her Windows XP was acting very sick, but I managed to copy all the important files she needed to a flash drive. I need to test the flash d...

map network drive in MFC
Can I map (create) a network drive in MFC? Thanks. Wanjun ...

How to programmability format a removable drive?
I am working on an image presentation system that ingests images from memory cards. I need to give the user the option to "format" the memory card once the images are copied to the computer. The question is: How do I very quickly clear or format the memory card programmatically? Cartopre Browse this thread: http://groups.google.com/group/microsoft.public.win32.programmer.kernel/browse_thread/thread/d46a7e2b862560a0/915aa8407dbdb1f7?lnk=gst&q=format#915aa8407dbdb1f7 -- V. This posting is provided "AS IS" with no warranties, and confers no rights. "Cartoper&q...

three new folders appeared on C drive
I discover that three new folders have appeared on my C drive. I think they appeared after the power went out here. They are: Found.000 Found.001 Found.002 There are a number of FILE....CHK files in them. I assume they're do to the pc recovery check after the power went out. Do I need to keep these folders/files? Jack Jack B wrote: > I discover that three new folders have appeared on my C drive. I > think they appeared after the power went out here. They are: > Found.000 > Found.001 > Found.002 > > There are a number of FILE....CHK file...

Citizen Silhouette Eco-Drive Womens Watch EW8844-51E
Citizen Silhouette Eco-Drive Womens Watch EW8844-51E Discount Watches Site : http://www.hotwatch.org/ Citizen Silhouette Eco-Drive Womens Watch EW8844-51E Link : http://citizen.hotwatch.org/Citizen-EW8844-51E.html Citizen Silhouette Eco-Drive Womens Watch EW8844-51E Information : Brand : Citizen Watches ( http://citizen.hotwatch.org/ ) Gender : Ladies Code : Citizen-EW8844-51E Item Variations : EW8844-51E, EW884451E, EW8844, Citizen- EW8844-51E, Citizen-EW884451E Movement : Quartz Bezel : Fixed Case Material : Two-tone Stainless Ste...

1000 errors drive me crazy
Hi, since years I'm bearing these 1000 errors in the application logs of my sbs 2003 servers (they're all standard with SP2). I've read for hours and hours and tried dozens of hacks, but nothing helped. The errors are: Error 1000 Windows Sharepoint Services 2.0: #50070: Connection to database STS_Config... Error 1000 Windows Sharepoint Services 2.0: #30002: Error 5 opening ... ConfigDb The first error occurs during boot only, the second now and then. Users don't use Sharepoint Services on none of my servers, so I cannot say wether there are any malfuncti...

I would like to be able to run Outlook from my U3 USB Smart Drive.
I would like to be able to run Outlook from my U3 USB Smart Drive. Please explain whether and how it can be done? Regards, Amiram Not possible since Outlook does not support the U3 platform. -- Robert Sparnaaij [MVP-Outlook] Coauthor, Configuring Microsoft Outlook 2003 http://www.howto-outlook.com/ Outlook FAQ, HowTo, Downloads, Add-Ins and more http://www.msoutlook.info/ Real World Questions, Real World Answers ----- "AkhPotter" <AkhPotter@discussions.microsoft.com> wrote in message news:6E9F6F33-3F94-4674-B54A-CC516B6FA5B6@microsoft.com... > I...

Worksheets Blank when Opened using Explorer & Networked Drive
I have an end-user reporting the above issue. He is running Office 2000 Professional SP3 on Windows XP. I have suggested that he attempt a Repair of Office - did not fix. I suggested a Removal and Reinstallation of Office & Service Packs - did not fix. Any ideas would be appreciated. Thanks, Terry C His issue as presented to me is below.... I can not directly open Excel spreadsheet on network (N:) drive or local C: drive using Explore from the Start menu. I also can not directly open a spreadsheet if it is an email attachment, I must save it to local drive first, then open it from w...

Flash Drive and Windows Explorer
In windows xp professional, how do I stop windows explorer from opening a new window when I plug in the flash drive? The flash drive has no files on it. Disabling autoplay has no effect. The window that opens, does it give several choices, the last one is "Take no action." If so, select it and check the box below on the window. -- Don Vancouver, USA "Paul" <pphop868@yahoo.com> wrote in message news:ae548c64-1df2-4667-99ba-9d0f1a980e5e@p32g2000vbi.googlegroups.com... > In windows xp professional, how do I stop windows explorer from > openi...

DVD drive struggles with DVDs
This might be a double post. I killed the original screen too quickly and couldn't find the post anywhere. Recently I reinstalled my OS to fix a registry error. Now my DVD drive won't read DVDs. It can read data and audio CDs just fine. I tried using DVD Decryptor to move a movie onto my computer so I could watch it. Upon inserting the dvd, it takes a long time to think about it. The dvd drive sounds wrong - not loud, just quietly skittery. It does eventually find the iso files, but when it tries to 'parse' them I get this error: I/O Error! ScsiStatu...

FileInfo.CopyTo to a mapped or network drive
The MSDN Library documentation tells me that CopyTo will, when run by an elevated-trust application, copy a file to a target location. In a .Net desktop application I have no trouble doing this in the local file system, but I'm throwing an "access denied" exception when copying to a mapped drive in my local file system. Defining a FullTrust security policy for the mapped drive through the Microsoft .Net Framework 2.0 Configuration control panel application has no effect on the problem. What permissions do I need to have for the application, and if it can be done ...

Restoring an image after repartitioning the image restore drive?
I'm a little confused about this: I save several (different-dated) system images on my backup drive, with a pretty large partition reserved just for storing those system drive (C: ) images (the rest of the space on that drive is still unallocated). Now suppose I increase the size of the partition on the backup drive (which stores those images) to make more room for more of them, and subsequently save a few more backup images. Ok, no problem so far. But now if decide to restore a much earlier image (where the partition size on the backup drive was previously allocated as...

AppleScript to keep Office 2004 or X from opening files and database on wrong drive?
I've noticed that immediately after I've cloned volumes to the backup internal hard drive with Retrospect's "Duplicate" feature, the first time I click on a Word or Excel file alias, it leads to the wrong drive. It seems that that the files on the backup drive at that point might be seen by OS 10.3.x (and Office) as newer/more recent than what's on the primary drive from which they've been cloned.. I was told that there "always" have been "minor issues" with Retrospect and aliases. Unfortunately, I learned from experience that "minor&qu...

Microsoft ODBC Drive Manager: Data Source Name not found and No Default Driver Specified
This is a multi-part message in MIME format. ------=_NextPart_000_000C_01C831F9.1F940070 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I've been meaning to ask this question for years (literally). In the Excel reports that I create for others in the company, I almost = exclusively use external data via MS Query from SQL databases. I always = use a system ODBC connection created not within Excel, but within the = ODBC administrator. In many cases I'll use the SA login and password = for the connection and in some cases, I'...

Drive Configuration for Exchange 2003
I currently have exchange 2003 installed on a windows 2003 server. Exchange is installed on the c: drive which is a 40gb drive. We are in the earlt implementation stages of exchange, there are no mailboxes set up, no public folders, its is basically just a clean install of exchange at the moment. We also have a d: drive which is 200gb, i want to put all the mailboxes and all the public stores on the d: drive as a fear that the 40gb drive will fill up quite quickly once we start using exchange fully. How can i change the mailbox and public store, and anything else that will take up a...

How do I lock a folder on a shared drive ?
I'm using windows xp. I would like to lock a folder on the shared drive so only I will have access the to files contained. Tony Brown wrote: > I'm using windows xp. > I would like to lock a folder on the shared drive so only I will have > access the to files contained. Which version of XP? -- Interim Systems and Management Accounting Gordon Burgess-Parker Director www.gbpcomputing.co.uk ...

CFileDialog drives me insane. Handle Problem ?
Hi, i want to communicate some strange Problems i have with CFileDialog. Hope someone can push in the right direction. 1. Problem: CFileDialog FileDlg(true); INT_PTR nResponse = FileDlg.DoModal(); if (nResponse == IDOK){}else{return;} LPSTR file = FileDlg.GetFileName().GetBuffer(); LPSTR folderPath = FileDlg.GetPathName().GetBuffer(); ULONGLONG fSize = GetFileSizeInByte(fileUrl.GetBuffer()); long GetFileSizeInByte(const char* sFileName) { std::ifstream f; f.open(sFileName, std::ios_base::binary | std::ios_base::in); if (f.eof()) { return 0; } if (!f.good()) { return -1; } ...

Creating Automatic Backup Files on another drive
Excel / Word create automatic backup files (.xlk / .wbk) when the option is selected. Can this backup be created not on the same drive as the main file (e.g. C) but on another drive (e.g. Y) ? That way there is more data security If you are referring to AutoRecover feature, you can select the destination under Tools~Options~Save "helvetik" wrote: > Excel / Word create automatic backup files (.xlk / .wbk) when the option is > selected. Can this backup be created not on the same drive as the main file > (e.g. C) but on another drive (e.g. Y) ? That way there is more da...

How to change the drive boot order by code?
Hi, I need to force a PXE boot so I need to change the boot priority. I know boot order depends on BIOS, but how can I change it by code? Thanks, How to change the drive boot order by code? On Nov 18, 3:39=A0pm, Javier C=E0ceres <JavierCce...@discussions.microsoft.com> wrote: > Hi, > > I need to force a PXE boot so I need to change the boot priority. I know > boot order depends on BIOS, but how can I change it by code? > > Thanks, > > How to change the drive boot order by code? In which part of your code are you going to do it? Anything is...

Exchange is driving me crazy please help.
I have just started working at a company last weeek appearently they have lot of issues with Exchange. We have lost our email and our clusters went down for two hours. After sometime we figured out the service accounts for exchange and cluster was locked out for some reason. After unlocking the accounts manually. Cluster and the exchange came back online. Now internal users are unable to email to internal users on the other servers. Example server A can not send email to server B. We have three exchange servers in our enviroment and they are clustered. They can send emails to the inter...

Reinstall after hard drive crash?
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel I recently had to replace my hard drive, and lost all of the data on it. I still have the product key I used to install office the first time, but I am wondering if I can still use it? Microsoft support is no help (they want me to pay 49$ just to call them!) Thanks In article <59b7379c.-1@webcrossing.caR9absDaxw>, mork@officeformac.com wrote: > I recently had to replace my hard drive, and lost all of the data on it. I > still have the product key I used to install office the first time, but I am > wo...

Connecting to a network drive using VBA
Hi, I would like to call a excel file which is actually stored in a network. There are two networks which i want to connect, one is controlled by user account and the other is a open one. Can anyone please help me to write a code which will either connect to the network drive by getting the username/password or by anyother way of directly calling the network folder probably using FileSystemObject library. Its ok even if it has to connect a drive to the network path. But would be useful if you tell me how to remove this within the code!! For Eg: the network path would look like \\10.10...

Files No Show on CD-RW Drive D:
I have an MS-Dos boot RW-CD with Dos Utilities in folders and files, which boots and works fine in drive D:.... Nero StartSmart shows D: Track 01: 0:0200 57:16.18 (504MB), Data... Why won't WinXPpro show the files and folders on drive D:, instead of just a blank white screen ???? "Willard" <guess@msn.invalid> wrote in message news:uZieoNK4KHA.5416@TK2MSFTNGP06.phx.gbl... > I have an MS-Dos boot RW-CD with Dos Utilities in folders and files, which > boots and works fine in drive D:.... > > Nero StartSmart shows D: Track 01: 0:0200 57:16...

SBS 2008 Backups
Our SBS 2008 server backs-up daily to an external USB HDD. That disk is now nearing full so we are about to replace it with a larger disk. My question is how do I take the existing old backups off the current disk and put them onto the new disk? I want to retain the older backups but retire the current disk, not retain it. Hope you can assist Ian Ian W wrote: >Our SBS 2008 server backs-up daily to an external USB HDD. That disk is now >nearing full so we are about to replace it with a larger disk. > >My question is how do I take the existing old backups off t...

Retrieving/opening Outlook express emails from old drive
Hi all, I recently needed to replace the hard drive in my notebook. The old drive is still operational, so I can now using it as an external hard disc. How can I open to read / and save or import all the email folders in Outlook express from this older disc? I'd like to save all those messages to a backup/archive. Thanks, Shayne. Try posting this in an Outlook Express news group - this is not one of them. Outlook is a part of Microsoft Office and is what this group supports. Outlook Express is a part of Internet Explorer and has its own news groups. You can also find some good Out...