BCGSoft Forums
BCGSoft Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 BCGControlBar Pro for MFC Forums
 BCGControlBar Professional Edition
 CBCGPOutlookBarPane Context Menu
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Hazelnut

54 Posts

Posted - 06/11/2022 :  6:35:18 PM  Show Profile  Reply with Quote
Hello Support,

I have a need for a context menu on the Outlook shortcuts window in my application. The options on the menu will change depending on the focused button when the user right clicks on it. I have added OnToolbarContextMenu and OnContextMenu handlers to the derived CBCGPOutlookBarPane which seem to work. However, at this point, I can't figure out if it is possible to find the ID or index of the button that has the focus - is that possible?

If not possible, can you suggest a similar method to the Outlook control that would allow me to do such things?

Thank You!

Support

4175 Posts

Posted - 06/12/2022 :  3:51:21 PM  Show Profile  Visit Support's Homepage  Reply with Quote
Hi,

Please take a look at BCGPOutlookDemo example: WPARAM of OnToolbarContextMenu message handler is the active page (CBCGPOutlookBarPane*) HWND and LPARAM is a clicked point in screen coordinates

So, you may easily obtain the clicked button index using CBCGPOutlookBarPane::HitTest method

Best regards,


BCGSoft Technical Support
Go to Top of Page

Hazelnut

54 Posts

Posted - 06/12/2022 :  9:18:56 PM  Show Profile  Reply with Quote
Hello, Thank you for the advice - I tried it. There seems to be some problem with HitTest.

I added the following to handler to display the HitTest return:


LRESULT CMainFrame::OnToolbarContextMenu(WPARAM wp,LPARAM lp)
{
	CPoint point (BCG_GET_X_LPARAM(lp), BCG_GET_Y_LPARAM(lp));

	m_pCurrOutlookPage = DYNAMIC_DOWNCAST (	CBCGPOutlookBarPane, 
							CWnd::FromHandlePermanent ((HWND) wp));

	if (m_pCurrOutlookPage == NULL)
	{
		m_uiHilightedPage = (UINT)-1;
		return 1l;	// Default menu
	}


	{
//////////////////////////////////////////////////////////////////////
		int nRet = m_pCurrOutlookPage->HitTest(point);
		CString str;
		str.Format(_T("Hit %d"), nRet);
		AfxMessageBox(str);
//////////////////////////////////////////////////////////////////////
	}
....



In my application, there are 8 buttons in the pane. The first button returns 2, the 2nd button returns 3, the 3rd button returns 4, the 4th button returns 5 - all of the buttons seem to be offset by 1. This is consistent until reaching the 7th button and 8th buttons which both return -1.

Can you tell me if the code I have tried for the test is correct?

Thank You!

Edited by - Hazelnut on 06/12/2022 10:27:09 PM
Go to Top of Page

Support

4175 Posts

Posted - 06/13/2022 :  12:10:14 AM  Show Profile  Visit Support's Homepage  Reply with Quote
As we mentioned "LPARAM is a clicked point in screen coordinates", so you've to translate it to client coordinates.

BCGSoft Technical Support
Go to Top of Page

Hazelnut

54 Posts

Posted - 06/13/2022 :  05:37:24 AM  Show Profile  Reply with Quote
Hello, OK, yes the following corrected the output:

pTestPane->ScreenToClient(&Testpoint);


Thank You
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To:
BCGSoft Forums © Copyright (c) 1998-2022 BCGSoft Co Ltd Go To Top Of Page
Snitz Forums 2000