VC++ Windows forms beginner question

G

Guest

managed C++
VS 2003

I have a beginner question about windows forms....
I need to call a function when a certain limit has been reached, now with
the way VS sets up the .NET windows Form I get confused. When I was using
Directx everything was being run from a while loop, so that was no problem
for me in seeing where to place conditional statements and other functions.

With windows forms do I need to have an event and eventhandler? it just
confuses me because of the form.h and form.cpp and pretty much all there is
in the .cpp is Application::Run(....).

Also can you give me advice on any good books for C++ .Net and WIndows. I
have Mircosoft Visual C++ .NET (step by step) by Templeman and Olsen but they
really don't give that much info on Windows forms and such.
 
C

Carl Daniel [VC++ MVP]

Neal said:
managed C++
VS 2003

I have a beginner question about windows forms....
I need to call a function when a certain limit has been reached, now with
the way VS sets up the .NET windows Form I get confused. When I was using
Directx everything was being run from a while loop, so that was no problem
for me in seeing where to place conditional statements and other
functions.

With windows forms do I need to have an event and eventhandler? it just
confuses me because of the form.h and form.cpp and pretty much all there
is
in the .cpp is Application::Run(....).

Also can you give me advice on any good books for C++ .Net and WIndows. I
have Mircosoft Visual C++ .NET (step by step) by Templeman and Olsen but
they
really don't give that much info on Windows forms and such.

"Windows Forms Programming in C#" by Chris Sells is a good book. You'll
have to translate from C# to C++, but that's not too hard.

Generally, just about everything that you write in a forms application is
(directly or indirectly) invoked as part of an event handler.

When you say "when a certain limit has been reached", what kind of a limit
are you talking about? Time? Mouse clicks? Value entered into a text
box? If it's time that you're interested in, look at the
Sytem.Windows.Forms.Timer class - drop a timer on your form, set it's period
to the time delay you want, and handle the Tick event.

-cd
 
G

Guest

Thanks for the book suggestions.
And yes I meant to say time limit, I will check into the Timer Class. Thank
You.
 
A

Abhijeet Dev

First to clarify, even in .Net Windows Forms everything runs in a while
loop. When you say Application::Run(...), it actually starts a while
loop, waiting for messages on the process main thread which can be
handled by adding a message filter :-
Application::AddMessageFilter(...)
which must be done before Application::Run(...) as this 'Run' method
starts an infinite while loop.
Now, this part was common between your directx application and the
windows forms application. Now you have another thing, there is another
filter working in background, all the windows message is forwarded to
the form's onWindowProc method, which can be overridden.

Even the timer's WM_TIMER event goes thru all this :)

Remember, Timer you can not rely upon ... as if you have other window
message handler running for a longer time, timer event will not come on
time.

Tell us what you need to do exactly and I hope we can help you with that...
 

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

Top