Click here to Skip to main content
15,886,199 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionEmbedding Excel in a dialog Pin
efraimyy18-May-11 22:49
efraimyy18-May-11 22:49 
AnswerRe: Embedding Excel in a dialog Pin
Chandrasekharan P19-May-11 1:35
Chandrasekharan P19-May-11 1:35 
GeneralRe: Embedding Excel in a dialog Pin
efraimyy19-May-11 2:58
efraimyy19-May-11 2:58 
GeneralRe: Embedding Excel in a dialog Pin
efraimyy19-May-11 3:00
efraimyy19-May-11 3:00 
GeneralRe: Embedding Excel in a dialog Pin
Chandrasekharan P19-May-11 22:04
Chandrasekharan P19-May-11 22:04 
GeneralRe: Embedding Excel in a dialog Pin
efraimyy21-May-11 21:40
efraimyy21-May-11 21:40 
GeneralRe: Embedding Excel in a dialog Pin
Chandrasekharan P22-May-11 18:42
Chandrasekharan P22-May-11 18:42 
QuestionAdding Scrollbar to a Dialog in MFC Pin
pix_programmer18-May-11 20:52
pix_programmer18-May-11 20:52 
Hi!
I've added Vertical and Horizontal Scrollbar to a Dialog in MFC. I'm facing the following problems.

(i)I've loaded a Flash movie inside the Dialog. My movie is larger than my Dialog. But both the scrollbars are not appearing at

the beginning. After I reduce the dialog size only,the scrollbars appear.

(ii) When I reached the extreme of Horizontal Scrollbar or Vertical Scrollbar the movie is not fully displayed. Part of the movies

is cut.

(iii) Some kind flicking occurs during scrolling(both Vertical and Horizontal).

I've developed this application using VC++ 2008/MFC. Here's the code:

BOOL OnInitDialog()
{
   m_nScrollPos = 0; 
   m_nHScrollPos = 0;
}

void OnSize(UINT nType, int cx, int cy)
{
	CDialog::OnSize(nType, cx, cy);

	m_nCurHeight = cy;
	m_nCurWidth = cx;

	SCROLLINFO si;
	si.cbSize = sizeof(SCROLLINFO);
	si.fMask = SIF_ALL; 
	si.nMin = 0;
	si.nMax = m_rcOriginalRect.Height();
	si.nPage = cy;
	si.nPos = 0;
	SetScrollInfo(SB_VERT, &si, TRUE);  

	SCROLLINFO si1;
	si1.cbSize = sizeof(SCROLLINFO);
	si1.fMask = SIF_ALL; 
	si1.nMin = 0;
	si1.nMax = m_rcOriginalRect.Width();
	si1.nPage = cx;
	si1.nPos = 0;
	SetScrollInfo(SB_HORZ, &si1, TRUE); 
}

void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
{
	int nDelta;
	int nMaxPos = m_rcOriginalRect.Height() - m_nCurHeight;

	switch (nSBCode)
	{
	case SB_LINEDOWN:
		if (m_nScrollPos >= nMaxPos)
			return;

		nDelta = min(max(nMaxPos/20,5),nMaxPos-m_nScrollPos);
		break;

	case SB_LINEUP:
		if (m_nScrollPos <= 0)
			return;
		nDelta = -min(max(nMaxPos/20,5),m_nScrollPos);
		break;
	case SB_PAGEDOWN:
		if (m_nScrollPos >= nMaxPos)
			return;
		nDelta = min(max(nMaxPos/10,5),nMaxPos-m_nScrollPos);
		break;
	case SB_THUMBTRACK:
	case SB_THUMBPOSITION:
		nDelta = (int)nPos - m_nScrollPos;
		break;

	case SB_PAGEUP:
		if (m_nScrollPos <= 0)
			return;
		nDelta = -min(max(nMaxPos/10,5),m_nScrollPos);
		break;

	default:
		return;
	}
	m_nScrollPos += nDelta;
	SetScrollPos(SB_VERT,m_nScrollPos,TRUE);
	ScrollWindow(0,-nDelta);
	CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}

void Htmlbr::OnSize(UINT nType, int cx, int cy)
{
	CDialog::OnSize(nType, cx, cy);

	m_nCurHeight = cy;
	m_nCurWidth = cx;

	SCROLLINFO si;
	si.cbSize = sizeof(SCROLLINFO);
	si.fMask = SIF_ALL; 
	si.nMin = 0;
	si.nMax = m_rcOriginalRect.Height();
	si.nPage = cy;
	si.nPos = 0;
	SetScrollInfo(SB_VERT, &si, TRUE);  

	SCROLLINFO si1;
	si1.cbSize = sizeof(SCROLLINFO);
	si1.fMask = SIF_ALL; 
	si1.nMin = 0;
	si1.nMax = m_rcOriginalRect.Width();
	si1.nPage = cx;
	si1.nPos = 0;
	SetScrollInfo(SB_HORZ, &si1, TRUE); 
}

void Htmlbr::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
{

	int nDelta;
	int nMaxPos = m_rcOriginalRect.Width() - m_nCurWidth;

	switch (nSBCode)
	{
	case SB_LINERIGHT:
		if (m_nHScrollPos >= nMaxPos)
			return;

		nDelta = min(max(nMaxPos/20,5),nMaxPos-m_nHScrollPos);
		break;

	case SB_LINELEFT:
		if (m_nHScrollPos <= 0)
			return;
		nDelta = -min(max(nMaxPos/20,5),m_nHScrollPos);
		break;
	case SB_PAGERIGHT:
		if (m_nScrollPos >= nMaxPos)
			return;
		nDelta = min(max(nMaxPos/10,5),nMaxPos-m_nHScrollPos);
		break;
	case SB_THUMBTRACK:
	case SB_THUMBPOSITION:
		nDelta = (int)nPos - m_nHScrollPos;
		break;

	case SB_PAGELEFT:
		if (m_nScrollPos <= 0)
			return;
		nDelta = -min(max(nMaxPos/10,5),m_nHScrollPos);
		break;

	default:
		return;
	}
	m_nHScrollPos += nDelta;
	SetScrollPos(SB_HORZ,m_nHScrollPos,TRUE);
	ScrollWindow(-nDelta,0);

	CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}


What else need to be done to rectify the above problems?
AnswerRe: Adding Scrollbar to a Dialog in MFC Pin
Chandrasekharan P18-May-11 22:04
Chandrasekharan P18-May-11 22:04 
GeneralRe: Adding Scrollbar to a Dialog in MFC Pin
pix_programmer18-May-11 22:12
pix_programmer18-May-11 22:12 
GeneralRe: Adding Scrollbar to a Dialog in MFC Pin
Chandrasekharan P18-May-11 22:26
Chandrasekharan P18-May-11 22:26 
Questionvoice chat in client/server Pin
includeh1018-May-11 12:18
includeh1018-May-11 12:18 
AnswerRe: voice chat in client/server Pin
Code-o-mat19-May-11 0:24
Code-o-mat19-May-11 0:24 
QuestionHow create a windows 7 gadget with MFC in VC++2010? Pin
Hadi Dayvary18-May-11 7:36
professionalHadi Dayvary18-May-11 7:36 
AnswerRe: How create a windows 7 gadget with MFC in VC++2010? Pin
Mark Salsbery18-May-11 8:25
Mark Salsbery18-May-11 8:25 
Question.def and 64 bit Pin
Paul Bryan Porter18-May-11 5:57
Paul Bryan Porter18-May-11 5:57 
AnswerRe: .def and 64 bit Pin
Chris Meech18-May-11 6:30
Chris Meech18-May-11 6:30 
GeneralRe: .def and 64 bit Pin
Paul Bryan Porter19-May-11 12:55
Paul Bryan Porter19-May-11 12:55 
AnswerRe: .def and 64 bit Pin
Chris Losinger18-May-11 15:32
professionalChris Losinger18-May-11 15:32 
GeneralRe: .def and 64 bit Pin
Paul Bryan Porter19-May-11 12:59
Paul Bryan Porter19-May-11 12:59 
AnswerRe: .def and 64 bit Pin
Chris Losinger19-May-11 13:15
professionalChris Losinger19-May-11 13:15 
GeneralRe: .def and 64 bit Pin
Paul Bryan Porter20-May-11 5:44
Paul Bryan Porter20-May-11 5:44 
QuestionCreate DSN for SQL Server at Run time Pin
manju 318-May-11 2:36
manju 318-May-11 2:36 
QuestionRe: Create DSN for SQL Server at Run time Pin
David Crow18-May-11 3:08
David Crow18-May-11 3:08 
QuestionOpen other Application From Dialogue Pin
camuoi28817-May-11 22:59
camuoi28817-May-11 22:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.