Link to home
Start Free TrialLog in
Avatar of oliverbowen
oliverbowen

asked on

Accessing a Progress bar in View class from thread in mainframe class

I have a Progress Bar control inside my view class for an MFC SDI application.

I created a thread and set the message handlers and thread functions in the MainFrame class.

When I attempt to compile I get an error saying my progress bar variable/control cannot be found where I try to update it in the thread function defined/implemented in the mainframe class.

How do I get access to that control?
Avatar of pgnatyuk
pgnatyuk
Flag of Israel image

Can you post the error message from the compiler?
Without it I can only guess that you forgot to add an appropriate #include in the cpp-file where you use the bar.
ASKER CERTIFIED SOLUTION
Avatar of alb66
alb66
Flag of Italy 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
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
Avatar of oliverbowen
oliverbowen

ASKER

Ok I got it figured out.

I moved the message handlers and custom messages into the view class, which is where the progress bar control is.

Now in my thread as I'm doing my processing I post a message to the update message handler and it works great.

I pass the counter to the message handler through the lparam of the sendmessage function and that way I'm able to increment the cprogressbar.

Thank you!