15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Bizzarre TreeView behavior

Deepak Saxena -- Deepak_Saxena@ccm.ch.intel.com
Wednesday, September 11, 1996

Environment: Nt3.51, Visual C++ 4.2

I have a CTreeView.  This treeview has objects.  I right click on an 
object, thus generating a WM_CONTEXTMENU message but my OnContextMenu() 
handler never gets called.  I also put in handler for ON_RBUTTONDOWN and 
ON_RBUTTONUP and they don't get called either. Now...I right 
double-click on an object...and everything works fine. I've used spy++, 
and WM_RBUTTONDOWN and WM_RBUTTONUP messages are generated properly, but 
WM_CONTEXTMENU messages are only being generated when I right-dbl-click. 
Any one have any ideas as to what might be causing this?

Thanks,
Deepak



Sumit Chawla -- schawla@csci.csc.com
Thursday, September 12, 1996

[Mini-digest: 2 responses]

Environment: NT3.51, Visual C++ 4.2
Hi Deepak,
I also show a context menu in my control using the
NM_RCLICK notification. In my case I have my own
tree control class which handles the reflected notification
I haven't tried but I guess you can trap WM_NOTIFY and to do it.

Hope this helps.


Sumit Chawla
Computer Sciences Corporation.


> Environment: Nt3.51, Visual C++ 4.2
> 
> I have a CTreeView.  This treeview has objects.  I right click on an 
> object, thus generating a WM_CONTEXTMENU message but my OnContextMenu() 
> handler never gets called.  I also put in handler for ON_RBUTTONDOWN and 
> ON_RBUTTONUP and they don't get called either. Now...I right 
> double-click on an object...and everything works fine. I've used spy++, 
> and WM_RBUTTONDOWN and WM_RBUTTONUP messages are generated properly, but 
> WM_CONTEXTMENU messages are only being generated when I right-dbl-click. 
> Any one have any ideas as to what might be causing this?
> 
> Thanks,
> Deepak


-----From: Jim Leavitt 

Deepak:
I don't know what's going on in your application. I'm doing the same =
thing in a TreeCtrl in my application.
I suppose I should have used the WM_CONTEXTMENU message, but I just used =
the WM_RBUTTONDOWN
message. I experimented with the MFCDRAG example, handling =
WM_CONTEXTMENU, WMRBUTTONDOWN and WM_RBUTTONUP. If just one of these =
messages are active, it works. If all are active, only the =
WM_CONTEXTMENU gets the message, I didn't look any further into the MFC =
Code.

Anyway, heres some code from my application, probably what you have =
already...=20
I'm using VC4.2 and NT 4.0 final.=20


void CCustomerTree::OnRButtonDown(UINT nFlags, CPoint point)=20
{
	CMenu menu;
	VERIFY(menu.LoadMenu(IDR_CUSTTREE_POPUP));  // menu resource for popup
	CMenu* pPopup =3D menu.GetSubMenu(0);
	ASSERT(pPopup !=3D NULL);

	ClientToScreen(&point);
	pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,=20
		point.x, point.y, this);

=09
	//CTree::OnRButtonDown(nFlags, point);		// I'll handle this, thank you.
}
Jim Leavitt





| Вернуться в корень Архива |