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

WTL Helper

, 27 Aug 2007
Add-in for Microsoft VC++.NET 2003 that helps to insert message handlers for WTL.
wtlhelper.zip
WTLHelper.exe
wtlhelper_exe.zip
WTLHelper.exe
wtlhelper_src.zip
source
AddIn.def
Dialog
vssver.scc
Options
res
a1.ico
AddIn.rgs
addin8.rgs
closefld.ico
Clsdfold.ico
DDX.bmp
dialog.bmp
functoolbar.bmp
icons.bmp
message.ico
msg.bmp
mysmall4.bmp
openfld.ico
Openfold.ico
option.bmp
vartoolbar.bmp
vssver.scc
wizard.bmp
Wizard.ico
WtlHelper.dll.manifest
resources
Setup.nsi
WtlHelperRes
res
DDX.bmp
dialog.bmp
msg.bmp
option.bmp
reflect.bmp
wizard.bmp
WtlHelperRes.aps
WtlHelperRes8.vcproj.MINSK.solozhentsev.user
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2005 Sergey Solozhentsev
// Author: 	Sergey Solozhentsev e-mail: salos@mail.ru
// Product:	WTL Helper
// File:      	ColorSetupDlg.cpp
// Created:	08.09.2005 16:59
// 
//   Using this software in commercial applications requires an author
// permission. The permission will be granted to everyone excluding the cases
// when someone simply tries to resell the code.
//   This file may be redistributed by any means PROVIDING it is not sold for
// profit without the authors written consent, and providing that this notice
// and the authors name is included.
//   This file is provided "as is" with no expressed or implied warranty. The
// author accepts no liability if it causes any damage to you or your computer
// whatsoever.
//
////////////////////////////////////////////////////////////////////////////////

// This file was generated by WTL Dialog wizard 
// dialog\ColorSetupDlg.cpp : Implementation of CColorSetupDlg

#include "stdafx.h"
#include "ColorSetupDlg.h"
#include "FileFilterDialog.h"
#include "../XMLSettingsArchive.h"

// CColorSetupDlg
CColorSetupDlg::CColorSetupDlg() : m_clWindowsText(CLR_NONE), m_clWindowsBack(CLR_NONE),
m_clCommandText(CLR_NONE), m_clCommandBack(CLR_NONE), m_clNotifyText(CLR_NONE),
m_clNotifyBack(CLR_NONE), m_clReflectBack(CLR_NONE), m_clReflectText(CLR_NONE)
{
	m_clDefBackColor = GetSysColor(COLOR_WINDOW);
	m_clDefTextColor = GetSysColor(COLOR_BTNTEXT);
}

CColorSetupDlg::~CColorSetupDlg()
{
}

LRESULT CColorSetupDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	CenterWindow();
	COLORREF BrushColor;
	// Windows colors
	m_WindowsText.SubclassWindow(GetDlgItem(IDC_BUTTON_WINDOWS_TEXT_COLOR));
	m_WindowsText.SetDefaultText(IDS_COLOR_DEFAULT);
	m_WindowsText.SetDefaultColor(m_clDefTextColor);
	m_WindowsText.SetColor((m_clWindowsText != CLR_NONE)? m_clWindowsText : CLR_DEFAULT);
	m_WindowsBack.SubclassWindow(GetDlgItem(IDC_BUTTON_WINDOWS_BACK_COLOR));
	m_WindowsBack.SetDefaultText(IDS_COLOR_DEFAULT);
	m_WindowsBack.SetDefaultColor(m_clDefBackColor);
	m_WindowsBack.SetColor(BrushColor = ((m_clWindowsBack != CLR_NONE) ? m_clWindowsBack : CLR_DEFAULT));
	if (BrushColor == CLR_DEFAULT)
	{
		BrushColor = m_clDefBackColor;
	}
	m_WindowsBrush.CreateSolidBrush(BrushColor);
	//Command Colors
	m_CommandText.SubclassWindow(GetDlgItem(IDC_BUTTON_COMMAND_TEXT_COLOR));
	m_CommandText.SetDefaultText(IDS_COLOR_DEFAULT);
	m_CommandText.SetDefaultColor(m_clDefTextColor);
	m_CommandText.SetColor((m_clCommandText != CLR_NONE) ? m_clCommandText : CLR_DEFAULT);
	m_CommandBack.SubclassWindow(GetDlgItem(IDC_BUTTON_COMMAND_BACK_COLOR));
	m_CommandBack.SetDefaultText(IDS_COLOR_DEFAULT);
	m_CommandBack.SetDefaultColor(m_clDefBackColor);
	m_CommandBack.SetColor(BrushColor = ((m_clCommandBack != CLR_NONE) ? m_clCommandBack : CLR_DEFAULT));
	if (BrushColor == CLR_DEFAULT)
	{
		BrushColor = m_clDefBackColor;
	}
	m_CommandBrush.CreateSolidBrush(BrushColor);
	//Notify Colors
	m_NotifyText.SubclassWindow(GetDlgItem(IDC_BUTTON_NOTIFY_TEXT_COLOR));
	m_NotifyText.SetDefaultText(IDS_COLOR_DEFAULT);
	m_NotifyText.SetDefaultColor(m_clDefTextColor);
	m_NotifyText.SetColor((m_clNotifyText != CLR_NONE) ? m_clNotifyText : CLR_DEFAULT);
	m_NotifyBack.SubclassWindow(GetDlgItem(IDC_BUTTON_NOTIFY_BACK_COLOR));
	m_NotifyBack.SetDefaultText(IDS_COLOR_DEFAULT);
	m_NotifyBack.SetDefaultColor(m_clDefBackColor);
	m_NotifyBack.SetColor(BrushColor = ((m_clNotifyBack != CLR_NONE) ? m_clNotifyBack : CLR_DEFAULT));
	if (BrushColor == CLR_DEFAULT)
	{
		BrushColor = m_clDefBackColor;
	}
	m_NotifyBrush.CreateSolidBrush(BrushColor);
	//Reflect Colors
	m_ReflectText.SubclassWindow(GetDlgItem(IDC_BUTTON_REFLECT_TEXT_COLOR));
	m_ReflectText.SetDefaultText(IDS_COLOR_DEFAULT);
	m_ReflectText.SetDefaultColor(m_clDefTextColor);
	m_ReflectText.SetColor((m_clReflectText != CLR_NONE) ? m_clReflectText : CLR_DEFAULT);
	m_ReflectBack.SubclassWindow(GetDlgItem(IDC_BUTTON_REFLECT_BACK_COLOR));
	m_ReflectBack.SetDefaultText(IDS_COLOR_DEFAULT);
	m_ReflectBack.SetDefaultColor(m_clDefBackColor);
	m_ReflectBack.SetColor(BrushColor = ((m_clReflectBack != CLR_NONE) ? m_clReflectBack : CLR_DEFAULT));
	if (BrushColor == CLR_DEFAULT)
	{
		BrushColor = m_clDefBackColor;
	}
	m_ReflectBrush.CreateSolidBrush(BrushColor);

	return 1;  // Let the system set the focus
}

LRESULT CColorSetupDlg::OnClickedOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	COLORREF Color;
	Color = m_WindowsText.GetColor();
	m_clWindowsText = ((Color == CLR_DEFAULT) ? CLR_NONE : Color);
	Color = m_WindowsBack.GetColor();
	m_clWindowsBack = ((Color == CLR_DEFAULT) ? CLR_NONE : Color);
	Color = m_CommandText.GetColor();
	m_clCommandText = ((Color == CLR_DEFAULT) ? CLR_NONE : Color);
	Color = m_CommandBack.GetColor();
	m_clCommandBack = ((Color == CLR_DEFAULT) ? CLR_NONE : Color);
	Color = m_NotifyText.GetColor();
	m_clNotifyText = ((Color == CLR_DEFAULT) ? CLR_NONE : Color);
	Color = m_NotifyBack.GetColor();
	m_clNotifyBack = ((Color == CLR_DEFAULT) ? CLR_NONE : Color);
	Color = m_ReflectBack.GetColor();
	m_clReflectBack = ((Color == CLR_DEFAULT) ? CLR_NONE : Color);

	m_WindowsBrush.DeleteObject();
	m_CommandBrush.DeleteObject();
	m_NotifyBrush.DeleteObject();
	m_ReflectBrush.DeleteObject();

	EndDialog(wID);
	return 0;
}

LRESULT CColorSetupDlg::OnClickedCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	m_WindowsBrush.DeleteObject();
	m_CommandBrush.DeleteObject();
	m_NotifyBrush.DeleteObject();

	EndDialog(wID);
	return 0;
}

LRESULT CColorSetupDlg::OnCtrlColor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	HDC hdc = (HDC)wParam;
	HWND hStatic = (HWND)lParam;
	if (hStatic == GetDlgItem(IDC_STATIC_WINDOWS))
	{
		COLORREF Color = m_WindowsText.GetColor();
		if (Color == CLR_DEFAULT)
		{
			Color = m_clDefTextColor;
		}
		::SetTextColor(hdc, Color);
		::SetBkMode(hdc, TRANSPARENT);
		return (LRESULT)m_WindowsBrush.m_hBrush;
	}
	if (hStatic == GetDlgItem(IDC_STATIC_COMMAND))
	{
		COLORREF Color = m_CommandText.GetColor();
		if (Color == CLR_DEFAULT)
		{
			Color = m_clDefTextColor;
		}
		::SetTextColor(hdc, Color);
		::SetBkMode(hdc, TRANSPARENT);
		return (LRESULT)m_CommandBrush.m_hBrush;
	}
	if (hStatic == GetDlgItem(IDC_STATIC_NOTIFY))
	{
		COLORREF Color = m_NotifyText.GetColor();
		if (Color == CLR_DEFAULT)
		{
			Color = m_clDefTextColor;
		}
		::SetTextColor(hdc, Color);
		::SetBkMode(hdc, TRANSPARENT);
		return (LRESULT)m_NotifyBrush.m_hBrush;
	}

	if (hStatic == GetDlgItem(IDC_STATIC_REFLECT))
	{
		COLORREF Color = m_ReflectText.GetColor();
		if (Color == CLR_DEFAULT)
		{
			Color = m_clDefTextColor;
		}
		::SetTextColor(hdc, Color);
		::SetBkMode(hdc, TRANSPARENT);
		return (LRESULT)m_ReflectBrush.m_hBrush;
	}
	return 0;
}

LRESULT CColorSetupDlg::OnWindowColorChange(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
	if (idCtrl == IDC_BUTTON_WINDOWS_BACK_COLOR)
	{
		m_WindowsBrush.DeleteObject();
		COLORREF Color = m_WindowsBack.GetColor();
		if (Color == CLR_DEFAULT)
		{
			Color = m_clDefBackColor;
		}
		m_WindowsBrush.CreateSolidBrush(Color);
	}
	GetDlgItem(IDC_STATIC_WINDOWS).Invalidate();
	return 0;
}

LRESULT CColorSetupDlg::OnCommandColorChange(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
	if (idCtrl == IDC_BUTTON_COMMAND_BACK_COLOR)
	{
		m_CommandBrush.DeleteObject();
		COLORREF Color = m_CommandBack.GetColor();
		if (Color == CLR_DEFAULT)
		{
			Color = m_clDefBackColor;
		}
		m_CommandBrush.CreateSolidBrush(Color);
	}
	GetDlgItem(IDC_STATIC_COMMAND).Invalidate();
	return 0;
}

LRESULT CColorSetupDlg::OnNotifyColorChange(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
	if (idCtrl == IDC_BUTTON_NOTIFY_BACK_COLOR)
	{
		m_NotifyBrush.DeleteObject();
		COLORREF Color = m_NotifyBack.GetColor();
		if (Color == CLR_DEFAULT)
		{
			Color = m_clDefBackColor;
		}
		m_NotifyBrush.CreateSolidBrush(Color);
	}
	GetDlgItem(IDC_STATIC_NOTIFY).Invalidate();
	return 0;
}

LRESULT CColorSetupDlg::OnReflectColorChange(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
	if (idCtrl == IDC_BUTTON_REFLECT_BACK_COLOR)
	{
		m_ReflectBrush.DeleteObject();
		COLORREF Color = m_ReflectBack.GetColor();
		if (Color == CLR_DEFAULT)
		{
			Color = m_clDefBackColor;
		}
		m_ReflectBrush.CreateSolidBrush(Color);
	}
	GetDlgItem(IDC_STATIC_REFLECT).Invalidate();
	return 0;
}

LRESULT CColorSetupDlg::OnButtonReset(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	m_WindowsBack.SetColor(CLR_DEFAULT);
	m_WindowsText.SetColor(CLR_DEFAULT);
	m_CommandText.SetColor(CLR_DEFAULT);
	m_CommandBack.SetColor(CLR_DEFAULT);
	m_NotifyText.SetColor(CLR_DEFAULT);
	m_NotifyBack.SetColor(CLR_DEFAULT);
	OnWindowColorChange(IDC_BUTTON_WINDOWS_BACK_COLOR, NULL, bHandled);
	OnCommandColorChange(IDC_BUTTON_COMMAND_BACK_COLOR, NULL, bHandled);
	OnNotifyColorChange(IDC_BUTTON_NOTIFY_BACK_COLOR, NULL, bHandled);
	return 0;
}

LRESULT CColorSetupDlg::OnImport(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	CFileFilterDialog dlg(TRUE);
	dlg.AddFilter(_T("XML color schema"), _T("*.xml"));
	if (dlg.DoModal() == IDOK)
	{
		CXMLSettingsArchive XMLArchive;
		if (XMLArchive.Open(dlg.m_ofn.lpstrFile))
		{
			if (!LoadSettings(XMLArchive, _T("ColorSchema")))
			{
				MessageBox(_T("Cannot import colors"));
			}
			else
			{
				m_WindowsBack.SetColor(m_clWindowsBack);
				m_WindowsText.SetColor(m_clWindowsText);
				m_CommandText.SetColor(m_clCommandText);
				m_CommandBack.SetColor(m_clCommandBack);
				m_NotifyText.SetColor(m_clNotifyText);
				m_NotifyBack.SetColor(m_clNotifyBack);
				OnWindowColorChange(IDC_BUTTON_WINDOWS_BACK_COLOR, NULL, bHandled);
				OnCommandColorChange(IDC_BUTTON_COMMAND_BACK_COLOR, NULL, bHandled);
				OnNotifyColorChange(IDC_BUTTON_NOTIFY_BACK_COLOR, NULL, bHandled);
			}
			XMLArchive.Close();
		}
		else
		{
			MessageBox(_T("Cannot import colors"));
		}
	}
	return 0;
}

LRESULT CColorSetupDlg::OnExport(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	CFileFilterDialog dlg(FALSE, _T("xml"));
	dlg.AddFilter(_T("XML color schema"), _T("*.xml"));
	if (dlg.DoModal() == IDOK)
	{
		CXMLSettingsArchive XMLArchive;
		if (XMLArchive.Open(dlg.m_ofn.lpstrFile, true))
		{
			if (!SaveSettings(XMLArchive, _T("ColorSchema")))
			{
				MessageBox(_T("Cannot export colors"));
			}
			XMLArchive.Close();
		}
		else
		{
			MessageBox(_T("Cannot export colors"));
		}
	}
	return 0;
}

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

Sergey Solozhentsev
Web Developer
Belarus Belarus
I am a software developer for 3 years.

| Advertise | Privacy | Mobile
Web03 | 2.8.140922.1 | Last Updated 27 Aug 2007
Article Copyright 2004 by Sergey Solozhentsev
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid