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


0
marco (7)
9/23/2004 10:18:24 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
609 Views

Similar Articles

[PageSpeed] 4

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 dispatch messages in the calling thread, even when you use 
TimerProc instead of processing WM_TIMER. "


So, your TimerProc won't get called if your code is stuck in a loop 
somewhere - you need to be pumping messages.



"Marco Hung" wrote:

> 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
> 
> 
> 
0
9/23/2004 11:05:04 AM
This is probably the wrong approach. It has many problems. First,, as already pointed out,
it won't do anything if you are not pumping messages. Second, the timer procedure can't
access any class member variables. It is usually a bad idea to try to use a timer like
this without a window class.  What I typically do under these conditions is to create a
hidden window which is the timer message sink, and it has everrything in it I need to deal
with, and I put an OnTimer handler in it. 

There is code that shows how to do this on my MVP Tips site. I needed a timer on a
CDocument; I shown how I did this.
				joe

On Thu, 23 Sep 2004 18:18:24 +0800, "Marco Hung" <marco@xmlhk.com> wrote:

>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
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
9/25/2004 2:27:38 AM
Reply:

Similar Artilces:

Using Extender to open an existing GP window when in another GP wi
We use GP 10.0 and also own Extender. When I attended an Extender session at Convergence last year, I seem to remember we were told it is possible to use Extender to add a link to a GP window to open another GP window. Does anyone know how to do this? For example, when in a customer card, I would like to be able to click on the "Additonal" tab up the top and select the window: Field Service - Inquiry - Contract Administration - Contracts by Customer Inquiry. Thanks for your help. You could only open GP windows using the Extender. I do not think there is a way to open up other...

5.5: use contacts public folder as mailing list?
Hi everybody, I have unsuccessfully been trying to set up some kind of simple mailing list based on the contents of a public folder. I have found a workaround using an Outlook 97 local address book, but I can't believe that that is the only answer. I have tried setting up a distribution list, but emails sent to that list just end up in that folder, rather than use the addresses from the folder. The usenet provided me with similar questions from the past, but surprisingly I couldn't find an answer. Michael ...

Use Combo Box to Select Month to Display Data on Chart
Hi All, I have a bar graph that shows the following information X Axis = Date Y Axis = Copper Produced Question: How can I enable the user to select a month from a drop-down list and the chart show the data only for the selected month? -- Carlee Here are a couple ways: http://peltiertech.com/Excel/Charts/ChartByControl.html http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=246 - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions http://PeltierTech.com _______ "Carlee" <Carlee@discussions.microsoft.com> wrote in message news:7779E1...

how to calculate appreciation using excel 2000
also, what are the common shortcuts? ------------------------------------------------ Message posted from the Excel Tip Forum at http://www.ExcelTip.com/forum/ -- View and post usenet messages directly from http://www.ExcelTip.com -- Hundreds of free MS Excel tips, tricks and solutions ------------------------------------------------ ...

GP printing PM checks to Acuprint using ACL command line
Looking for experience of printing Great Plains PM checks to Acuprint. Have client that is trying to do this by adding ACL command line in check format report writer to tell Acuprint which template to use. Anyone successful in doing this? Thanks. ...

VirtualAlloc,GlobalAlloc,HeapAlloc,..what to use in my case,...
Hi, i have a application that reads a unknown bunch of files to a block of memory, handles them and finally frees the memory. For now, i work with VirtualAlloc, but i get after processing ~250 Files a GetLastError=8 for any memory request, even i know that memory has been released with VirtualFree=TRUE. Why is that the case? The System has 1GB of real physical memory. Sure i know the limitations of user memory space and process space. VirtualAlloc will always be called with MEM_COMMIT and PAGE_READWRITE in my code. I have to read the complete file, not a piece of it, so some files are 205 byt...

Counting cells using multiple criteria
I am using Excel 2000. And, I need to count cells that fall in multiple criteria. For example, I have 5 numbers 93.84, 100, 95, 92.5, and 92.5 in cells from A6 to A10. I wrote the following formula to count the number of the cells that have numbers between 91 and 95, inclusively: =SUM(((A6:A10)>90)*((A6:A10)<=95)) Tha should return 4; however, I get an error messge (#VALUE!). Is that a right formula to count the cells that I want? Actually, the formula I wrote in the previous posting was different than I have. The one I have is as follows: =SUM(IF(((A6:A10)>90)*((A6:A1...

Exchange server using Office 2003 and Vista
I'm trying to connect to my corportate email through Outlook 2003 using exchange server. The instructions that were provided to me are for PCs running Windows XP and Outlook 2003. I can't complete the setup because I don't have some of the icons listed in the instructions. I think it is because of my OS. I am running: Windows Vista Home Premium (64 Bit) Office 2003 Professional Is there a way to setup up Office 2003 to connect using exchange server in the Vista Home Premium or is this ANOTHER feature not available? Any suggestions would be greatly appreciated. ...

Store Use
Hi, is there anywhere in RMS where we can log store use merchandise?? so these Items come off inventory and we can have a record of how much the guys are using in the store. thanks -- Reynold Cycle See the "Handling store use items" thread on 5/9. Craig "Jose" <Jose@discussions.microsoft.com> wrote in message news:297CDA8E-1DF1-4ED4-BA34-1187DD3E7A83@microsoft.com... > Hi, is there anywhere in RMS where we can log store use merchandise?? > so these Items come off inventory and we can have a record of how much > the > guys are using in the store. ...

Workbook Protectionand stiil use Comment function
I have a shared workbook that requires some fields to be used for data entry and some fields for comments ( using the Xl comment function), however, when I protect the workbook the overall comment function is also looked (still allows viewing a previous comment). Is it possible to overcome this scenarion so that one doesn't have to Unprotect the book or sheet everytime a comment needs to be inserted or edited. Many thanks Olympiad In Excel 2003 you can edit comments in protected sheet, if you check the option for Edit Objects in the Protect Sheet dialog. -- tj "olympiad&qu...

Abnormal program termination while using "eseutil /d" #2
Hi Thierry, there is no other server available to move the folders. That´s why we force our users to delete not needed folders. Do you know why the eseutil is running out of order? Sven ...

Can a "flags" or "reminders" be used in a ws
Excell version 2002-Can you set up a worksheet to flash a "flag" or "reminder" that the user needs to update another worksheet in the same workbook. I am a new user to excell and am still struggling. Thanks. You could probably use Conditional Formatting to accomplish this. For example, have a certain cell or cells turn red until the other sheet has been updated. Or, you could write a formula to display a reminder message in a cell if updates aren't complete. Or you could even use VB code for more complex situations. We would need to know more about your spre...

Can I Use AutoNumber Field In Multi-Table Link?
Is there any problem using the AutoNumber field as the primary key, and then using this field to define a 1-M relationship between two tables? I recall being warned against this. At the time, I was using another db app (Paradox). Would this warning also apply to Access? David Portwood wrote: > Is there any problem using the AutoNumber field as the primary key, > and then using this field to define a 1-M relationship between two > tables? > I recall being warned against this. At the time, I was using another > db app (Paradox). Would this warning also apply to Access? No....

how to use the GetClipBox and redraw the particular rectangle
hi all.. actually i need to draw a rectangle in the view window.. then i need to clip the rectangle and need to redraw it.. when we try to resize the view window i want only the rectangle drawn to be redrawn.. others like background should not flicker.. i have tried with.. void CClippingView::OnPaint() { CPaintDC dc(this); CRect rcClient; GetClientRect(&rcClient); dc.FillSolidRect(&rcClient, RGB(255,240,250)); rectClip.top=150; rectClip.left=150; rectClip.right=250; rectClip.bottom=350; dc.GetClipBox(&rectClip); dc.Rectangle(150,150...

Attaching a 2003 Access data base to an email for use with Office
I was using Win XP with Office 2003 and have just installed Windows 7 and Windows Live Mail with Office 2007. I have two other sites which also are using Office 2003 and heretofore, we have had no problems emailing data bases back and forth. But now, Windows Live Mail won't permit our exchanging .mdb files as we have in the past. So, I was told that if we change the .mdb to ..txt we could email and get by Windows Live validation. That does get by the validation, but I am having the problem of changing the .txt data base to ..mdb and getting it to open in Access. Any sugge...

Can't use SendMessage...WM_PASTE with a regular Text Box
Anyone have any idea why SendMessage ctl.hwnd, WM_PASTE, 0, 0 isn't working from a regular Access text box (form is opened normally, not in dialog more)? I realize I can just use docmd.RunCommand acCmdPaste. But I have a reason for needing to do it this way. When I run the code I get the message, "Object doesn't support this property or method" (error 438). Any ideas why this is happening? Thanks! Neil Here is the code I'm using: Private Declare Function SendMessage _ Lib "user32" _ Alias "SendMessageA" ( _ ByVal hwnd As Long, _ ByV...

Collecting data through email using VBA
Hi, I know that the "Create Email" tool in order to collect data through email but I want to do it automatically. My database form includes VBA code in order to send automate emails. I'd like to make this email "special" in order to receive the replay into access and use the answer email. I'd be grateful if someone could help me with the VBA code. Thanks! This capability is included in Access 2007, if you are using the .accdb file format, although you still need to initiate the process (ie. it is not fully automatic). What version of Access are you using? ...

Transfering Outlook Files to a new computer (Using Outlook 2007)
I recently bought a new computer (PC), and want to move my Outlook Account Information (Mail, Calendar, Contacts and Tasks) over to the new computer without having to re-enter everything by hand. I used to have AOL (sorry), and I knew the AOL folder (pfc folder) to copy and paste which stored everything with ease. I merely kept a copy of that AOL pfc folder on a data stick so if ever I had a computer crash, or bought a new computer, all my AOL address book and contact information could be easily transfered. I do not know how to find or access this information (folders/files) with...

using applescript to save as word 2004 format
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel How can I save in word 2004 format with applescript and word 2008 Why do you need Apple Script? File> Save As, select Word 97-2004 Document (.doc) from the Format: list. If it's a matter of needing to use that format routinely set it as the default format in Word> Preferences> Save. If your needs are more complex than those options address you'll have to provide a far more complete, detailed & accurate description of them before anyone can even consider whether an Apple Script solut...

Export to CSV file using "|" as the delimiter
Does anyone know how to export an Excel spread sheet to a csv file using "|" as the delimiter instead of ","? You can (temporarily) change the separator by changing the windows list separator under control panel regional settings (number tab) to that | character. Or you could write your own macro to extract the data in whatever form you want: Some sample code to get you started: Earl Kiosterud's Text Write program: www.smokeylake.com/excel (or directly: http://www.smokeylake.com/excel/text_write_program.htm) Chip Pearson's: http://www.cpearson.com/excel/imp...

Using the Search for newsgroups
I'm trying to use the newsgroups search to research my GP problem, but there doesn't seem any way to search on a phrase and not the individual words in a phrase. For example, when I type UNIT ACCOUNTS I get a ton of hits for ACCOUNTS. I only want to find places with an exact match to UNIT ACCOUNTS. Anyone know how to do this? Robert, type your phrase inside quotes (e.g., "unit accounts") Elisabeth "Robert" wrote: > I'm trying to use the newsgroups search to research my GP > problem, but there doesn't seem any way to search on a > phra...

How to use the conditions?
I need help with this if anyone can help me with this: A1=$1500 B1=$1500 I want to create a logic that if B1 is greater or equal to A1 then YES and if B1 is less than A1 then NO. And if the cells A1 or B1 is blank then the result cell should also appear blank and should not show #Value? or other values in the conditioned cell. What should I should to get this conditioned in one cell? Thanks Liz This formula should work: =IF(OR(A1="",B1=""), "", IF(B1 >= A1, "YES", "NO")) If A1 or B1 is blank, return a blank, otherwise if B1 is gre...

using word for email it wont send graphics
if i use word to send emails it will only send text it wont send graphics or speech balloons or if i put photos on it it wont send them why? "stephen talbot" <stephen talbot@discussions.microsoft.com> wrote in message news:B8CEAC7D-86CC-4B54-9F0B-003628A04D83@microsoft.com... > if i use word to send emails it will only send text it wont send graphics > or > speech balloons or if i put photos on it it wont send them why? Hi - When you post in here, always include your version, SP level, and mode (if applicable) of Outlook - you can find this information in Help ...

when i use stream writer to write to a shared folder, and the network card of that remote computer is disabled
when i use stream writer to write to a shared folder, and the network card of that remote computer is disabled in the middle of the write then reenabled later. every time i try to write to that same path on the network drive it says "The process cannot access the file "\\foo\bar.txt" because it is being used by another process. its not until i restart my exe that it can access it. I tried catching the error and closing the file when the network card on the remote machine is disconnected but it fails to close the connection and gets stuck in this bad state even when the network c...

Money 2004: Got an error attempting to use ePay
I recently purchased MS Money 2004 Deluxe. I decided to use the MSN Bill Pay (I have never used it before). Tonight I sat down to pay a couple of utility bills. When I did each generated the following error message: "Your payment was not processed for the following reason: An Internet communication error occurred. Please try your call again later. (OFXIE12029)" What does this mean? And what about the bills I attempted to pay? Are they paid, or not? And if not, then how do I get them resubmitted to be paid? Rod ...