Click here to Skip to main content
16,017,650 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a scrollBar with elements like buttons, combo..I would like that my dialog has a scrollbar..because I have many elements and they don't enter in my dialog..How Can I do?

<pre>
<pre>void CModalitaNotturnaDlg2::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
	switch (nSBCode)
	{
	case SB_TOP:
		m_iSrcY = 0;
		break;
	case SB_BOTTOM:
		m_iSrcY = INT_MAX;
		break;
	case SB_THUMBPOSITION:
	case SB_THUMBTRACK:
		m_iSrcY = nPos;
		break;

	case SB_PAGEDOWN:
	case SB_LINEDOWN:
		if (m_iSrcY >= INT_MAX)
		{
			m_iSrcY = INT_MAX;
			return;
		}
		m_iSrcY += 10;
		break;
	case SB_PAGEUP:
	case SB_LINEUP:
		if (m_iSrcY <= (-INT_MAX))
		{
			m_iSrcY = 0;
			return;
		}
		m_iSrcY -= 10;
		break;
	}
	m_Scroll.SetScrollPos(m_iSrcY);
	Invalidate();
	CDialogEx::OnVScroll(nSBCode, nPos, pScrollBar);
}




<pre>
void CModalitaNotturnaDlg2::OnSize(UINT nType, int cx, int cy)
{

	//if (m_Scroll.GetSafeHwnd())
	//{
	vert.fMask = SIF_ALL;
	vert.nMin = 0;
	vert.nMax = 200;
	vert.nPage = 0;
	vert.nTrackPos = 0;
	m_Scroll.SetScrollInfo(&vert);

}


What I have tried:

I added some code but dialog doesn't change size..I don't know how I can show dialog
Posted
Updated 15-Jul-22 0:28am
v3
Comments
0x01AA 14-Jul-22 10:37am    
Maybe you are willing to show the relevant part of that code, that some MFC gurus can help you?
Member 14594285 14-Jul-22 10:40am    
In dialog I put true in left scrollbar, only this
jeron1 14-Jul-22 10:42am    
CScrollView Class | Microsoft Docs[^] Maybe using something like this?
Member 14594285 14-Jul-22 10:46am    
I don't know this class, I would like a scroll in my dialog
Richard MacCutchan 14-Jul-22 10:54am    
Adding scrollbars to a dialog is not generally supported in MFC. You would be better using the CFormView in a normal Window. Although, with some effort it may actually work in aDialog.

1 solution

Here is a detailed guide on how to add scrollbars to a dialog and react to the associated scrolling messages WM_VSCROLL and WM_HSCROLL. However, it is recommended here to avoid dialog-based scroll views and to use an SDI project with a CScrollView instead if possible.
c++ - How to enable scrolling on Dialog Based MFC app? - Stack Overflow[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900