Add controls to a drop-down menu
Hello everyone,
I need to add a slider (trackbar) to a menu, and use-it to select one of the options (something like Change View button in Win7's Explorer - helps to select Tile, Details, List, Small Icons ..... Large Icons). It;s there way to do this ?
1 Attachment(s)
Re: Add controls to a drop-down menu
Re: Add controls to a drop-down menu
I'm pretty sure that's not a standard menu.
I think they are just creating a custom window and make it look and behave like a menu.
And since it's a custom window, you can add any controls to it as you wish.
Re: Add controls to a drop-down menu
i was thinking the same thing. if you look careful the selection rect has a different color than the standard menu items, but i wanted to check that i'm on the right track.
one more question: anyone has idea how to make an slider like that ? that snaps only to some of the values ? my idea is to handle the WM_MOUSEMOVE or WM_VSCROLL and TB_THUMBTRACK, but i don't know which is the right approach. It;s there a way to be notified before the slider is moved ?
thanks in advance
Re: Add controls to a drop-down menu
You are trying it way too complicated ;)
Simply use SetRange(0, 5) for example which will give you 6 ticks and the slider will jump between those 6 ticks.
Re: Add controls to a drop-down menu
this is the default behavior. what i need is to jump between ticks 1-3 and move smooth between ticks 3-6.
Re: Add controls to a drop-down menu
Ah, ok.
Then something like this.
Initialize your slider with:
Code:
m_slider.SetRange(0,10);
m_slider.SetTic(5);
m_slider.SetTic(6);
m_slider.SetTic(7);
m_slider.SetTic(8);
m_slider.SetTic(9);
Then handle TRBN_THUMBPOSCHANGING as follows:
Code:
void CslidertestDlg::OnThumbposchangingSlider1(NMHDR *pNMHDR, LRESULT *pResult)
{
// This feature requires Windows Vista or greater.
// The symbol _WIN32_WINNT must be >= 0x0600.
NMTRBTHUMBPOSCHANGING *pNMTPC = reinterpret_cast<NMTRBTHUMBPOSCHANGING *>(pNMHDR);
if (pNMTPC->dwPos >= 0 && pNMTPC->dwPos <= 2)
{
m_slider.SetPos(0);
*pResult = 1;
}
else if (pNMTPC->dwPos > 2 && pNMTPC->dwPos <= 5)
{
m_slider.SetPos(5);
*pResult = 1;
}
else
*pResult = 0;
}