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

The Ultimate Toolbox - Updates and User Contributions

, 12 Feb 2013 CPOL
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
// OXSkinnedComboBox.cpp : implementation file
//
// Version: 9.3


#include "stdafx.h"

// v93 update 03 - 64-bit
#include "UTB64Bit.h"

#include "OXSkinnedComboBox.h"
#include "OXSkins.h"

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

#include <Shlwapi.h>

// This function is used to check the version of comctl32.dll
#define PACKVERSION(major,minor) MAKELONG(minor,major)
DWORD GetDllVersion(LPCTSTR lpszDllName)
{
    HINSTANCE hinstDll;
    DWORD dwVersion = 0;

    hinstDll = LoadLibrary(lpszDllName);
	
    if(hinstDll)
    {
        DLLGETVERSIONPROC pDllGetVersion;
        pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll, 
                          "DllGetVersion");

        /*Because some DLLs might not implement this function, you
        must test for it explicitly. Depending on the particular 
        DLL, the lack of a DllGetVersion function can be a useful
        indicator of the version.*/

        if(pDllGetVersion)
        {
            DLLVERSIONINFO dvi;
            HRESULT hr;

            ZeroMemory(&dvi, sizeof(dvi));
            dvi.cbSize = sizeof(dvi);

            hr = (*pDllGetVersion)(&dvi);

            if(SUCCEEDED(hr))
            {
               dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion);
            }
        }

        FreeLibrary(hinstDll);
    }
    return dwVersion;
}

/////////////////////////////////////////////////////////////////////////////
// COXSkinnedComboBox

IMPLEMENT_DYNCREATE(COXSkinnedComboBox, CComboBox)

HHOOK COXSkinnedComboBox::m_hMouseHook = NULL;
HWND COXSkinnedComboBox::m_hwndPrevMouseMoveWnd = NULL;

COXSkinnedComboBox::COXSkinnedComboBox() :
	m_pToolbarSkin(NULL)
{
	// Determine if we are ussing common controls 6.0 or not
	if (GetDllVersion(_T("comctl32.dll")) >= PACKVERSION(6,00))
		m_bCommonControls6 = true;
	else
		m_bCommonControls6 = false;
}

COXSkinnedComboBox::~COXSkinnedComboBox()
{
	if (m_pToolbarSkin != NULL)
		delete m_pToolbarSkin;
}


BEGIN_MESSAGE_MAP(COXSkinnedComboBox, CComboBox)
	//{{AFX_MSG_MAP(COXSkinnedComboBox)
	ON_WM_PAINT()
	ON_WM_CREATE()
	ON_WM_DESTROY()
	ON_CONTROL_REFLECT_EX(CBN_KILLFOCUS, OnKillFocus)
	ON_CONTROL_REFLECT_EX(CBN_SETFOCUS, OnSetFocus)
	ON_CONTROL_REFLECT_EX(CBN_SELCHANGE, OnSelChange)
	ON_CONTROL_REFLECT_EX(CBN_CLOSEUP, OnCloseUp)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// COXSkinnedComboBox message handlers

void COXSkinnedComboBox::OnPaint() 
{
	GetToolbarSkin()->OnPaintComboBox(this);
}

COXToolbarSkin* COXSkinnedComboBox::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 combo box when the mouse leaves
LRESULT CALLBACK COXSkinnedComboBox::MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
	if (nCode < 0)
		return ::CallNextHookEx(m_hMouseHook, nCode, wParam, lParam);

	if (nCode == HC_ACTION && wParam == WM_MOUSEMOVE)
	{
		MOUSEHOOKSTRUCT* pMH = (MOUSEHOOKSTRUCT*) lParam;

		// If the previous message was for COXSizableMiniDockFrameWnd and the current is not
		// we need to update the caption buttons
		COXSkinnedComboBox* pPrev = DYNAMIC_DOWNCAST(COXSkinnedComboBox,
			CWnd::FromHandlePermanent(m_hwndPrevMouseMoveWnd));
		if (pPrev == NULL)
			pPrev = DYNAMIC_DOWNCAST(COXSkinnedComboBox,
				CWnd::FromHandlePermanent(::GetParent(m_hwndPrevMouseMoveWnd)));

		COXSkinnedComboBox* pCurrent = DYNAMIC_DOWNCAST(COXSkinnedComboBox,
			CWnd::FromHandlePermanent(pMH->hwnd));
		if (pCurrent == NULL)
			pCurrent = DYNAMIC_DOWNCAST(COXSkinnedComboBox,
				CWnd::FromHandlePermanent(::GetParent(pMH->hwnd)));

		if (pPrev != NULL && pCurrent != pPrev)
		{
			// The mouse just left the combo box
			pPrev->GetToolbarSkin()->DrawComboBox(pPrev);
		}
		else if (pCurrent != NULL && pCurrent != pPrev)
		{

			// The mouse just entered the combo box
			pCurrent->GetToolbarSkin()->DrawComboBox(pCurrent);
		}

		m_hwndPrevMouseMoveWnd = pMH->hwnd;
	}

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

int COXSkinnedComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CComboBox::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// Hook the mouse
	if (m_hMouseHook == NULL)
		m_hMouseHook = ::SetWindowsHookEx(WH_MOUSE, MouseProc, 0, AfxGetApp()->m_nThreadID);
	
	return 0;
}

void COXSkinnedComboBox::OnDestroy() 
{
	// Unhook the mouse
	if (m_hMouseHook)
	{
		::UnhookWindowsHookEx(m_hMouseHook);
		m_hMouseHook = NULL;
	}

	CComboBox::OnDestroy();
}

BOOL COXSkinnedComboBox::OnKillFocus() 
{
	GetToolbarSkin()->DrawComboBox(this);
	return FALSE;
}

BOOL COXSkinnedComboBox::OnSetFocus() 
{
	GetToolbarSkin()->DrawComboBox(this);
	return FALSE;	
}

BOOL COXSkinnedComboBox::OnSelChange() 
{
	GetToolbarSkin()->DrawComboBox(this);
	return FALSE;	
}

BOOL COXSkinnedComboBox::OnCloseUp() 
{
	GetToolbarSkin()->DrawComboBox(this);
	return FALSE;
}

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

392 members


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