|
-
October 19th, 2004, 07:04 AM
#1
Vertical ScrollBar does not send WM_VSCROLL
Hi gurus,
To my view i added a horizontal and a vertical scrollbar.
They are both visible, but only the horizontal scrollbar sends WM_HSCROLL messages to the view when clicked on.
The vertical scrollbar does nothing when clicked on. How is this possible????
Both handlers and message maps are present. Breakpoint in OnHScroll() stops execution, but this does not work for OnVScroll().
Also spy++ does not record WM_VSCROLL messages.
This is how they are created:
Code:
CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...
// Create scrollbars
VERIFY(m_HorzScrollBar.Create(WS_CHILD|WS_VISIBLE|WS_HSCROLL,
CRect(0,0,0,0), this, IDS_CTRL_HORZ_SB));
VERIFY(m_VertScrollBar.Create(WS_CHILD|WS_VISIBLE|WS_VSCROLL,
CRect(0,0,0,0), this, IDS_CTRL_VERT_SB));
...
}
This is how i draw them:
Code:
void CMyView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
CRect rcClient;
GetClientRect(&rcClient);
int iNewHeight = rcClient.bottom;
int iNewWidth = rcClient.right;
int iFolderTabWidth = m_FolderTabs.GetDesiredWidth();
int iFolderTabLimit = (iNewWidth*4) / 5;
if(iFolderTabWidth > iFolderTabLimit)
iFolderTabWidth = iFolderTabLimit;
m_FolderTabs.MoveWindow(0, iNewHeight - GetSystemMetrics(SM_CYHSCROLL),
iFolderTabWidth, GetSystemMetrics(SM_CYHSCROLL), TRUE);
// reposition and redraw the horizontal scroll bar
m_HorzScrollBar.MoveWindow(
iFolderTabWidth,
iNewHeight - GetSystemMetrics(SM_CYHSCROLL),
iNewWidth - iFolderTabWidth - GetSystemMetrics(SM_CXVSCROLL),
GetSystemMetrics (SM_CYHSCROLL), TRUE);
// reposition and redraw the horizontal scroll bar
m_VertScrollBar.MoveWindow(
iNewWidth - GetSystemMetrics(SM_CYHSCROLL),
rcClient.top,
GetSystemMetrics(SM_CYHSCROLL),
iNewHeight - GetSystemMetrics(SM_CYHSCROLL), TRUE);
SCROLLINFO si;
ZeroMemory (&si, sizeof (SCROLLINFO));
si.cbSize = sizeof (SCROLLINFO);
si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
si.nMin = 0;
si.nMax = 10;
si.nPos = 5;
si.nPage = 1;
m_HorzScrollBar.SetScrollInfo (&si, TRUE);
m_VertScrollBar.SetScrollInfo (&si, TRUE);
}
Time is fun when you're having flies 
-
October 19th, 2004, 07:31 AM
#2
Re: Vertical ScrollBar does not send WM_VSCROLL
Never mind, i figured it out. I passed the wrong styles for the scrollbars
Should be:
Code:
// Create scrollbars
VERIFY(m_HorzScrollBar.Create(WS_CHILD|WS_VISIBLE|SBS_HORZ,
CRect(0,0,0,0), this, IDS_CTRL_HORZ_SB));
VERIFY(m_VertScrollBar.Create(WS_CHILD|WS_VISIBLE|SBS_VERT,
CRect(0,0,0,0), this, IDS_CTRL_VERT_SB));
Time is fun when you're having flies 
-
October 19th, 2004, 07:56 AM
#3
Re: Vertical ScrollBar does not send WM_VSCROLL
 Originally Posted by hmc
Never mind, i figured it out. I passed the wrong styles for the scrollbars 
Well, no problem. Can happen to anybody anytime.
But I have to remark that was a cute mistake, i.e. trying to create a scrolbar control having a scrolbar. Just
Hokutata Yakubotu
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|