Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. Hide context menu on CScrollBar in MFC.

Hide context menu on CScrollBar in MFC.

Scheduled Pinned Locked Moved ATL / WTL / STL
c++helpquestion
5 Posts 3 Posters 12 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sampath579
    wrote on last edited by
    #1

    Hi I created a MFC application and created a horizontal scroll bar using CScrollBar calss as follows instead of default scroll bar.

    if (CScrollView::OnCreate(lpCreateStruct) == -1)
    return -1;
    // TODO: Add your specialized creation code here
    m_horzscrollbar.Create(WS_CHILD | WS_VISIBLE | SBS_HORZ | SBS_BOTTOMALIGN, CRect(0,0,100,100), this, 101);

    SCROLLINFO scrollInfo = { 0 };
    scrollInfo.fMask = SIF\_ALL;
    scrollInfo.cbSize = sizeof(SCROLLINFO);
    scrollInfo.nMin = 0;
    scrollInfo.nMax = 1000;
    scrollInfo.nPage = 10;
    scrollInfo.nPos = 10;
    scrollInfo.nTrackPos = 10;
    
    m\_horzscrollbar.SetScrollInfo(&scrollInfo);
    m\_horzscrollbar.ShowWindow(1);
    

    The above piece of code created a horizontal scroll bar. When i right click on the scroll bar, it displaying a context menu with some options like page left, page right, scroll here, scroll left and scroll left. How can i stop this default context menu in my application since this is not required for me. Any help is appreciated. Thanks.

    V J 2 Replies Last reply
    0
    • S Sampath579

      Hi I created a MFC application and created a horizontal scroll bar using CScrollBar calss as follows instead of default scroll bar.

      if (CScrollView::OnCreate(lpCreateStruct) == -1)
      return -1;
      // TODO: Add your specialized creation code here
      m_horzscrollbar.Create(WS_CHILD | WS_VISIBLE | SBS_HORZ | SBS_BOTTOMALIGN, CRect(0,0,100,100), this, 101);

      SCROLLINFO scrollInfo = { 0 };
      scrollInfo.fMask = SIF\_ALL;
      scrollInfo.cbSize = sizeof(SCROLLINFO);
      scrollInfo.nMin = 0;
      scrollInfo.nMax = 1000;
      scrollInfo.nPage = 10;
      scrollInfo.nPos = 10;
      scrollInfo.nTrackPos = 10;
      
      m\_horzscrollbar.SetScrollInfo(&scrollInfo);
      m\_horzscrollbar.ShowWindow(1);
      

      The above piece of code created a horizontal scroll bar. When i right click on the scroll bar, it displaying a context menu with some options like page left, page right, scroll here, scroll left and scroll left. How can i stop this default context menu in my application since this is not required for me. Any help is appreciated. Thanks.

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      You could find some ideas from this thread: [Scrollbar and context menu](http://forums.codeguru.com/showthread.php?490982-Scrollbar-and-context-menu)

      S 1 Reply Last reply
      0
      • V Victor Nijegorodov

        You could find some ideas from this thread: [Scrollbar and context menu](http://forums.codeguru.com/showthread.php?490982-Scrollbar-and-context-menu)

        S Offline
        S Offline
        Sampath579
        wrote on last edited by
        #3

        I have tried this but its not working. One more wired problem i face is, this context menu is not appearing in debug mode, only in release mode this menu is appeared.

        1 Reply Last reply
        0
        • S Sampath579

          Hi I created a MFC application and created a horizontal scroll bar using CScrollBar calss as follows instead of default scroll bar.

          if (CScrollView::OnCreate(lpCreateStruct) == -1)
          return -1;
          // TODO: Add your specialized creation code here
          m_horzscrollbar.Create(WS_CHILD | WS_VISIBLE | SBS_HORZ | SBS_BOTTOMALIGN, CRect(0,0,100,100), this, 101);

          SCROLLINFO scrollInfo = { 0 };
          scrollInfo.fMask = SIF\_ALL;
          scrollInfo.cbSize = sizeof(SCROLLINFO);
          scrollInfo.nMin = 0;
          scrollInfo.nMax = 1000;
          scrollInfo.nPage = 10;
          scrollInfo.nPos = 10;
          scrollInfo.nTrackPos = 10;
          
          m\_horzscrollbar.SetScrollInfo(&scrollInfo);
          m\_horzscrollbar.ShowWindow(1);
          

          The above piece of code created a horizontal scroll bar. When i right click on the scroll bar, it displaying a context menu with some options like page left, page right, scroll here, scroll left and scroll left. How can i stop this default context menu in my application since this is not required for me. Any help is appreciated. Thanks.

          J Offline
          J Offline
          Jochen Arndt
          wrote on last edited by
          #4

          Not tested but should work: Derive your own CScrollBar based class and implemement OnContextMenu() as empty function. Then the default implementation should not be called anymore.

          S 1 Reply Last reply
          0
          • J Jochen Arndt

            Not tested but should work: Derive your own CScrollBar based class and implemement OnContextMenu() as empty function. Then the default implementation should not be called anymore.

            S Offline
            S Offline
            Sampath579
            wrote on last edited by
            #5

            Thanks. The trick worked. :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups