.NET Event Handling (timers, Mouse movement)

T

TogaKangaroo

Hi, I'm trying to get intimate with my new copy of the .NET Pro
developing environment, specifically C++ Visual Studio. I have a book
(VC++ in 21 days) that I am going through following their examples.
However the book treats the MS VC++ 6.0 environment and I...as I
mentioned am learning .NET.

It hasn't been too large a problem so far, I'm have a comp sci degree
and have done plenty of c++ so where the two don't match up I've been
mostly able to figure it out. However I am having problems figuring
out how to make an event handler for timers or mouse actions.

I think It all spawns from the same problem so if I can figure out
timers I can probably handle the rest. So far I have done the
following:
-Added a resource symbol ID_CLOCK_TIMER (am I correct that this simply
adds a #define ID_CLOCK_TIMER line to resource.h?)
-did SetTimer(ID_CLOCK_TIMER, 1000,NULL); in OnInitDialog()

Now the book states I can click on my main dialog box(main window) and
do add event handler to handle the WM_TIMER message. .NET won't let me
add an event handler to the main message box however and for no place
where I CAN add an event handler do I see the WM_TIMER message as an
option in the wizard. I tried adding a handler manually (from what I
understood should be done)
and added
public:
afx_msg void OnTimer(UINT_PTR nIDEvent);
to my main dialog class (it is derived from CDialog)
as well as a definition
void CTimeyDlg::OnTimer(UINT_PTR nIDEvent) {
MessageBox("Yo");
}
Nothing happens however.

Can anyone help me out here?
Thanks a lot
Toga
 
I

Ioannis Vranos

TogaKangaroo said:
Hi, I'm trying to get intimate with my new copy of the .NET Pro
developing environment, specifically C++ Visual Studio. I have a book
(VC++ in 21 days) that I am going through following their examples.
However the book treats the MS VC++ 6.0 environment and I...as I
mentioned am learning .NET.

It hasn't been too large a problem so far, I'm have a comp sci degree
and have done plenty of c++ so where the two don't match up I've been
mostly able to figure it out. However I am having problems figuring
out how to make an event handler for timers or mouse actions.

I think It all spawns from the same problem so if I can figure out
timers I can probably handle the rest. So far I have done the
following:
-Added a resource symbol ID_CLOCK_TIMER (am I correct that this simply
adds a #define ID_CLOCK_TIMER line to resource.h?)
-did SetTimer(ID_CLOCK_TIMER, 1000,NULL); in OnInitDialog()

Now the book states I can click on my main dialog box(main window) and
do add event handler to handle the WM_TIMER message. .NET won't let me
add an event handler to the main message box however and for no place
where I CAN add an event handler do I see the WM_TIMER message as an
option in the wizard. I tried adding a handler manually (from what I
understood should be done)
and added
public:
afx_msg void OnTimer(UINT_PTR nIDEvent);
to my main dialog class (it is derived from CDialog)
as well as a definition
void CTimeyDlg::OnTimer(UINT_PTR nIDEvent) {
MessageBox("Yo");
}
Nothing happens however.

Can anyone help me out here?


At first you have to know that programming with C++ in a platform
involves two things. Knowledge of the C++ language itself as it is
defined by ISO C++ standard, and knowledge of the specific platform
extensions (its GUI library etc).


You can get up and running regarding ISO C++ by reading "Accelerated
C++" by Andrew Koening, Barbara Moo:

http://www.acceleratedcpp.com


About Windows, the best thing you have to do is learn .NET facilities
and not the older ones (MFC, Win32, etc). Since you have VC++ .NET, a
good book for VC++ 2003 .NET which will help you to learn how to use
..NET with C++ is


"Visual C++ .NET How To Program" by Deitel.

http://vig.prenhall.com/catalog/academic/product/0,1144,0134373774,00.html


It is very good, it covers even multithreading.


However if you can wait, I suggest you wait for VC++ 2005 and the new
C++/CLI standard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top