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

The Ultimate Toolbox - Updates and User Contributions

, 12 Feb 2013
Updates and User Contributions for the Ultimate Toolbox Libraries
OutlookDemoUpdate.zip
Ultimate Grid
Demos
OutlookStyle
OutlookStyle.aps
OutlookStyle.dsp
OutlookStyle.dsw
OutlookStyle.suo
res
bitmap1.bmp
bmattach.bmp
bmp00001.bmp
bmp00002.bmp
bmp00003.bmp
Flags.bmp
OutlookStyle.ico
OutlookStyleDoc.ico
Toolbar.bmp
toolbar1.bmp
toolbar2.bmp
toolbarf.bmp
UltimateGrid72_Src_Update01.zip
CellTypes
Include
Source
UltimateGrid72_Src_Update02.zip
DataSources
ODBC
OleDB
EditControls
UltimateGrid72_Src_Update03.zip
UltimateGrid72_Src_Update04.zip
UltimateGrid73_src.zip
BuildDLL
Build DLL.dsp
Build DLL.dsw
res
BuildLib
ugmfclib.dsp
ugmfclib.dsw
Lib
Skel
UltimateTCP-IP42_Src_Update01.zip
Ultimate TCP-IP
Include
Security
Include
Source
source
UltimateTCP-IP42_Src_Update02.zip
Examples
Client
Mail
icon1.ico
icon2.ico
MailClientS.suo
test.dsp
test.dsw
UltimateTCP-IP42_Src_Update03.zip
ultimatetoolbox93_src_update01.zip
Ultimate Toolbox
include
source
UltimateToolbox93_Src_Update02.zip
lib
Build DLLs
Build Libs
UltimateToolbox93_Src_Update03.zip
UltimateToolbox93_Src_Update04.zip
UltimateToolbox93_Src_Update05.zip
// Version: 9.3

#if !defined(AFX_OXSKINNEDWND_H__6BAD3A54_4046_453C_A79B_4A9BB99FF063__INCLUDED_)
#define AFX_OXSKINNEDWND_H__6BAD3A54_4046_453C_A79B_4A9BB99FF063__INCLUDED_


#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// v9.3 - update 05 - removed
//#include "StdAfx.h"

// OXSkinnedWnd.h : header file
//


/////////////////////////////////////////////////////////////////////////////
// COXSkinnedWnd window

class COXToolbarSkin;

template<class BASE_CLASS>
class COXSkinnedWnd : public BASE_CLASS
{
	friend class COXToolbarSkinClassic;
	friend class COXToolbarSkinXP;

// Construction
public:
	COXSkinnedWnd()
	{
		m_pToolbarSkin = NULL;
	};

// Attributes
public:

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
protected:
	virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);

// Implementation
public:
	virtual ~COXSkinnedWnd() { };

private:
	COXToolbarSkin* m_pToolbarSkin;
	COXToolbarSkin* GetToolbarSkin();
	static LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);
	static HHOOK m_hMouseHook;
	static HWND m_hwndPrevMouseMoveWnd;
	static CList<HWND, HWND> m_Handles;
};

/////////////////////////////////////////////////////////////////////////////
// COXSkinnedWnd

template<class BASE_CLASS>
HHOOK COXSkinnedWnd<BASE_CLASS>::m_hMouseHook = NULL;

template<class BASE_CLASS>
HWND COXSkinnedWnd<BASE_CLASS>::m_hwndPrevMouseMoveWnd = NULL;

template<class BASE_CLASS>
CList<HWND, HWND> COXSkinnedWnd<BASE_CLASS>::m_Handles;

template<class BASE_CLASS>
COXToolbarSkin* COXSkinnedWnd<BASE_CLASS>::GetToolbarSkin()
{
	// Check if the app is derived from COXSkinnedApp
	COXSkinnedApp* pSkinnedApp = DYNAMIC_DOWNCAST(COXSkinnedApp, AfxGetApp());
	if (pSkinnedApp != NULL && pSkinnedApp->GetCurrentSkin() != NULL)
		return pSkinnedApp->GetCurrentSkin()->GetToolbarSkin();
	else
	{
		// Create a classic skin for this class if not created already
		if (m_pToolbarSkin == NULL)
			m_pToolbarSkin = new COXToolbarSkinClassic();

		return m_pToolbarSkin;
	}
};

// Update the edit box when the mouse leaves
template<class BASE_CLASS>
LRESULT CALLBACK COXSkinnedWnd<BASE_CLASS>::MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
	if (nCode < 0)
		return ::CallNextHookEx(m_hMouseHook, nCode, wParam, lParam);

	MOUSEHOOKSTRUCT* pMH = (MOUSEHOOKSTRUCT*) lParam;

	if (nCode == HC_ACTION && (wParam == WM_NCMOUSEMOVE || wParam == WM_MOUSEMOVE))
	{
		// If the previous message was for COXSizableMiniDockFrameWnd and the current is not
		// we need to update the caption buttons
		POSITION posPrev = m_Handles.Find(m_hwndPrevMouseMoveWnd);
		COXSkinnedWnd<BASE_CLASS>* pPrev = NULL;
		if (posPrev != NULL)
			pPrev = (COXSkinnedWnd<BASE_CLASS>*) CWnd::FromHandlePermanent(m_Handles.GetAt(posPrev));

		POSITION posCurrent = m_Handles.Find(pMH->hwnd);
		COXSkinnedWnd<BASE_CLASS>* pCurrent = NULL;
		if (posCurrent != NULL)
			pCurrent = (COXSkinnedWnd<BASE_CLASS>*) CWnd::FromHandlePermanent(m_Handles.GetAt(posCurrent));


		if (pPrev != NULL && pCurrent != pPrev)
		{
			// The mouse just left the window
			pPrev->GetToolbarSkin()->DrawWndFrame(pPrev);
		}
		else if (pCurrent != NULL)
		{
			// The mouse just entered the window
			pCurrent->GetToolbarSkin()->DrawWndFrame(pCurrent);
		}

		m_hwndPrevMouseMoveWnd = pMH->hwnd;
	}

	return ::CallNextHookEx(m_hMouseHook, nCode, wParam, lParam);
};


template<class BASE_CLASS>
LRESULT COXSkinnedWnd<BASE_CLASS>::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
#if defined (_WINDLL)
#if defined (_AFXDLL)
	AFX_MANAGE_STATE(AfxGetAppModuleState());
#else
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
#endif
#endif

	// TODO: Add your specialized code here and/or call the base class
	ASSERT_VALID(this);

	
	switch(message) 
	{
	case WM_CREATE:
		{
			// Hook the mouse
			if (m_hMouseHook == NULL)
			{
				m_hMouseHook = ::SetWindowsHookEx(WH_MOUSE, MouseProc, 0, AfxGetApp()->m_nThreadID);
			}

			if (m_Handles.Find(m_hWnd) == NULL)
				m_Handles.AddTail(m_hWnd);
			
			break;
		}

	case WM_DESTROY:
		{
			// Unhook the mouse
			if (m_hMouseHook)
			{
				::UnhookWindowsHookEx(m_hMouseHook);
				m_hMouseHook = NULL;
			}

			POSITION pos = m_Handles.Find(m_hWnd);
			if (pos != NULL)
				m_Handles.RemoveAt(pos);

			break;
		}

	case WM_PAINT:
		{
			LRESULT lResult = BASE_CLASS::WindowProc(message, wParam, lParam);
			GetToolbarSkin()->DrawWndFrame(this);
			
			return lResult;
		}

	case WM_SETFOCUS:
	case WM_KILLFOCUS:
		{
			GetToolbarSkin()->DrawWndFrame(this);
			break;
		}

	default:
		{
			break;
		}
	}

	return BASE_CLASS::WindowProc(message, wParam, lParam);
}

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_OXSKINNEDWND_H__6BAD3A54_4046_453C_A79B_4A9BB99FF063__INCLUDED_)

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)

Share

About the Author

The Ultimate Toolbox
Web Developer
Canada Canada
In January 2005, David Cunningham and Chris Maunder created TheUltimateToolbox.com, a new group dedicated to the continued development, support and growth of Dundas Software’s award winning line of MFC, C++ and ActiveX control products.
 
Ultimate Grid for MFC, Ultimate Toolbox for MFC, and Ultimate TCP/IP have been stalwarts of C++/MFC development for a decade. Thousands of developers have used these products to speed their time to market, improve the quality of their finished products, and enhance the reliability and flexibility of their software.
Group type: Organisation

387 members


| Advertise | Privacy | Mobile
Web02 | 2.8.140921.1 | Last Updated 13 Feb 2013
Article Copyright 2008 by The Ultimate Toolbox
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid