Add controls to a drop-down menu
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Add controls to a drop-down menu

  1. #1
    Join Date
    Jan 2011
    Posts
    5

    Lightbulb 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 ?

  2. #2
    Join Date
    Jan 2011
    Posts
    5

    Smile Re: Add controls to a drop-down menu

    Something like this
    Attached Images Attached Images  

  3. #3
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,062

    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.

  4. #4
    Join Date
    Jan 2011
    Posts
    5

    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

  5. #5
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,062

    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.

  6. #6
    Join Date
    Jan 2011
    Posts
    5

    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.

  7. #7
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,062

    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;
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center