![]() |
Pop-up menu not disappear in thread |
Post Reply
|
| Author | |
hijerry
Newbie
Joined: 12 February 2007 Status: Offline Points: 5 |
Post Options
Thanks(0)
Quote Reply
Topic: Pop-up menu not disappear in threadPosted: 12 February 2007 at 12:10am |
|
If the view is created in main thread, the pop-up menu works.
But if the view is created in a CWinThread, the pop-up menu do not disappear when I switch to another widow.
Here is the codes: I create a pop-up menu in a MFC CView class:
void CXXXView::OnContextMenu(CWnd* /*pWnd*/, CPoint point){ // TODO: Add your message handler code hereCMenu MainMenu; MainMenu.LoadMenu(IDR_MAINFRAME ); CMenu* pCTRMKMenu= NULL; CXTPPopupBar* pPopupBar = CXTPPopupBar::CreatePopupBar(0); pCTRMKMenu = MainMenu.GetSubMenu(0); pPopupBar->LoadMenu(pCTRMKMenu); CXTPCommandBars::TrackPopupMenu(pPopupBar,TPM_RIGHTBUTTON|TPM_NONOTIFY,point.x, point.y, this);pPopupBar->InternalRelease(); pPopupBar = NULL; } |
|
![]() |
|
akur
Senior Member
Joined: 16 May 2006 Status: Offline Points: 139 |
Post Options
Thanks(0)
Quote Reply
Posted: 12 February 2007 at 1:58am |
|
Hello,
generally it's a good idea to make all the GUI activity from the GUI thread of your application (your "main" thread). I've run into different, more difficult problems in the past when I tried not to do so. Limiting GUI interaction to the GUI thread will save you many troubles. |
|
![]() |
|
hijerry
Newbie
Joined: 12 February 2007 Status: Offline Points: 5 |
Post Options
Thanks(0)
Quote Reply
Posted: 12 February 2007 at 2:23am |
|
Thanks for your suggestion. Anyway, is there someone that met the same problem? Or is there any solution to make the menu disappear?
|
|
![]() |
|
lbvlad
Newbie
Joined: 10 November 2006 Location: United States Status: Offline Points: 2 |
Post Options
Thanks(0)
Quote Reply
Posted: 12 February 2007 at 2:32pm |
|
Hello,
you need to call //ensure any popup menus are destroyed XTPMouseManager()->SendTrackLost(); from the same thread where you have popped up the menu. for example, when user clicks on another window, send a special message to your CXXXView and execute code above. It will break tracking loop inside a TrackMenuPopup. |
|
![]() |
|
hijerry
Newbie
Joined: 12 February 2007 Status: Offline Points: 5 |
Post Options
Thanks(0)
Quote Reply
Posted: 12 February 2007 at 8:27pm |
|
Thanks. It does work now. The menu in the CWinThread will disappear if I switch to the view of main thread. But there is still a problem. When I switch the window from the view in main thread to the view in CWinThread, the menu of view in the main thread would not disappear. |
|
![]() |
|
lbvlad
Newbie
Joined: 10 November 2006 Location: United States Status: Offline Points: 2 |
Post Options
Thanks(0)
Quote Reply
Posted: 12 February 2007 at 8:32pm |
|
This is exactly the same problem.
Just when you switch from main thread to another thread and in main thread menu is open, you need to call SendTrackLost (but this time in the context of the main thread) |
|
![]() |
|
hijerry
Newbie
Joined: 12 February 2007 Status: Offline Points: 5 |
Post Options
Thanks(0)
Quote Reply
Posted: 12 February 2007 at 9:15pm |
|
Now //ensure any popup menus are destroyed
XTPMouseManager()->SendTrackLost(); works both in main thread and CWinThread.
Thanks again :)
|
|
![]() |
|
hijerry
Newbie
Joined: 12 February 2007 Status: Offline Points: 5 |
Post Options
Thanks(0)
Quote Reply
Posted: 20 March 2007 at 10:04pm |
|
For the huge frame of the program, it's hard to call functions such as SendTrackLost to make the menu disappear. Is there a way to let the menu disappear automatically?
|
|
![]() |
|
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 |