?
Solved

SetTimer issues...

Posted on 2006-06-14
6
Medium Priority
?
580 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 2000 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
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 

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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

755 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