Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26755 Discussions

Sending messages to the main window from a subroutine

steven_j_
Beginner
93 Views

I am writing a windows application where the main window has an edit box as a child control. This edit box has the handle hMsg. In response to a user clicking on a menu item, the MainWndProc function calls a subroutine. This subroutine performs a number of tasks, each requiring significant cpu time (on the order of 30 seconds). I want the subroutine to write text into the edit box of the main window, stating which task it is currently working on so that the user can follow the progress in real time.

In my first attempt to accomplish this, I passed the subroutine the handle hMsg to the edit box. In the subroutine, before starting a task, I set a character variable msg to the desired message and then call SetWindowText(hMsg, msg). Apparently, this only puts the requested change to the edit box into the message queue; the new text is not displayed until after the subroutine terminates a few minutes after it is called. Thus, the user cannot follow the real-time progress of the subroutine. Is there a way to have the edit box in the main window updated by the subroutine as the subroutine performs each of its several tasks?

Thanks,

Steve J

0 Kudos
1 Reply
Zlamal__Jakub
New Contributor III
93 Views

You should start your subroutine in separate thread. Then will be main thread of your application able to response to messages.

At the end of execution of your subroutine you send message to your application that it's work is finished.

Reply