Advertisement

05.08.2008 at 11:35AM PDT, ID: 23387164
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

CDialog with Scrool Bar and Drawing

Asked by suvendulaha in Windows MFC Programming, Windows Programming

Tags:

I have CDialog Class . I add scroll bar ot it. I am scrolling, the graphics be become vanished. I want to draw the graphics aslo. could you please help me.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
class CSystemEnclosureCabinateDlg : public CDialog
{
	DECLARE_DYNAMIC(CSystemEnclosureCabinateDlg)
 
public:
	CSystemEnclosureCabinateDlg(CWnd* pParent = NULL);   // standard constructor
	virtual ~CSystemEnclosureCabinateDlg();
 
// Dialog Data
	enum { IDD = IDD_DIALOG_ENCLOSURE_CABINATE };
 
	CRect	m_rcOriginalRect;
	BOOL	m_bDragging;
	CPoint	m_ptDragPoint;	
	int		m_nScrollPos;	
	int		m_nHScrollPos;	
	int		m_nCurHeight;
	int     m_nCurWidth;
 
	
protected:
	CBrush m_brush;
protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
 
	DECLARE_MESSAGE_MAP()
public:
	virtual BOOL OnInitDialog();
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnPaint();
};
 
///////////CPP //////////////file
IMPLEMENT_DYNAMIC(CSystemEnclosureCabinateDlg, CDialog)
CSystemEnclosureCabinateDlg::CSystemEnclosureCabinateDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSystemEnclosureCabinateDlg::IDD, pParent)
{
	Create(CSystemEnclosureCabinateDlg::IDD,pParent);
}
 
CSystemEnclosureCabinateDlg::~CSystemEnclosureCabinateDlg()
{
}
 
void CSystemEnclosureCabinateDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}
 
 
BEGIN_MESSAGE_MAP(CSystemEnclosureCabinateDlg, CDialog)
	ON_WM_CTLCOLOR()
	ON_WM_VSCROLL()
	ON_WM_SIZE()
	ON_WM_HSCROLL()
	ON_WM_PAINT()
END_MESSAGE_MAP()
 
 
// CSystemEnclosureCabinateDlg message handlers
 
BOOL CSystemEnclosureCabinateDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
 
	m_brush.CreateSolidBrush(RGB(255, 255, 255)); 
 
	GetWindowRect(m_rcOriginalRect);
	m_nScrollPos = 0; 
	m_nHScrollPos = 0;
 
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
 
HBRUSH CSystemEnclosureCabinateDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
 
	// TODO:  Change any attributes of the DC here
 
	return m_brush;
}
 
void CSystemEnclosureCabinateDlg::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 CSystemEnclosureCabinateDlg::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 CSystemEnclosureCabinateDlg::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);
}
 
void CSystemEnclosureCabinateDlg::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: Add your message handler code here
	// Do not call CDialog::OnPaint() for painting messages
	dc.MoveTo(0 ,100);
	dc.LineTo(1000,100);
}
 
 
[+][-]05.08.2008 at 09:18PM PDT, ID: 21530367

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 06:05AM PDT, ID: 21532337

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 09:51PM PDT, ID: 21537893

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Windows MFC Programming, Windows Programming
Tags: VC++ MFC
Sign Up Now!
Solution Provided By: mahesh1402
Participating Experts: 1
Solution Grade: A
 
 
[+][-]08.09.2008 at 10:49AM PDT, ID: 22197003

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]08.13.2008 at 04:11PM PDT, ID: 22226504

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628