?
Solved

SetTimer issues...

Posted on 2006-06-14
6
Medium Priority
?
576 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

 

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

764 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