Print Page | Close Window

CXTPPopupControl use into Thread

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=23110
Printed Date: 23 December 2024 at 9:33pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPPopupControl use into Thread
Posted By: vishal
Subject: CXTPPopupControl use into Thread
Date Posted: 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.



Replies:
Posted By: cluster
Date Posted: 31 August 2016 at 9:06am
Hi Ahir,

MFC is not thread-safe!

https://msdn.microsoft.com/en-us/library/h14y172e.aspx




Posted By: vishal
Date 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.


Posted By: cluster
Date 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...



Posted By: vishal
Date Posted: 01 September 2016 at 5:35am
Hi,

Thank you for our solution I think from your solution I can solve my problem.

Thanks,StarStar


-------------
Ahir Vishal D.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net