![]()  | 
 
CXTPPopupControl use into Thread | 
 
    Post Reply  
   | 
  
| Author | |
   
   vishal  
   
   Groupie  
   Joined: 22 August 2013 Status: Offline Points: 14  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Topic: CXTPPopupControl use into ThreadPosted: 31 August 2016 at 5:46am  | 
 
| 
   
    
   Hi, 
   
  I'm using CXTPPopupControl popup control into CDialog application. It is work fine when show popup from CDialog button event. But when i'm using same logic for show popup into Thread then it is not work. Below code i'm using into Thread, DWORD WINAPI RunThread(LPVOID *arg) { 	CPopupControlDemoDlg* pDlg = (CPopupControlDemoDlg*)arg; 	while(1) 	{ 		// pDlg->OnButtonShow(); 		// Sleep(5000); 		// continue; 		CXTPPopupControl* pPopup = new CXTPPopupControl(); 		pPopup->SetTransparency(255); 		pPopup->AllowMove(TRUE); 		pPopup->SetAnimateDelay(0); 		pPopup->SetPopupAnimation((XTPPopupAnimation)0); 		pPopup->SetShowDelay(0); 		pDlg->SetTheme(pPopup); 		pPopup->SetPopupSize(pDlg->m_sizePopup); 		pDlg->FindBestPosition(pPopup, pDlg->m_sizePopup); 		// pPopup->m_hWnd = pDlg->m_hWnd; 		// SetWindowPos(pPopup->m_hWnd, NULL, 0, 0, 500, 500, SW_SHOW); 		pPopup->SetOwner(pDlg); 		//pPopup->SetParent(pDlg); 		// pPopup->ShowModal(pDlg); 		pPopup->Show(NULL); 		pPopup->SetTheme(xtpPopupThemeOffice2003); 		pPopup->RedrawControl(); 		// ShowWindow(pPopup->m_hWnd, SW_SHOW); 		pDlg->m_lstPopupControl.AddTail(pPopup); 		Sleep(5000); 	} 	return 0; } Please help me to solve this problem. Thanks 
    | 
 |
| 
   
     
     Ahir Vishal D.
     
   
   | 
 |
![]()  | 
 |
   
   cluster  
   
   Groupie  
   Joined: 22 January 2015 Status: Offline Points: 91  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 31 August 2016 at 9:06am | 
 
| 
   
    
   Hi Ahir, 
   
  MFC is not thread-safe! https://msdn.microsoft.com/en-us/library/h14y172e.aspx  | 
 |
![]()  | 
 |
   
   vishal  
   
   Groupie  
   Joined: 22 August 2013 Status: Offline Points: 14  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 31 August 2016 at 10:21am | 
 
| 
   
    
   Hi, 
   
  Thank you for your replay. You right MFC is not thread safe. But what i need to do i have some logic in thread which is return true false value. If my logic return false then I need to show popup with some message and if its return true then i need to close opened popup. And this all are in one thread so can you please help me to solve this problem? Thanks  | 
 |
| 
   
     
     Ahir Vishal D.
     
   
   | 
 |
![]()  | 
 |
   
   cluster  
   
   Groupie  
   Joined: 22 January 2015 Status: Offline Points: 91  | 
  
   
      Post Options
    
        Thanks(1)
      Quote   Reply
   
     Posted: 31 August 2016 at 10:35am | 
 
| 
   
    
   I think you should use for this interaction PostMessage/PostThreadMessage. If your logic-thread is done you will fire a PostMessage to the main-thread. In your main-thread you have to catch the "WM_USER" message and show the result... 
   
   | 
 |
![]()  | 
 |
   
   vishal  
   
   Groupie  
   Joined: 22 August 2013 Status: Offline Points: 14  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 01 September 2016 at 5:35am | 
 
| 
   
    
   Hi, 
   
  Thank you for our solution I think from your solution I can solve my problem. Thanks, 
   ![]() ![]()  | 
 |
| 
   
     
     Ahir Vishal D.
     
   
   | 
 |
![]()  | 
 |
    Post Reply  
   | 
  |
|       
  
  Tweet   	
    | 
 
| Forum Jump | Forum Permissions  ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum  |