Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I maintain control of my form?

This is a bit "wordy", but here is the scoop. I'm using Microsoft Visual
Studio for VC++ in Windows 2000.

I made an application which had no form in it. So when I ran the
application, I just got a DOS box that showed some progress info. I then
decided to add a form... So I made a new application and started with
creating the form. Then I copied and pasted cpp code into places where I
thought they should go - leaving out the stuff that would print to the DOS
box. Pfff.....

The program works, but as soon as it gets into the meat of the real
application, I lose control of the form and can't change things.

Now... it is very likely that this may be due to the fact that the real
application is running all over the place and doesn't have time to bother
with the form - but I really think I should be able to get back to the form
so I can change things on the fly.

I should let you know that I'm using an SDK. I've noticed that the form
creates an area in the .cpp with event handlers - but my application uses
event handlers involved with the SDK. These event handlers are not active
until I hit the "Connect" button - and that is when I lose control.

I'll try to be a little more exact. I'm using the 3d chat - Active Worlds
SDK. The form takes information from two ini files and loads it. I hit the
connect button, it connects and the application runs fine - but I have lost
my form control at that point. Funny thing... before I hit connect - I
can't close or minimize the form yet I have control of the edit boxes in the
form and can load and save to ini files - but after I hit connect, the
minimize and close functions work, yet I can't get to the edit boxes. I
think the basic code is good - I just got some stuff out of place or I'm
missing a message somewhere along the way.

Got any clues?

Maybe I should have the real application separate
from the form? As it is right now, the real application is in the form
..cpp - the form .cpp does not call up the real application because it is
already there. I think that is my problem... but I don't know how to run
another .cpp from the form. I hope I am making sense here... Should I
study up a bit more on resourcing stuff? Thinking to myself... the form
should be running in one section of memory - and the application in another.
When I change the form, the form sends a message to the application and the
application adjusts itself. As it stands right now, since the main
application is in the form, the form code is ignored once the connect button
is hit. If I am correct, or if you have other suggestions, please give me a
hand here.

P2


0 Kudos
Message 1 of 2
(3,466 Views)
P2,

Are you developing an MFC application or a standard Win32 project?  For an MFC application, the project should automatically be set up to handle messages which would respond to your UI interactions.  For a Win32 application, you must ensure that you have a message dispatch loop.  The following link has a good description of the Message Loop:

http://www.winprog.org/tutorial/message_loop.html

It may be that you are performing some operation that takes a very long time so the Message Loop handling (either in the MFC or Win32 app) is not being called often enough.  In that case, you must see if it is possible to break up your operations so that the Mesasge Loop is still handled.  A good way to take care of this is to fork a separate thread for the heavy operations to take place in.

If this is not related to the use of Measurement Studio controls, you may get a better or more detailed answer if you post this question on a generic Windows programming forum.

Thanks,

Tyler Tigue
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(3,451 Views)