Discussion Locked

Accessing GUI from thread

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Problem: I have a windows application created with Microsoft VC++ that is implemented as a Dialog window. The application has buttons to press for different actions f.ex. an "Exit" button to be used when the application shall be closed down. The application even has a Thread that runs as background worker. The thread listens for commands from a serial port.

What i want is some way for the Thread to call
the dialog (handle to the window ??) when the "exit" command is received from the serialport.

I have tried to use the SendMessage() from the Thread but without success. Is it the right solution but implemented wrong by me or does anyone have a better solution.

/With hope of help
Bj?rn

3 replies

by lusu

The application should answer to PostQuitMessage function with a normal shutdown. If it doesn't, it means that you do not handle such message in purpose (a close confirmation for example). If the dialog window is modal, it must be closed first. Try to call the close button from the dialog window directly (via direct VCL access) if PostQuitMessage fails.

This discussion is closed to new replies.