Link to home
Start Free TrialLog in
Avatar of Mlungisi Ndlela
Mlungisi NdlelaFlag for South Africa

asked on

How to update a label control outside the h file in vc++

Hi guys.

I have Form1.h and Test.cpp files in my project which was generated by VS. I have around 5 functions in my Test.cpp file and each function has to update the label with its result. I've made the label1 public on my Form1.h file and with this solution I am now able to write to the label1 outside the h file, I mean I can write to the label1 from .cpp file but only when the application is starting up or should I say only from the main function. I've used the solution provided on this post here and now my problem is that I can not use the same approach on other 5 to 6 functions as this approach also uses the
Application::Run(form);

Open in new window

which I don't think is appropriate to keep calling this from each and every function that needs to update the label.

The updates are based on the App returned results for each and every function its execute.
SOLUTION
Avatar of sarabande
sarabande
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mlungisi Ndlela

ASKER

Hi Sara, Thanks for your comment. I think I should have said that I'm not a C++ developer but I'm a VB.NET developer and what you just said above doesn't ring a bell to me. I'm using Visual C++ 2010 and I chose the CRL template and added a new item which is a Form1 to the project.
if you right-click on a control of the Form1 you can choose  'properties' and you'll get a window with mini-buttons at top. one of these buttons shows a flash symbol. if you click on it you can define an event handler for some event (for example 'button click' or 'scroll'). the class wizard will create an function for this. you may search for sample code at the web for each event type. the handler function was called every time the event was fired. for example if you click at the 'ok' button of your form, the handler function could read the data from screen and store it to an XML or a database.

Sara
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I managed to find the answer and the answer or solution is that don't write codes on the file I was writing them on, instead create functions within the .h file of that particular form so that you will be able to access form controls even if they are private.