Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modify UI elements from separate thread

Status
Not open for further replies.

mapage

Programmer
Aug 29, 2007
1
US
I have a function callback from a C++ DLL which is being used in a VBA macro. The callback works fine when I just echo the parameters to the function to the screen using the MsgBox function. It fails, however, when I try to use the callback function to update the textboxes on the main userform. From research, I've determined that this is because a background thread cannot up date the UI thread. Even though the callback function is in the Forms procedures, it is still run in it's own thread. (I don't think this can be changed.)

I've tried creating a second function in the form that is called when the callback function fires as well as moving that function to a separate module and neither method works. (By works I mean that the program doesn't crash.)

How do I modify the UI elements from a function that is running in another thread?

I read up on the Invoke command, but it doesn't appear to be available for this version of VBA.

My program isn't otherwise multithreaded, and I don't want to add the complexity if I don't have to. (I have to pass this project to a client of unknown programming knowledge or abilities...)

Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top