Solved

SetTimer issues...

Posted on 2006-06-14
6
562 Views
Last Modified: 2008-01-09
Morning all...

I'm trying to solve the last part in my program here and am stuck once again.

I'm trying to utilize the SetTimer function and process the "callback" with the WndPrc message handler. No matter what I've tried, I can't find the right combination to avoid compiler errors.

Here is how I'm calling the SetTimer...

                                   protected: virtual void WndProc(Message% m) override
               {
                     if (m.Msg == WM_CREATE)
                     {
                           tid = SetTimer(NULL, 1, 50000, (TIMERPROC)NULL);
                     }
                     if (m.Msg == WM_TIMER)
                     {
                                    ...

I understand that I probably need a handle in the call of SetTimer, but I read somwhere that if it is in WndPrc it does not need it. Doesn't make sense to me, but ...

Here are the compiler errors...

Omni Monitor.obj : error LNK2028: unresolved token (0A00001A) "extern "C" unsigned int __stdcall SetTimer(struct HWND__ *,unsigned int,unsigned int,void (__stdcall*)(struct HWND__ *,unsigned int,unsigned int,unsigned long))" (?SetTimer@@$$J216YGIPAUHWND__@@IIP6GX0IIK@Z@Z) referenced in function "protected: virtual void __clrcall OmniMonitor::Form1::WndProc(class System::Windows::Forms::Message %)" (?WndProc@Form1@OmniMonitor@@$$FM$AAMXA$CAVMessage@Forms@Windows@System@@@Z)

Omni Monitor.obj : error LNK2019: unresolved external symbol "extern "C" unsigned int __stdcall SetTimer(struct HWND__ *,unsigned int,unsigned int,void (__stdcall*)(struct HWND__ *,unsigned int,unsigned int,unsigned long))" (?SetTimer@@$$J216YGIPAUHWND__@@IIP6GX0IIK@Z@Z) referenced in function "protected: virtual void __clrcall OmniMonitor::Form1::WndProc(class System::Windows::Forms::Message %)" (?WndProc@Form1@OmniMonitor@@$$FM$AAMXA$CAVMessage@Forms@Windows@System@@@Z)

Those errors are referencing my SetTimer call.

What I'm needing is help with the actual call here... If I need the handle, how do I call it? My knowledge on handles is limited, but everything I know, I've tried.

This is an urgent problem for me too, so source code help would be appreciated, not just links to definitions. Oh, I'm using VC++ 2005 Express Edition!
0
Comment
Question by:demilune
  • 3
  • 3
6 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 16900742
To solve linker problem add User32.lib to the list of Linker dependencies.
SetTimer call should be:

tid = SetTimer((HWND)this->Handle.ToPointer(), 1, 50000, (TIMERPROC)NULL);

BYW, you can use .NET Timer control. Maybe it is not available in the Express Edition, in this case use SetTimer.

0
 

Author Comment

by:demilune
ID: 16907533
Please don't think less of me, but how exactly do you do that? :)

Thanks!
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16908903
What?
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:demilune
ID: 16908934
My bad...

How do you add the User32.lib to the list of Linker dependencies. I looked in the project option and found the section "linker" but saw no place to add the path to the library.

I must be really tired right now, as I have a feeling this is really simple.

Thanks!
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16909144
Project - Properties - Configuration Properties - Linker - Input - Additional Dependencies. Type User32.lib.

This is from Professional Edition, in Express Edition it can be different.
0
 

Author Comment

by:demilune
ID: 16909164
THANKS!!!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question