+ Reply to Thread
Results 1 to 2 of 2

Thread: How to send a message to application Main window using secondary thread?

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    24

    How to send a message to application Main window using secondary thread?

    I am having following thread:

    Code:
    UINT BackgroungThread(LPVOID lpParam)
    {
            //Send or Post message to Main window. How?
    	return 0 ;
    }
    
    
    void CThreadDlg::OnInitDialog()
    {
    	CDialog::OnInitDialog();
            
            AfxBeginThread((AFX_THREADPROC) BackgroungThread, NULL) ;
    }
    I want to send a message to CThreadDlg object from BackgroungThread function.

    How to send a message to application Main window using secondary thread?

    Help.

  2. #2
    There are different ways as following:

    a. You can pass a window handle as an argument to thread function. Once you have window handle you can send or post message (SendMessage/PostMessage) to it.
    b. You can get the Main thread ID by some means (via argument) and then you can use PostThreadMessage WIN32 API.


+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts