Solved

SetTimer issues...

Posted on 2006-06-14
6
559 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
Comment Utility
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
Comment Utility
Please don't think less of me, but how exactly do you do that? :)

Thanks!
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
What?
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:demilune
Comment Utility
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
Comment Utility
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
Comment Utility
THANKS!!!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now