Solved

SetTimer issues...

Posted on 2006-06-14
6
566 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
Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

 

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 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