diff options
Diffstat (limited to 'plugins/SendScreenshotPlus/src/UAboutForm.cpp')
| -rw-r--r-- | plugins/SendScreenshotPlus/src/UAboutForm.cpp | 414 | 
1 files changed, 213 insertions, 201 deletions
diff --git a/plugins/SendScreenshotPlus/src/UAboutForm.cpp b/plugins/SendScreenshotPlus/src/UAboutForm.cpp index 0b112a3803..98a533d4ab 100644 --- a/plugins/SendScreenshotPlus/src/UAboutForm.cpp +++ b/plugins/SendScreenshotPlus/src/UAboutForm.cpp @@ -1,201 +1,213 @@ -/*
 -
 -Miranda IM: the free IM client for Microsoft* Windows*
 -Copyright 2000-2009 Miranda ICQ/IM project, 
 -
 -This file is part of Send Screenshot Plus, a Miranda IM plugin.
 -Copyright (c) 2010 Ing.U.Horn
 -
 -Parts of this file based on original sorce code
 -(c) 2004-2006 Sérgio Vieira Rolanski (portet from Borland C++)
 -
 -This program is free software; you can redistribute it and/or
 -modify it under the terms of the GNU General Public License
 -as published by the Free Software Foundation; either version 2
 -of the License, or (at your option) any later version.
 -
 -This program is distributed in the hope that it will be useful,
 -but WITHOUT ANY WARRANTY; without even the implied warranty of
 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 -See the GNU General Public License for more details.
 -
 -You should have received a copy of the GNU General Public License
 -along with this program; if not, write to the Free Software
 -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 -*/
 -
 -#include "global.h"
 -
 -//---------------------------------------------------------------------------
 -TfrmAbout::CHandleMapping TfrmAbout::_HandleMapping;
 -
 -INT_PTR CALLBACK TfrmAbout::DlgTfrmAbout(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 -{
 -	if (msg == WM_CTLCOLOREDIT || msg == WM_CTLCOLORSTATIC) {
 -		switch ( GetWindowLongPtr(( HWND )lParam, GWL_ID )) {
 -			case IDC_WHITERECT:
 -			case IDC_CREDIT:
 -			case IDC_LICENSE:
 -				SetTextColor((HDC)wParam,GetSysColor(COLOR_WINDOWTEXT));
 -				break;
 -			default:
 -				return FALSE;
 -		}
 -		SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
 -		return (LRESULT)GetStockObject(WHITE_BRUSH); 	//GetSysColorBrush(COLOR_WINDOW);
 -	}
 -
 -	CHandleMapping::iterator wnd(_HandleMapping.end());
 -	if (msg == WM_INITDIALOG) {
 -		wnd = _HandleMapping.insert(CHandleMapping::value_type(hWnd, reinterpret_cast<TfrmAbout*>(lParam))).first;
 -		reinterpret_cast<TfrmAbout*>(lParam)->m_hWnd = hWnd;
 -		return wnd->second->wmInitdialog(wParam, lParam);
 -	}
 -	else {
 -		wnd = _HandleMapping.find(hWnd);
 -	}
 -	if (wnd == _HandleMapping.end()) {	// something screwed up
 -		return FALSE;					//dialog! do not use ::DefWindowProc(hWnd, msg, wParam, lParam);
 -	}
 -
 -	switch (msg)
 -	{
 -		// case WM_INITDIALOG:	done on top
 -		case WM_COMMAND:
 -			return wnd->second->wmCommand(wParam, lParam);
 -			break;
 -		case WM_CLOSE:
 -			return wnd->second->wmClose(wParam, lParam);
 -			break;
 -		case WM_DESTROY:
 -			delete wnd->second;
 -			break;
 -	}
 -	return FALSE;
 -}
 -
 -//---------------------------------------------------------------------------
 -//WM_INITDIALOG:
 -LRESULT TfrmAbout::wmInitdialog(WPARAM wParam, LPARAM lParam) {
 -	char* pszMsg = NULL;
 -	HRSRC hResInfo;
 -	DWORD ResSize;
 -	TCHAR oldTitle[256], newTitle[256];
 -	LPTSTR temp = NULL;
 -	LPTSTR pszTitle = NULL;
 -	// Headerbar
 -	LPTSTR pszPlug = mir_a2t(__PLUGIN_NAME);
 -	LPTSTR pszVer  = mir_a2t(__VERSION_STRING);
 -	GetDlgItemText( m_hWnd, IDC_HEADERBAR, oldTitle, SIZEOF( oldTitle ));
 -	mir_sntprintf( newTitle, SIZEOF(newTitle), oldTitle, pszPlug, pszVer );
 -	mir_freeAndNil(pszPlug);
 -	mir_freeAndNil(pszVer);
 -	SetDlgItemText( m_hWnd, IDC_HEADERBAR, newTitle );
 -	SendMessage(GetDlgItem(m_hWnd, IDC_HEADERBAR), WM_SETICON, 0, (WPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true));
 -
 -	//License
 -	{	mir_tcsadd(pszTitle ,_T(__COPYRIGHT));
 -		mir_tcsadd(pszTitle ,_T("\r\n\r\n"));
 -
 -		hResInfo = FindResource(hInst,MAKEINTRESOURCE(IDR_LICENSE),_T("TEXT"));
 -		ResSize  = SizeofResource(hInst,hResInfo);
 -		pszMsg   = (char*)LockResource(LoadResource(hInst,hResInfo));
 -		temp = mir_a2t(pszMsg);
 -		temp [ResSize] = 0;			//LockResource is not NULL terminatet !!
 -		mir_tcsadd(pszTitle ,temp);
 -		mir_freeAndNil(temp);
 -		SetDlgItemText(m_hWnd,IDC_LICENSE, pszTitle);
 -		mir_freeAndNil(pszTitle);
 -	}
 -
 -	//Credit
 -	{
 -		hResInfo = FindResource(hInst,MAKEINTRESOURCE(IDR_CREDIT),_T("TEXT"));
 -		ResSize  = SizeofResource(hInst,hResInfo);
 -		pszMsg   = (char*)LockResource(LoadResource(hInst,hResInfo));
 -		temp = mir_a2t(pszMsg);
 -		temp [ResSize] = 0;			//LockResource is not NULL terminatet !!
 -		mir_tcsadd(pszTitle ,temp);
 -		mir_freeAndNil(temp);
 -		SetDlgItemText(m_hWnd,IDC_CREDIT, pszTitle);
 -		mir_freeAndNil(pszTitle);
 -	}
 -
 -	SendMessage(m_hWnd, WM_SETICON, ICON_BIG,	(LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true));
 -	SendMessage(m_hWnd, WM_SETICON, ICON_SMALL,	(LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW2));
 -
 -	//init controls
 -	btnPageClick();
 -	SendMessage(GetDlgItem(m_hWnd, IDA_CONTRIBLINK), BUTTONSETDEFAULT, (WPARAM)1, NULL);
 -
 -	TranslateDialogDefault(m_hWnd);
 -	return FALSE;
 -}
 -
 -//WM_COMMAND:
 -LRESULT TfrmAbout::wmCommand(WPARAM wParam, LPARAM lParam) {
 -	//---------------------------------------------------------------------------
 -	if (HIWORD(wParam) == BN_CLICKED) {
 -		int IDControl = LOWORD(wParam);
 -		HWND hCtrl = (HWND)lParam;
 -		switch(IDControl) {
 -			case IDCANCEL:
 -			case IDCLOSE:
 -				break;
 -			case IDA_btnClose:
 -				Close();
 -				break;
 -			case IDA_CONTRIBLINK:
 -				m_Page = m_Page ? 0 : 1;
 -				btnPageClick();
 -				break;
 -			default:
 -				break;
 -		}
 -	}
 -	return FALSE;
 -}
 -
 -//WM_CLOSE:
 -LRESULT TfrmAbout::wmClose(WPARAM wParam, LPARAM lParam) {
 -	SendMessage(m_hWndOwner,UM_CLOSING, (WPARAM)m_hWnd, (LPARAM)IDD_UAboutForm);
 -	DestroyWindow(m_hWnd);
 -	return FALSE;
 -}
 -
 -//---------------------------------------------------------------------------
 -// Standard konstruktor/destruktor
 -TfrmAbout::TfrmAbout(HWND Owner) {
 -	m_hWndOwner = Owner;
 -	// create window
 -	m_hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_UAboutForm),0, DlgTfrmAbout,(LPARAM)this);
 -	//register object
 -	_HandleMapping.insert(CHandleMapping::value_type(m_hWnd, this));
 -	//init page
 -	m_Page	= 1;
 -}
 -
 -TfrmAbout::~TfrmAbout() {
 -	_HandleMapping.erase(m_hWnd);
 -}
 -
 -//---------------------------------------------------------------------------
 -void TfrmAbout::btnPageClick() {
 -	HWND hCtrl = GetDlgItem(m_hWnd, IDA_CONTRIBLINK);
 -	if(!m_Page) {
 -		ShowWindow(GetDlgItem(m_hWnd, IDC_CREDIT), SW_HIDE);
 -		ShowWindow(GetDlgItem(m_hWnd, IDC_LICENSE), SW_SHOW);
 -		SendDlgItemMessage(m_hWnd, IDA_CONTRIBLINK, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Credits >"), MBBF_TCHAR);
 -		HICON hIcon = IcoLib_GetIcon(ICO_PLUG_ARROWR);
 -		SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
 -		SetWindowText(hCtrl, hIcon ? TranslateT("Credits") : TranslateT("Credits >"));
 -	}
 -	else {
 -		ShowWindow(GetDlgItem(m_hWnd, IDC_CREDIT), SW_SHOW);
 -		ShowWindow(GetDlgItem(m_hWnd, IDC_LICENSE), SW_HIDE);
 -		SendDlgItemMessage(m_hWnd, IDA_CONTRIBLINK, BUTTONADDTOOLTIP, (WPARAM)TranslateT("< Copyright"), MBBF_TCHAR);
 -		HICON hIcon = IcoLib_GetIcon(ICO_PLUG_ARROWL);
 -		SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
 -		SetWindowText(hCtrl, hIcon ? TranslateT("Copyright") : TranslateT("< Copyright"));
 -	}
 -}
 +/* + +Miranda IM: the free IM client for Microsoft* Windows* +Copyright 2000-2009 Miranda ICQ/IM project,  + +This file is part of Send Screenshot Plus, a Miranda IM plugin. +Copyright (c) 2010 Ing.U.Horn + +Parts of this file based on original sorce code +(c) 2004-2006 Sérgio Vieira Rolanski (portet from Borland C++) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "global.h" + +#include <list> +void TfrmAbout::Unload(){ +	std::list<TfrmAbout*> lst; +	for(CHandleMapping::iterator iter=_HandleMapping.begin(); iter!=_HandleMapping.end(); ++iter){ +		lst.push_back(iter->second);//we can't delete inside loop.. not MT compatible +	} +	while(!lst.empty()){ +		DestroyWindow(lst.front()->m_hWnd);//deletes class +		lst.pop_front(); +	} +} + +//--------------------------------------------------------------------------- +TfrmAbout::CHandleMapping TfrmAbout::_HandleMapping; + +INT_PTR CALLBACK TfrmAbout::DlgTfrmAbout(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ +	if (msg == WM_CTLCOLOREDIT || msg == WM_CTLCOLORSTATIC) { +		switch ( GetWindowLongPtr(( HWND )lParam, GWL_ID )) { +			case IDC_WHITERECT: +			case IDC_CREDIT: +			case IDC_LICENSE: +				SetTextColor((HDC)wParam,GetSysColor(COLOR_WINDOWTEXT)); +				break; +			default: +				return FALSE; +		} +		SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW)); +		return (LRESULT)GetStockObject(WHITE_BRUSH); 	//GetSysColorBrush(COLOR_WINDOW); +	} + +	CHandleMapping::iterator wnd(_HandleMapping.end()); +	if (msg == WM_INITDIALOG) { +		wnd = _HandleMapping.insert(CHandleMapping::value_type(hWnd, reinterpret_cast<TfrmAbout*>(lParam))).first; +		reinterpret_cast<TfrmAbout*>(lParam)->m_hWnd = hWnd; +		return wnd->second->wmInitdialog(wParam, lParam); +	} +	else { +		wnd = _HandleMapping.find(hWnd); +	} +	if (wnd == _HandleMapping.end()) {	// something screwed up +		return FALSE;					//dialog! do not use ::DefWindowProc(hWnd, msg, wParam, lParam); +	} + +	switch (msg) +	{ +		// case WM_INITDIALOG:	done on top +		case WM_COMMAND: +			return wnd->second->wmCommand(wParam, lParam); +			break; +		case WM_CLOSE: +			return wnd->second->wmClose(wParam, lParam); +			break; +		case WM_DESTROY: +			delete wnd->second; +			break; +	} +	return FALSE; +} + +//--------------------------------------------------------------------------- +//WM_INITDIALOG: +LRESULT TfrmAbout::wmInitdialog(WPARAM wParam, LPARAM lParam) { +	char* pszMsg = NULL; +	HRSRC hResInfo; +	DWORD ResSize; +	TCHAR oldTitle[256], newTitle[256]; +	LPTSTR temp = NULL; +	LPTSTR pszTitle = NULL; +	// Headerbar +	LPTSTR pszPlug = mir_a2t(__PLUGIN_NAME); +	LPTSTR pszVer  = mir_a2t(__VERSION_STRING); +	GetDlgItemText( m_hWnd, IDC_HEADERBAR, oldTitle, SIZEOF( oldTitle )); +	mir_sntprintf( newTitle, SIZEOF(newTitle), oldTitle, pszPlug, pszVer ); +	mir_freeAndNil(pszPlug); +	mir_freeAndNil(pszVer); +	SetDlgItemText( m_hWnd, IDC_HEADERBAR, newTitle ); +	SendMessage(GetDlgItem(m_hWnd, IDC_HEADERBAR), WM_SETICON, 0, (WPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true)); + +	//License +	{	mir_tcsadd(pszTitle ,_T(__COPYRIGHT)); +		mir_tcsadd(pszTitle ,_T("\r\n\r\n")); + +		hResInfo = FindResource(hInst,MAKEINTRESOURCE(IDR_LICENSE),_T("TEXT")); +		ResSize  = SizeofResource(hInst,hResInfo); +		pszMsg   = (char*)LockResource(LoadResource(hInst,hResInfo)); +		temp = mir_a2t(pszMsg); +		temp [ResSize] = 0;			//LockResource is not NULL terminatet !! +		mir_tcsadd(pszTitle ,temp); +		mir_freeAndNil(temp); +		SetDlgItemText(m_hWnd,IDC_LICENSE, pszTitle); +		mir_freeAndNil(pszTitle); +	} + +	//Credit +	{ +		hResInfo = FindResource(hInst,MAKEINTRESOURCE(IDR_CREDIT),_T("TEXT")); +		ResSize  = SizeofResource(hInst,hResInfo); +		pszMsg   = (char*)LockResource(LoadResource(hInst,hResInfo)); +		temp = mir_a2t(pszMsg); +		temp [ResSize] = 0;			//LockResource is not NULL terminatet !! +		mir_tcsadd(pszTitle ,temp); +		mir_freeAndNil(temp); +		SetDlgItemText(m_hWnd,IDC_CREDIT, pszTitle); +		mir_freeAndNil(pszTitle); +	} + +	SendMessage(m_hWnd, WM_SETICON, ICON_BIG,	(LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW1, true)); +	SendMessage(m_hWnd, WM_SETICON, ICON_SMALL,	(LPARAM)IcoLib_GetIcon(ICO_PLUG_SSWINDOW2)); + +	//init controls +	btnPageClick(); +	SendMessage(GetDlgItem(m_hWnd, IDA_CONTRIBLINK), BUTTONSETDEFAULT, (WPARAM)1, NULL); + +	TranslateDialogDefault(m_hWnd); +	return FALSE; +} + +//WM_COMMAND: +LRESULT TfrmAbout::wmCommand(WPARAM wParam, LPARAM lParam) { +	//--------------------------------------------------------------------------- +	if (HIWORD(wParam) == BN_CLICKED) { +		int IDControl = LOWORD(wParam); +		HWND hCtrl = (HWND)lParam; +		switch(IDControl) { +			case IDCANCEL: +			case IDCLOSE: +				break; +			case IDA_btnClose: +				Close(); +				break; +			case IDA_CONTRIBLINK: +				m_Page = m_Page ? 0 : 1; +				btnPageClick(); +				break; +			default: +				break; +		} +	} +	return FALSE; +} + +//WM_CLOSE: +LRESULT TfrmAbout::wmClose(WPARAM wParam, LPARAM lParam) { +	SendMessage(m_hWndOwner,UM_CLOSING, (WPARAM)m_hWnd, (LPARAM)IDD_UAboutForm); +	DestroyWindow(m_hWnd); +	return FALSE; +} + +//--------------------------------------------------------------------------- +// Standard konstruktor/destruktor +TfrmAbout::TfrmAbout(HWND Owner) { +	m_hWndOwner = Owner; +	// create window +	m_hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_UAboutForm),0, DlgTfrmAbout,(LPARAM)this); +	//register object +	_HandleMapping.insert(CHandleMapping::value_type(m_hWnd, this)); +	//init page +	m_Page	= 1; +} + +TfrmAbout::~TfrmAbout() { +	_HandleMapping.erase(m_hWnd); +} + +//--------------------------------------------------------------------------- +void TfrmAbout::btnPageClick() { +	HWND hCtrl = GetDlgItem(m_hWnd, IDA_CONTRIBLINK); +	if(!m_Page) { +		ShowWindow(GetDlgItem(m_hWnd, IDC_CREDIT), SW_HIDE); +		ShowWindow(GetDlgItem(m_hWnd, IDC_LICENSE), SW_SHOW); +		SendDlgItemMessage(m_hWnd, IDA_CONTRIBLINK, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Credits >"), MBBF_TCHAR); +		HICON hIcon = IcoLib_GetIcon(ICO_PLUG_ARROWR); +		SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); +		SetWindowText(hCtrl, hIcon ? TranslateT("Credits") : TranslateT("Credits >")); +	} +	else { +		ShowWindow(GetDlgItem(m_hWnd, IDC_CREDIT), SW_SHOW); +		ShowWindow(GetDlgItem(m_hWnd, IDC_LICENSE), SW_HIDE); +		SendDlgItemMessage(m_hWnd, IDA_CONTRIBLINK, BUTTONADDTOOLTIP, (WPARAM)TranslateT("< Copyright"), MBBF_TCHAR); +		HICON hIcon = IcoLib_GetIcon(ICO_PLUG_ARROWL); +		SendMessage(hCtrl, BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); +		SetWindowText(hCtrl, hIcon ? TranslateT("Copyright") : TranslateT("< Copyright")); +	} +}  | 
