⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setwnd.cpp

📁 QQ2009组件管理源码
💻 CPP
字号:
#include "stdafx.h"
#include "setwnd.h"
#include "PluginMgr.h"
#include "bgwnd.h"
#include "basewnd.h"

class CConfigWnd : public CStandardPageWnd, public IListCallbackUI
{
public:
	LPCTSTR GetWindowClassName() const;
	void OnFinalMessage(HWND hWnd);
	LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
	
	// INotifyUI
	virtual void Notify(TNotifyUI& msg);

	// IListCallbackUI
	LPCTSTR GetItemText(CControlUI* pControl, int iIndex, int iSubItem);
	int CompareItem(CControlUI* pList, CControlUI* pItem1, CControlUI* pItem2);

	virtual CControlUI* OnCreateCtrlTree();
};

static HWND hDlgSet=NULL;
static BOOL bFirst=TRUE;
INT_PTR ShowSetDialog(void)
{
	_TRACE_FUNCTION_;
	if (hDlgSet && IsWindow(hDlgSet)) return 0;

	CPaintManagerUI::SetResourceInstance(g_hInstance);
	CConfigWnd* pWindow = new CConfigWnd;
	if( pWindow != NULL ) 
	{
		pWindow->Create(NULL, _T(""), UI_WNDSTYLE_DIALOG & (~(WS_VISIBLE)), WS_EX_WINDOWEDGE,CW_USEDEFAULT,CW_USEDEFAULT,600,480);
		pWindow->CenterWindow();
		pWindow->ShowWindow();
		hDlgSet=pWindow->GetHWND();
	}
	return 0;
}

void CloseSetDialog()
{
	_TRACE_FUNCTION_;
	if (hDlgSet)
	{
		SendMessage(hDlgSet,WM_CLOSE,0,0);
		hDlgSet=NULL;
	}
}

void CConfigWnd::OnFinalMessage(HWND hWnd) 
{
	CStandardPageWnd::OnFinalMessage(hWnd);
	hDlgSet=NULL;
	delete this; 
}

LPCTSTR CConfigWnd::GetWindowClassName() const
{
	return _T("ConfigWnd");
};

LRESULT CConfigWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	return CStandardPageWnd::HandleMessage(uMsg, wParam, lParam);
}

CControlUI* CConfigWnd::OnCreateCtrlTree()
{
	CDialogBuilder builder;
	return builder.CreateFromResource(MAKEINTRESOURCE(IDR_XML2),_T("XML"),this,m_hWnd);
}

void CConfigWnd::Notify(TNotifyUI& msg)
{
	if( msg.sType == _T("windowinit") )
	{
		//获取数据
		g_pluginmgr.AquireDataLock();
		int nEnabledCount=0,nTotalCount=0;
		nTotalCount=g_pluginmgr.GetPluginCount();
		nEnabledCount=g_pluginmgr.GetPlugInEnabledCount();
		g_pluginmgr.ReleaseDataLock();
		
		//设置列表
		CListUI* pList = static_cast<CListUI*>(m_pm.FindControl(_T("pluginlist")));
		if (pList)
		{
			pList->SetTextCallback(this); // We want GetItemText for items
			
			CListTextElementUI* pListElem=NULL;
			for (int i=0;i<nTotalCount;i++)
			{
				pList->Add(new CListTextElementUI);
			}
		}

		//设置标签
		TCHAR szTmp[1024];
		CTextPanelUI* pTxt = static_cast<CTextPanelUI*>(m_pm.FindControl(_T("lblwelcome")));
		if (pTxt)
		{
			wsprintf(szTmp,_T("        ") _T("<b><c #00418C>应用服务 (%d/%d)</c></b>"),nEnabledCount,nTotalCount);
			pTxt->SetText(szTmp);
		}

		pTxt = static_cast<CTextPanelUI*>(m_pm.FindControl(_T("lblcaption")));
		if (pTxt)
		{
			pTxt->SetText(_T(" <b><c #00418C>组件管理</c></b>"));
		}

		pTxt = static_cast<CTextPanelUI*>(m_pm.FindControl(_T("lbltxt")));
		if (pTxt)
		{
			wsprintf(szTmp,_T("欢迎来到组件管理中心!在这里,您可以定制组件选项,调用多项强大的功能,让操作更自由,交流更轻松。\n当前,您已经启用%d项服务,还有更多功能和乐趣等待您的发现哦。"),nEnabledCount);
			pTxt->SetText(szTmp);
		}

		CImagePanelUI* pImg = static_cast<CImagePanelUI*>(m_pm.FindControl(_T("imgwelcome")));
		if (pImg)
		{
			pImg->SetImage(MAKEINTRESOURCE(IDB_BITMAP1));
		}

		CControlUI* pCtrl=m_pm.FindControl(_T("btnset"));
		if (pCtrl)
		{
			pCtrl->SetVisible(FALSE);
		}
		bFirst=TRUE;
		
		CStatusbarUI* pStatus= static_cast<CStatusbarUI*>(m_pm.FindControl(_T("btnstatus")));
		if (pStatus)
		{
			wsprintf(szTmp,_T("版本: %s"),COMMGR_VERSION);
			pStatus->SetText(szTmp);
		}
		return;
	}
	if ( msg.sType == _T("itemselect"))
	{
		if (msg.pSender->GetName() == _T("pluginlist"))
		{
			CListUI* pList = static_cast<CListUI*>(msg.pSender);
			int nCursel=pList->GetCurSel();
			g_pluginmgr.AquireDataLock();
			if (nCursel>=0 && nCursel<g_pluginmgr.GetPluginCount())
			{
				const COMINFO& itsel=g_pluginmgr.GetPlugin(nCursel);
				BOOL bDisable=itsel.bDisable;
				if (!QQinterface::IsHooked()) bDisable=FALSE;//Hook 失败
				std_str stmp;
				stmp=itsel.strfriendlyname;
				if (stmp.empty()) stmp=itsel.strname;

				CTextPanelUI* pTxt = static_cast<CTextPanelUI*>(m_pm.FindControl(_T("lblcaption")));
				if (pTxt)
				{
					TCHAR szTmp[1024];
					wsprintf(szTmp,_T(" <b><c #00418C>%s</c></b>"),stmp.c_str());
					pTxt->SetText(szTmp);
				}

				pTxt = static_cast<CTextPanelUI*>(m_pm.FindControl(_T("lbltxt")));
				if (pTxt)
				{
					pTxt->SetText(itsel.strdescription.c_str());
				}
				
				CControlUI* pCtrl=m_pm.FindControl(_T("btnset"));
				if (pCtrl)
				{
					if (bFirst)
					{
						pCtrl->SetVisible(TRUE);
						bFirst=FALSE;
					}
					pCtrl->SetText(bDisable?_T("启用(&E)"):_T("停用(&E)"));
				}

				CStatusbarUI* pStatus= static_cast<CStatusbarUI*>(m_pm.FindControl(_T("btnstatus")));
				if (pStatus)
				{
					TCHAR szTmp[1024];
					*szTmp=0;
					if (bDisable && itsel.strwarning.length())
					{
						wsprintf(szTmp,_T("<I %d> <c #556E80>%s</c>"),IDI_ICON4,itsel.strwarning.c_str());
					}
					pStatus->SetText(szTmp);
				}

			}
			g_pluginmgr.ReleaseDataLock();
			m_pm.UpdateLayout();//更新控件显示
			return;
		}
	}
	if ( msg.sType == _T("click"))
	{
		if (msg.pSender->GetName() == _T("btnset"))
		{
			if (!QQinterface::IsHooked())
			{
				MessageBox(m_hWnd,_T("您的版本无法识别,请更新!"),_T("提示"),MB_ICONINFORMATION);
				ShellExecute(m_hWnd,_T("open"),_T("http://231la.com"),NULL,NULL,SW_NORMAL);
				return;
			}
			int nCursel=-1;
			CListUI* pList = static_cast<CListUI*>(m_pm.FindControl(_T("pluginlist")));
			if (pList)
			{
				nCursel=pList->GetCurSel();
				pList->SetFocus();
			}
			g_pluginmgr.AquireDataLock();
			if (nCursel!=-1 && nCursel<g_pluginmgr.GetPluginCount())
			{
				const COMINFO& itsel=g_pluginmgr.GetPlugin(nCursel);
				BOOL bDisable=itsel.bDisable?FALSE:TRUE;
				if (!QQinterface::IsHooked()) bDisable=FALSE;//Hook 失败

				g_pluginmgr.UpdatePluginStatus(nCursel,bDisable);
//				pList->UpdateLayout();//刷新显示
				
				int nEnabledCount=0,nTotalCount=0;
				nTotalCount=g_pluginmgr.GetPluginCount();
				nEnabledCount=g_pluginmgr.GetPlugInEnabledCount();
				
				CTextPanelUI* pTxt = static_cast<CTextPanelUI*>(m_pm.FindControl(_T("lblwelcome")));
				if (pTxt)
				{
					TCHAR szTmp[1024];
					wsprintf(szTmp,_T("        ") _T("<b><c #00418C>应用服务 (%d/%d)</c></b>"),nEnabledCount,nTotalCount);
					pTxt->SetText(szTmp);
				}

				CControlUI* pCtrl=m_pm.FindControl(_T("btnset"));
				if (pCtrl)
				{
					pCtrl->SetText(bDisable?_T("启用(&E)"):_T("停用(&E)"));
				}
				
				CStatusbarUI* pStatus= static_cast<CStatusbarUI*>(m_pm.FindControl(_T("btnstatus")));
				if (pStatus)
				{
					TCHAR szTmp[1024];
					*szTmp=0;
					if (bDisable && itsel.strwarning.length())
					{
						wsprintf(szTmp,_T("<I %d> <c #556E80>%s</c>"),IDI_ICON4,itsel.strwarning.c_str());
					}
					pStatus->SetText(szTmp);
				}
				
				std_str stmp;
				stmp=itsel.strname;
				if (bDisable)
					QQinterface::DisablePlugIn(stmp.c_str());
				else
					QQinterface::EnablePlugIn(stmp.c_str());
			}
			g_pluginmgr.ReleaseDataLock();
			m_pm.UpdateLayout();//更新控件显示
			return;
		}
	}
}

LPCTSTR CConfigWnd::GetItemText(CControlUI* pControl, int iIndex, int iSubItem)
{
	static TCHAR szTmp[30]={0};
	LPCTSTR pName=_T("");
	g_pluginmgr.AquireDataLock();
	const COMINFO& ci=g_pluginmgr.GetPlugin(iIndex);
	if (iSubItem==0)
	{
		if (ci.strfriendlyname.empty())
			pName=ci.strname.c_str();
		else
			pName=ci.strfriendlyname.c_str();
	}
	else
	{
		if (ci.bDisable && QQinterface::IsHooked())
		{
			wsprintf(szTmp,_T("<I %d> %s"),IDI_ICON2,_T("已禁用"));
		}
		else
		{
			wsprintf(szTmp,_T("<I %d> %s"),IDI_ICON3,_T("已启用"));
		}
		pName=szTmp;
	}
	g_pluginmgr.ReleaseDataLock();

	return pName;
}

int CConfigWnd::CompareItem(CControlUI* pList, CControlUI* pItem1, CControlUI* pItem2)
{
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -