Click here to Skip to main content
15,867,568 members
Articles / Desktop Programming / MFC

Resource ID Organiser Add-In for Visual C++ 5.0/6.0/.NET

Rate me:
Please Sign up or sign in to vote.
4.98/5 (71 votes)
10 Jan 2005CPOL25 min read 528.2K   12.1K   201  
An application/add-in to organise and renumber resource symbol IDs
// CJExplorerBar.cpp : implementation file
// Copyright � 1998-1999 CodeJock.com, All Rights Reserved.
// See ReadMe.txt for TERMS OF USE.
//
/////////////////////////////////////////////////////////////////////////////
/****************************************************************************
 *
 * $Date: 10/25/99 10:52p $
 * $Revision: 12 $
 * $Archive: /CodeJock/CJLibrary/CJExplorerBar.cpp $
 *
 * $History: CJExplorerBar.cpp $
 * 
 * *****************  Version 12  *****************
 * User: Kirk Stowell Date: 10/25/99   Time: 10:52p
 * Updated in $/CodeJock/CJLibrary
 * Modified resource include for static builds.
 * 
 * *****************  Version 11  *****************
 * User: Kirk Stowell Date: 10/24/99   Time: 12:01a
 * Updated in $/CodeJock/CJLibrary
 * Fixed potential resource and memory leak problems.
 * 
 * *****************  Version 10  *****************
 * User: Kirk Stowell Date: 8/31/99    Time: 1:11a
 * Updated in $/CodeJockey/CJLibrary
 * Updated copyright and contact information.
 * 
 * *****************  Version 9  *****************
 * User: Kirk Stowell Date: 8/29/99    Time: 9:14p
 * Updated in $/CodeJockey/CJLibrary
 * Added Unicode compliance, thanks to Barry Burton for his help with
 * this.
 * 
 * 
 * *****************  Version 8  *****************
 * User: Kirk Stowell Date: 6/23/99    Time: 7:24a
 * Updated in $/CodeJockey/CJLibrary
 * 
 * *****************  Version 7  *****************
 * User: Kirk Stowell Date: 6/23/99    Time: 2:07a
 * Updated in $/CodeJockey/CJLibrary
 * 
 * *****************  Version 6  *****************
 * User: Kirk Stowell Date: 7/25/99    Time: 12:30a
 * Updated in $/CodeJockey/CJLibrary
 * 
 * *****************  Version 5  *****************
 * User: Kirk Stowell Date: 7/18/99    Time: 10:26p
 * Updated in $/CodeJockey/CJLibrary
 * Cleaned up caption creation.
 * 
 * *****************  Version 4  *****************
 * User: Kirk Stowell Date: 6/09/99    Time: 8:33p
 * Updated in $/CodeJockey/CJ60Lib
 * Ioannhs Stamatopoulos (Yiannhs) [ystamat@mail.datamedia.gr] - Extended
 * docking windows, removed ::GetSysColor(...) calls and WM_SYSCOLORCHANGE
 * message handler, this is now automatically handled by the base class.
 * Added redraw flags to the create method and modified paint and layout
 * handlers to reduce flicker and un-necessary command handling. Dragging
 * rect now reflects actual control bar docked size. Added "flat" look to
 * the control bars, the control bars can now use the classic DevStudio
 * look, or use flat gradient gripper, borders and frame buttons. Overall,
 * docking windows now handle dragging, docking and floating much better,
 * and behave more like DevStudio.
 * 
 * *****************  Version 3  *****************
 * User: Kirk Stowell Date: 4/03/99    Time: 4:23p
 * Updated in $/CodeJockey/CJ60Lib
 * Added comments and cleaned up code.
 * 
 * *****************  Version 2  *****************
 * User: Kirk Stowell Date: 1/31/99    Time: 4:23p
 * Updated in $/CodeJockey/CJ60Lib
 * Made some cosmetic enhancements to more closely match the windows
 * explorer bar.
 * 
 * *****************  Version 1  *****************
 * User: Kirk Stowell Date: 1/16/99    Time: 4:22p
 * Created in $/CodeJockey/CJ60Lib
 * Initial release
 *
 ***************************************************************************/
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CJResource.h"
#include "CJExplorerBar.h"

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

/////////////////////////////////////////////////////////////////////////////
// CCJExplorerBar

CCJExplorerBar::CCJExplorerBar()
{
	m_hIcon = NULL;
	m_strCaption = _T("");
}

CCJExplorerBar::~CCJExplorerBar()
{
	// fix potential resource leak - KStowell - 10-22-99.
	_destroyIcon(m_hIcon);
}

IMPLEMENT_DYNAMIC(CCJExplorerBar, CCJControlBar)

BEGIN_MESSAGE_MAP(CCJExplorerBar, CCJControlBar)
	//{{AFX_MSG_MAP(CCJExplorerBar)
	ON_WM_CREATE()
	ON_COMMAND(IDC_BAR_BUTTON, OnButtonClose)
	ON_UPDATE_COMMAND_UI(IDC_BAR_BUTTON, OnUpdateButtonClose)
	ON_WM_WINDOWPOSCHANGED()
	ON_WM_ERASEBKGND()
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCJExplorerBar message handlers

BOOL CCJExplorerBar::Create(CWnd *pParentWnd, UINT nID, LPCTSTR lpszWindowName, CSize sizeDefault, DWORD dwStyle)
{
	m_strCaption = lpszWindowName;

	if(!CCJControlBar::Create(pParentWnd, nID, lpszWindowName, sizeDefault, dwStyle)) {
		return FALSE;
	}

	ShowFrameControls(FALSE, FALSE);
	return TRUE;
}

int CCJExplorerBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CCJControlBar::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// Create the caption.
	if (!m_Caption.Create(this, m_strCaption))
	{
		TRACE0( "Unable to create caption.\n" );
		return -1;
	}

	// Create the caption button.
	if (!m_CaptionButton.Create(NULL, WS_VISIBLE|BS_ICON|BS_OWNERDRAW|BS_CENTER|BS_VCENTER,
		CRect(0,0,0,0), this, IDC_BAR_BUTTON))
	{
		TRACE0( "Unable to create caption button.\n" );
		return -1;
	}
	
	// Create the image list used by frame buttons.
	CImageList imageList;
	imageList.Create(IDB_PUSHPIN, 16, 1, RGB(255,0,255));
	m_hIcon = imageList.ExtractIcon(2);

	// Associate the button icon
	m_CaptionButton.SetIcon(m_hIcon, CSize(16,15));
	imageList.DeleteImageList();

	return 0;
}

void CCJExplorerBar::OnButtonClose()
{
	GetDockingFrame()->ShowControlBar(this, FALSE, FALSE);
}

void CCJExplorerBar::OnUpdateButtonClose(CCmdUI* pCmdUI)
{
	pCmdUI->Enable(TRUE);
}

void CCJExplorerBar::GetChildRect(CRect &rect)
{
	GetClientRect(&rect);
	
	if (!IsFloating())
	{
		rect.left	+= 1;
		rect.right  -= 1;
		rect.top	+= (IsVertDocked()?26:22);
	}

	else
		rect.DeflateRect(2,2);
}

void CCJExplorerBar::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) 
{
	CControlBar::OnWindowPosChanged(lpwndpos);
	
	int nCmdShow = IsFloating() ? SW_HIDE:SW_SHOW;
	m_Caption.ShowWindow(nCmdShow);
	m_CaptionButton.ShowWindow(nCmdShow);

	if (!IsFloating())
	{
		if (IsVertDocked())
		{
			m_Caption.MoveWindow(1,4,lpwndpos->cx-1,22);
			m_CaptionButton.MoveWindow(CRect(lpwndpos->cx-25,
				7, lpwndpos->cx-5, 24));
		}
		else
		{
			m_Caption.MoveWindow(1,0,lpwndpos->cx-1,22);
			m_CaptionButton.MoveWindow(CRect(lpwndpos->cx-25,
				3, lpwndpos->cx-5, 20));
		}
	}

	if (m_pChildWnd->GetSafeHwnd())
	{
		CRect rc;
		GetChildRect(rc);
		m_pChildWnd->MoveWindow(rc);
	}
}

BOOL CCJExplorerBar::OnEraseBkgnd(CDC* pDC) 
{
	int result = CControlBar::OnEraseBkgnd(pDC);

	CRect rect;
	GetClientRect(rect);
	rect.top+=(IsVertDocked()?3:-1);
	rect.bottom += 1;
    //Yiannhs This was a side effect of removing the variables
    pDC->Draw3dRect(rect, afxData.clrBtnShadow, afxData.clrBtnShadow);
	//pDC->Draw3dRect(rect, m_clrBtnShadow, m_clrBtnShadow);
	return result;
}

void CCJExplorerBar::OnLButtonDown(UINT /*nFlags*/, CPoint /*point*/) 
{
	// bypass CCJControlBar.
}

void CCJExplorerBar::OnLButtonUp(UINT /*nFlags*/, CPoint /*point*/) 
{
	// bypass CCJControlBar.
}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder Riverblade Limited
United Kingdom United Kingdom
I haven't always written software for a living. When I graduated from Surrey University in 1989, it was with an Electronic Engineering degree, but unfortunately that never really gave me the opportunity to do anything particularly interesting (with the possible exception of designing Darth Vader's Codpiece * for the UK Army in 1990).
    * Also known as the Standard Army Bootswitch. But that's another story...
Since the opportunity arose to lead a software team developing C++ software for Avionic Test Systems in 1996, I've not looked back. More recently I've been involved in the development of subsea acoustic navigation systems, digital TV broadcast systems, port security/tracking systems, and most recently software development tools with my own company, Riverblade Ltd.

One of my personal specialities is IDE plug-in development. ResOrg was my first attempt at a plug-in, but my day to day work is with Visual Lint, an interactive code analysis tool environment with works within the Visual Studio and Eclipse IDEs or on build servers.

I love lots of things, but particularly music, photography and anything connected with history or engineering. I despise ignorant, intolerant and obstructive people - and it shows...I can be a bolshy cow if you wind me up the wrong way...Laugh | :laugh:

I'm currently based 15 minutes walk from the beach in Bournemouth on the south coast of England. Since I moved here I've grown to love the place - even if it is full of grockles in Summer!

Comments and Discussions