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

📄 cscriptbutton.cpp

📁 《脚本驱动的应用软件开发方法与实践》源码
💻 CPP
字号:
//
// CScriptButton.cpp
//
// --------------------------------------------------------
// A Practical Guide to Script-Driven Software Development
// Author: Qiming Lu                        Date: 6/1/2006
// MSN Messager: luqiming26@hotmail.com
// MSN Blog: http://spaces.msn.com/jemylu
// --------------------------------------------------------

#include "stdafx.h"
#include "CScriptButton.h"
#include "DOM2EventTarget.h"
#include "ViewerEvent.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#define kElementBaseID 8800

UINT CScriptButton::sButtonCount = 0;
///////////////////////////////////////////////////////////////////////////////////////////////
CScriptButton::CScriptButton(DOM2EventTarget* pTarget, CString strID, bool bStatic)
	: mTarget(pTarget)
	, mID(strID)
{
	if (bStatic)
	{
		// This is a special button. Its function is: 
		//	simply display an image.
		mStateCount = 1; 
	}
}

CScriptButton::~CScriptButton()
{
}

void CScriptButton::CreateSelf(CWnd* pParent)
{
	UINT ctrlID = kElementBaseID + sButtonCount;
	++sButtonCount;
	Create(mID, WS_CHILD|WS_VISIBLE, CRect(0,0,1,1), pParent, ctrlID);

	LoadButtonImages();
}

void CScriptButton::SetSkinFile(CString const& inFile)
{
	mSkinFileName = inFile;
}

void CScriptButton::SetSkinPosition(long xpos, long ypos)
{
	mSkinXPos = xpos;
	mSkinYPos = ypos;
}

void CScriptButton::TakeClickAction()
{
	if (mTarget)
	{
		ViewerEvent clickEvent("ev_ButtonClicked", (LPCSTR)mID);
		mTarget->dispatchEvent(clickEvent);

#ifdef _DEBUG
	//	::AfxMessageBox("Button <" + mID + "> clicked.");
#endif 
	}
}

⌨️ 快捷键说明

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