Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Project Line Counter Add-In v2.10 for VS.NET and VC6

, 29 Jun 2003
Get statistics about your source code with a click of a button
linecount_dll.zip
LineCount.dll
WWhizInterface.mod
LineCount.chm
linecount_src.zip
LineCount.dsw
LineCount_VC5.dsw
LineCount.dsp
LineCount_VC5.dsp
LineCount.odl
LineCount.def
LineCount.clw
Help
arrowrt.gif
Index.hhk
LineCount.chm
LineCount.hhp
mailto.gif
metl011.gif
PLC.gif
small_exclamation.gif
TOC.hhc
weblink.gif
res
idr_main.ico
project.ico
TBarLrge.bmp
TBarMedm.bmp
title.ico
ExtrnSrc
Release
LineCount.dll
WWhizInterface.mod
LineCount.chm
plc110src.zip
plc111.zip
WWhizInterfaceInstaller210Beta1.exe
LineCount.dll
LineCount.chm
plc111src.zip
WWhizInterfaceInstaller210Beta1.exe
LineCount.dll
LineCount.chm
Source
LineCount.dsw
LineCount_VC5.dsw
LineCount.dsp
LineCount_VC5.dsp
LineCount.odl
LineCount.def
Help
.cvsignore
Index.hhk
LineCount.hhp
PLC.gif
TOC.hhc
arrowrt.gif
mailto.gif
metl011.gif
small_exclamation.gif
weblink.gif
res
TBarLrge.bmp
TBarMedm.bmp
idr_main.ico
project.ico
title.ico
ExtrnSrc
Debug
WWhizInterface2D.mod
plc150.zip
WWhizInterfaceInstaller212.exe
LineCount.dll
LineCount.chm
Reports
SampleAnalysis.xls
Simple-BW.xsl
Simple-Color.xsl
plc150src.zip
WWhizInterfaceInstaller212.exe
LineCount.dll
LineCount.chm
SampleAnalysis.xls
Simple-BW.xsl
Simple-Color.xsl
LineCount.dsw
LineCount.dsp
LineCount.odl
LineCount.def
LineCount.clw
.cvsignore
TOC.hhc
linecount.hhp
arrowrt.gif
Index.hhk
PLC.gif
mailto.gif
small_exclamation.gif
weblink.gif
info_dot_small.gif
TBarLrge.bmp
idr_main.ico
project.ico
HdrDownA.bmp
HdrUpA.bmp
title.ico
info.ico
TBarMedm.bmp
WWhizInterface2D.mod
plc200.zip
LineCount.cab
WWhizInterface30VC6_1016.exe
plc200src.zip
.cvsignore
LineCount.def
LineCount.dsp
LineCount.dsw
LineCount.odl
ResizableLib
.cvsignore
ResizableLib.dsp
ResizableLib.dsw
.cvsignore
Index.hhk
LineCount.hhp
PLC.gif
TOC.hhc
arrowrt.gif
info_dot_small.gif
mailto.gif
small_exclamation.gif
weblink.gif
ObjModelVC6
ObjModelVC7
MSADDNDR.tlh
MSO.tlh
dte.tlh
HdrDownA.bmp
HdrUpA.bmp
LineCountVC6.rgs
LineCountVC7.rgs
TBarLrge.bmp
TBarMedm.bmp
idr_main.ico
info.ico
lcgo.bmp
project.ico
title.ico
WWhizInterface2D.mod
plc210.zip
SetupPLC210.exe
plc210src.zip
.cvsignore
LineCount.def
LineCount.dsp
LineCount.dsw
LineCount.odl
.cvsignore
ResizableLib.dsp
ResizableLib.dsw
.cvsignore
Index.hhk
LineCount.hhp
PLC.gif
TOC.hhc
arrowrt.gif
info_dot_small.gif
mailto.gif
small_exclamation.gif
weblink.gif
MSADDNDR.tlh
MSO.tlh
dte.tlh
HdrDownA.bmp
HdrUpA.bmp
LineCountVC6.rgs
LineCountVC7.rgs
TBarLrge.bmp
TBarMedm.bmp
gallery.xsl
idr_main.ico
info.ico
lcgo.bmp
project.ico
title.ico
WWhizInterface2D.mod
// ResizableSheet.cpp : implementation file
//
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2000-2001 by Paolo Messina
// (http://www.geocities.com/ppescher - ppescher@yahoo.com)
//
// The contents of this file are subject to the Artistic License (the "License").
// You may not use this file except in compliance with the License. 
// You may obtain a copy of the License at:
// http://www.opensource.org/licenses/artistic-license.html
//
// If you find this code useful, credits would be nice!
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ResizableSheet.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CResizableSheet

IMPLEMENT_DYNAMIC(CResizableSheet, CPropertySheet)

inline void CResizableSheet::Construct()
{
	m_bInitDone = FALSE;

	m_bEnableSaveRestore = FALSE;
	m_bSavePage = FALSE;
}


CResizableSheet::CResizableSheet()
{
	Construct();
}

CResizableSheet::CResizableSheet(UINT nIDCaption, CWnd *pParentWnd, UINT iSelectPage)
	 : CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
	Construct();
}

CResizableSheet::CResizableSheet(LPCTSTR pszCaption, CWnd *pParentWnd, UINT iSelectPage)
	 : CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
	Construct();
}

CResizableSheet::~CResizableSheet()
{
}

BEGIN_MESSAGE_MAP(CResizableSheet, CPropertySheet)
	//{{AFX_MSG_MAP(CResizableSheet)
	ON_WM_GETMINMAXINFO()
	ON_WM_SIZE()
	ON_WM_DESTROY()
	ON_WM_CREATE()
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
	ON_NOTIFY_REFLECT_EX(PSN_SETACTIVE, OnPageChanging)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CResizableSheet message handlers

int CResizableSheet::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CPropertySheet::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// keep client area
	CRect rect;
	GetClientRect(&rect);
	// set resizable style
	ModifyStyle(DS_MODALFRAME, WS_POPUP | WS_THICKFRAME);
	// adjust size to reflect new style
	::AdjustWindowRectEx(&rect, GetStyle(),
		::IsMenu(GetMenu()->GetSafeHmenu()), GetExStyle());
	SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(), SWP_FRAMECHANGED|
		SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREPOSITION);

	if (!InitGrip())
		return -1;

	return 0;
}

BOOL CResizableSheet::OnInitDialog() 
{
	BOOL bResult = CPropertySheet::OnInitDialog();
	
	// set the initial size as the min track size
	CRect rc;
	GetWindowRect(&rc);
	SetMinTrackSize(rc.Size());

	// init

	UpdateGripPos();

	PresetLayout();

	// prevent flickering
	GetTabControl()->ModifyStyle(0, WS_CLIPSIBLINGS);

	m_bInitDone = TRUE;

	return bResult;
}

void CResizableSheet::OnDestroy() 
{
	if (m_bEnableSaveRestore)
	{
		SaveWindowRect(m_sSection, m_bRectOnly);
		SavePage();
	}

	RemoveAllAnchors();

	CPropertySheet::OnDestroy();
}

// maps an index to a button ID and vice-versa
static UINT _propButtons[] =
{
	IDOK, IDCANCEL, ID_APPLY_NOW, IDHELP,
	ID_WIZBACK, ID_WIZNEXT, ID_WIZFINISH
};

// horizontal line in wizard mode
#define ID_WIZLINE	ID_WIZFINISH+1

void CResizableSheet::PresetLayout()
{
	if (IsWizard())	// wizard mode
	{
		// hide tab control
		GetTabControl()->ShowWindow(SW_HIDE);

		AddAnchor(ID_WIZLINE, BOTTOM_LEFT, BOTTOM_RIGHT);
	}
	else	// tab mode
	{
		AddAnchor(AFX_IDC_TAB_CONTROL, TOP_LEFT, BOTTOM_RIGHT);
	}

	// add a callback for active page (which can change at run-time)
	AddAnchorCallback(1);

	// use *total* parent size to have correct margins
	CRect rectPage, rectSheet;
	GetTotalClientRect(&rectSheet);

	GetActivePage()->GetWindowRect(&rectPage);
	ScreenToClient(&rectPage);

	// pre-calculate margins
	m_sizePageTL = rectPage.TopLeft() - rectSheet.TopLeft();
	m_sizePageBR = rectPage.BottomRight() - rectSheet.BottomRight();

	// add all possible buttons, if they exist
	for (int i = 0; i < 7; i++)
	{
		if (NULL != GetDlgItem(_propButtons[i]))
			AddAnchor(_propButtons[i], BOTTOM_RIGHT);
	}
}

BOOL CResizableSheet::ArrangeLayoutCallback(LayoutInfo &layout)
{
	if (layout.nCallbackID != 1)	// we only added 1 callback
		return CResizableLayout::ArrangeLayoutCallback(layout);

	// set layout info for active page
	layout.hWnd = GetActivePage()->GetSafeHwnd();

	// set margins
	if (IsWizard())	// wizard mode
	{
		// use pre-calculated margins
		layout.sizeMarginTL = m_sizePageTL;
		layout.sizeMarginBR = m_sizePageBR;
	}
	else	// tab mode
	{
		CRect rectPage, rectSheet;
		GetTotalClientRect(&rectSheet);

		CTabCtrl* pTab = GetTabControl();
		pTab->GetWindowRect(&rectPage);
		pTab->AdjustRect(FALSE, &rectPage);
		ScreenToClient(&rectPage);

		// use tab control
		layout.sizeMarginTL = rectPage.TopLeft() - rectSheet.TopLeft();
		layout.sizeMarginBR = rectPage.BottomRight() - rectSheet.BottomRight();
	}

	// set anchor types
	layout.sizeTypeTL = TOP_LEFT;
	layout.sizeTypeBR = BOTTOM_RIGHT;

	// use this layout info
	return TRUE;
}

void CResizableSheet::OnSize(UINT nType, int cx, int cy) 
{
	CWnd::OnSize(nType, cx, cy);
	
	if (nType == SIZE_MAXHIDE || nType == SIZE_MAXSHOW)
		return;		// arrangement not needed

	if (m_bInitDone)
	{
		// update size-grip
		UpdateGripPos();

		ArrangeLayout();
	}
}

BOOL CResizableSheet::OnPageChanging(NMHDR* /*pNotifyStruct*/, LRESULT* /*pResult*/)
{
	// update new wizard page
	// active page changes after this notification
	PostMessage(WM_SIZE);

	return FALSE;	// continue routing
}

BOOL CResizableSheet::OnEraseBkgnd(CDC* pDC) 
{
	ClipChildren(pDC);

	return CPropertySheet::OnEraseBkgnd(pDC);
}

void CResizableSheet::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
{
	if (!m_bInitDone)
		return;

	MinMaxInfo(lpMMI);
}

// protected members

int CResizableSheet::GetMinWidth()
{
	CWnd* pWnd = NULL;
	CRect rectWnd, rectSheet;
	GetTotalClientRect(&rectSheet);

	int max = 0, min = rectSheet.Width();
	// search for leftmost and rightmost button margins
	for (int i = 0; i < 7; i++)
	{
		pWnd = GetDlgItem(_propButtons[i]);
		// exclude not present or hidden buttons
		if (pWnd == NULL || !(pWnd->GetStyle() & WS_VISIBLE))
			continue;

		// left position is relative to the right border
		// of the parent window (negative value)
		pWnd->GetWindowRect(&rectWnd);
		ScreenToClient(&rectWnd);
		int left = rectSheet.right - rectWnd.left;
		int right = rectSheet.right - rectWnd.right;

		if (left > max)
			max = left;
		if (right < min)
			min = right;
	}

	// sizing border width
	int border = GetSystemMetrics(SM_CXSIZEFRAME);
	
	// compute total width
	return max + min + 2*border;
}


// NOTE: this must be called after all the other settings
//       to have the window and its controls displayed properly
void CResizableSheet::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly, BOOL bWithPage)
{
	m_sSection = pszSection;
	m_bSavePage = bWithPage;

	m_bEnableSaveRestore = TRUE;
	m_bRectOnly = bRectOnly;

	// restore immediately
	LoadWindowRect(pszSection, bRectOnly);
	LoadPage();
}

// private memebers

// used to save/restore active page
// either in the registry or a private .INI file
// depending on your application settings

#define ACTIVEPAGE 	_T("ActivePage")

void CResizableSheet::SavePage()
{
	if (!m_bSavePage)
		return;

	// saves active page index, zero (the first) if problems
	// cannot use GetActivePage, because it always fails

	CTabCtrl *pTab = GetTabControl();
	int page = 0;

	if (pTab != NULL) 
		page = pTab->GetCurSel();
	if (page < 0)
		page = 0;

	AfxGetApp()->WriteProfileInt(m_sSection, ACTIVEPAGE, page);
}

void CResizableSheet::LoadPage()
{
	// restore active page, zero (the first) if not found
	int page = AfxGetApp()->GetProfileInt(m_sSection, ACTIVEPAGE, 0);
	
	if (m_bSavePage)
	{
		SetActivePage(page);
		ArrangeLayout();	// needs refresh
	}
}

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Oz Solomon
Experion
Canada Canada
You may know Oz from his WndTabs days. Oz has long since left client side development to work on web technologies and to consult in the R&D management field.

| Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 30 Jun 2003
Article Copyright 2000 by Oz Solomon
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid