Click here to Skip to main content
15,906,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Developers,

I have one ComboBox in MFC. I created one PopUp menu and attached with ComboBox.
When I click on ComboBox, I see popup menu getting displayed successfully.

So far so good.

My requirement is when I mouse Hover on ComboBox, I should see PopUp menu getting displayed.

How can I implement Mouse Hover on ComboBox.


Below is the code which I have written for CBN_DROPDOWN event which gets fire when I click on ComboBox. I need to do the same for Mouse Hover. Can anybody tell me which event I need to implement.

C#
void CControlContextDlg::OnCbnDropdownCombo1()
{
	
	
	CMenu mnuPopupSubmit;
	mnuPopupSubmit.LoadMenu(IDR_SUBMIT);

	// Get a pointer to the button
	//CButton *pButton;
	CComboBox *pComboBox;
	pComboBox = reinterpret_cast<CComboBox *>(GetDlgItem(IDC_COMBO1));

	// Find the rectangle around the button
	CRect rectSubmitButton;
	pComboBox->GetWindowRect(&rectSubmitButton);
	
	CPoint pbottom = rectSubmitButton.BottomRight();
	
	int h = rectSubmitButton.Width();
	
	CPoint p;
	p.x = pbottom.x - h;
	p.y = pbottom.y;


	// Get a pointer to the first item of the menu
	CMenu *mnuPopupMenu = mnuPopupSubmit.GetSubMenu(0);
	ASSERT(mnuPopupMenu);
	// Find out if the user right-clicked the button
	// because we are interested only in the button
	CPoint point;
	
		
	mnuPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, p.x, p.y, this);

	
}



Regards,
Joy

What I have tried:

I have not tried anything as I am not aware of the event which will be used for mouse Hover.
Posted

1 solution

There is a notification message: WM_MOUSEHOVER message (Windows)[^].

Examples on detecting mouse activities on controls can be found in the article Adding mouse functionality to any control[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900