Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - CXTPPopupControl use into Thread
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPPopupControl use into Thread

 Post Reply Post Reply
Author
Message
vishal View Drop Down
Groupie
Groupie
Avatar

Joined: 22 August 2013
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote vishal Quote  Post ReplyReply Direct Link To This Post Topic: CXTPPopupControl use into Thread
    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.
Back to Top
cluster View Drop Down
Groupie
Groupie


Joined: 22 January 2015
Status: Offline
Points: 91
Post Options Post Options   Thanks (0) Thanks(0)   Quote cluster Quote  Post ReplyReply Direct Link To This Post Posted: 31 August 2016 at 9:06am
Hi Ahir,

MFC is not thread-safe!

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


Back to Top
vishal View Drop Down
Groupie
Groupie
Avatar

Joined: 22 August 2013
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote vishal Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
cluster View Drop Down
Groupie
Groupie


Joined: 22 January 2015
Status: Offline
Points: 91
Post Options Post Options   Thanks (1) Thanks(1)   Quote cluster Quote  Post ReplyReply Direct Link To This Post 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...

Back to Top
vishal View Drop Down
Groupie
Groupie
Avatar

Joined: 22 August 2013
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote vishal Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.