Hide context menu on CScrollBar in MFC.
-
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.
-
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.
You could find some ideas from this thread: [Scrollbar and context menu](http://forums.codeguru.com/showthread.php?490982-Scrollbar-and-context-menu)
-
You could find some ideas from this thread: [Scrollbar and context menu](http://forums.codeguru.com/showthread.php?490982-Scrollbar-and-context-menu)
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.
-
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.
Not tested but should work: Derive your own
CScrollBar
based class and implemementOnContextMenu()
as empty function. Then the default implementation should not be called anymore. -
Not tested but should work: Derive your own
CScrollBar
based class and implemementOnContextMenu()
as empty function. Then the default implementation should not be called anymore.Thanks. The trick worked. :)