- sdimultisplit_part3.zip
- SDIMultiSplit
- bin
- SDIMultiApp1.exe
- CodeProject Article
- add_gridcontrol_01.png
- add_menu_items_01.png
- add_menu_items_02.png
- add_menu_items_03.png
- add_msg_handler_01.png
- add_msg_handler_02.png
- add_viewclass_01.png
- add_viewclass_02.png
- add_viewclass_03.png
- add_viewclass_04.png
- add_viewclass_05.png
- app_after_part3.png
- app1_stage_01.png
- app1_stage_01b.png
- code_notes_msgmap_01.png
- code_notes_msgmap_02.png
- CPArticle_Part_01.html
- CPArticle_Part_01.html.bak
- CPArticle_Part_02.html
- CPArticle_Part_02.html.bak
- CPArticle_Part_03.html
- CPArticle_Part_03.html.bak
- create_app1_01.png
- create_app1_02.png
- create_app1_03.png
- create_app1_04.png
- create_app1_05.png
- create_app1_06.png
- create_app1_07.png
- create_app1_08.png
- create_app1_09.png
- create_app1_10.png
- create_solution_01.png
- create_solution_02.png
- create_solution_03.png
- part_02_done_01.png
- part_02_done_02.png
- part_02_done_03.png
- part_02_done_04.png
- part_03_statusbar_01.png
- part_03_statusbar_02.png
- CodeProject
- include
- MFCGridControl_2-25
- SDIMultiApp1
- SDIMultiSplit.sln
- SDIMultiSplit.suo
|
// SecondaryView.cpp : implementation file
//
#include "stdafx.h"
#include "SDIMultiApp1.h"
#include "SecondaryView.h"
IMPLEMENT_DYNCREATE(CSecondaryView, CScrollView)
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// CSecondaryView message map
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CSecondaryView, CScrollView)
END_MESSAGE_MAP()
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// CSecondaryView constructor/destructor
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
CSecondaryView::CSecondaryView()
{
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
CSecondaryView::~CSecondaryView()
{
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// CSecondaryView overrides
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void CSecondaryView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// for the moment, we'll go ahead and use the default view size generated by
// class wizard
sizeTotal.cx = sizeTotal.cy = 100;
SetScrollSizes(MM_TEXT, sizeTotal);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void CSecondaryView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
CFont docFont;
CFont* pOldFont;
// construct and select our font
BuildFont(pDC, &docFont, 11, false, false);
pOldFont = pDC->SelectObject(&docFont);
// Get a baseline lineheight value. We add 2 pixels to the calculated
// lineheight so we have a little white space betwen lines of text.
CString sText = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
int nLineHeight = pDC->GetTextExtent(sText).cy + 2;
int nMargin = 10;
int nMaxLines = 20;
int nViewHeight = 5;
int nViewWidth = 0;
// draw the lines
for (int i = 1; i <= nMaxLines; i++)
{
// build our text string
sText.Format("This is line number %02d of %d", i, nMaxLines);
// display it
pDC->TextOutA(nMargin, nViewHeight, sText);
// calculate our new view height (and coincidentally, our next y position)
nViewHeight += nLineHeight;
// determine our new view width
nViewWidth = __max(nViewWidth, pDC->GetTextExtent(sText).cx);
}
// release the font resource
pDC->SelectObject(pOldFont);
// use our caluclated view height and width to reset the scroolbars.
SetScrollSizes(MM_TEXT, CSize(nViewWidth, nViewHeight));
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// CSecondaryView diagnostics
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
#ifdef _DEBUG
void CSecondaryView::AssertValid() const
{
CScrollView::AssertValid();
}
#ifndef _WIN32_WCE
void CSecondaryView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
#endif
#endif //_DEBUG
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// CSecondaryView programmer-added functions
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
// Added this function to build a suitable font for the INFO text - jms
//------------------------------------------------------------------------------
BOOL CSecondaryView::BuildFont(CDC* pDC, CFont* pFont, int nFontHeight, bool bBold, bool bItalic)
{
nFontHeight = -MulDiv(nFontHeight, pDC->GetDeviceCaps(LOGPIXELSY), 72);
CString sFontName = _T("Arial");
int nWeight = (bBold) ? FW_BOLD : FW_NORMAL;
BYTE nItalic = (bItalic) ? 1 : 0;
return pFont->CreateFont(nFontHeight, 0, 0, 0, nWeight, nItalic, 0, 0, DEFAULT_CHARSET,
OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE, sFontName);
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// CSecondaryView windows message handlers
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I've been paid as a programmer since 1982 with experience in Pascal, and C++ (both self-taught), and began writing Windows programs in 1991 using Visual C++ and MFC. In the 2nd half of 2007, I started writing C# Windows Forms and ASP.Net applications, and have since done WPF, Silverlight, WCF, web services, and Windows services.
My weakest point is that my moments of clarity are too brief to hold a meaningful conversation that requires more than 30 seconds to complete. Thankfully, grunts of agreement are all that is required to conduct most discussions without committing to any particular belief system.