📄 baseobject.cpp
字号:
#include "StdAfx.h"
#include ".\baseobject.h"
CBaseObject::CBaseObject(void)
{
ZeroMemory(m_szName, MAX_NAME);
ZeroMemory(&m_Basal, sizeof(m_Basal));
m_enBaseType = Type_Null;
m_pParent = NULL;
m_bVisabled = true;
m_bDisabled = false;
}
CBaseObject::~CBaseObject(void)
{
}
//设置父对象
void CBaseObject::SetParent(IUnknownEx* pIUnknownEx){
m_pParent = pIUnknownEx;
}
//返回父对象
IUnknownEx* CBaseObject::GetParent(){
return m_pParent;
}
//设置类型
void CBaseObject::SetBaseType(enBaseObjectType enType){
m_enBaseType = enType;
}
//返回类型
enBaseObjectType CBaseObject::GetBaseType(){
return m_enBaseType;
}
//设置名字
void CBaseObject::SetObjectName(LPCTSTR lpName){
memcpy(&m_szName, lpName, MAX_NAME);
}
//获取名字
LPCTSTR CBaseObject::GetObjectName(){
return m_szName;
}
//设置可视
void CBaseObject::SetVisabled(bool bFlag){
m_bVisabled = bFlag;
}
//设置禁用
void CBaseObject::SetDisabled(bool bFlag){
m_bDisabled = bFlag;
}
//是否可视
bool CBaseObject::IsVisabled(){
return m_bVisabled;
}
//是否禁用
bool CBaseObject::IsDisabled(){
return m_bDisabled;
}
//返回深度
DWORD CBaseObject::GetDepth(){
return m_Basal.Depth;
}
//设置深度
void CBaseObject::SetDepth(DWORD dwDepth){
m_Basal.Depth = dwDepth;
}
//设置中心
void CBaseObject::SetAnchorPosition(POINT piPoint){
m_Basal.AnchorPos.x = piPoint.x;
m_Basal.AnchorPos.y = piPoint.y;
}
//返回大小
void CBaseObject::SetSize(RECT rcRect){
m_Basal.Size.left = rcRect.left;
m_Basal.Size.top = rcRect.top;
m_Basal.Size.right = rcRect.right;
m_Basal.Size.bottom = rcRect.bottom;
}
//返回大小
RECT CBaseObject::GetSize(){
return m_Basal.Size;
}
//返回基本信息
BASALINFO& CBaseObject::GetBasalInfo(){
return m_Basal;
}
//移动对象
void CBaseObject::MoveTo(POINT piPoint){
m_Basal.LocalPos.x = piPoint.x;
m_Basal.LocalPos.y = piPoint.y;
m_Basal.ScreenPos.x = m_Basal.LocalPos.x + m_Basal.ContainerPos.x;
m_Basal.ScreenPos.y = m_Basal.LocalPos.y + m_Basal.ContainerPos.y;
}
//返回对象坐标相对于屏幕
POINT CBaseObject::GetScreenPosition(){
return m_Basal.ScreenPos;
}
//返回对象相对于容器的坐标
POINT CBaseObject::GetLocalPosition(){
return m_Basal.LocalPos;
}
//返回对象容器坐标
POINT CBaseObject::GetContainerPosition(){
return m_Basal.ContainerPos;
}
// 返回对象容器坐标
POINT CBaseObject::GetAnchorPosition(){
return m_Basal.AnchorPos;
}
// 返回对象容器坐标
POINT CBaseObject::CalcContainerPosition(){
POINT piContainerPos;
piContainerPos.x = piContainerPos.y = 0;
if(m_pParent!=NULL){
IBaseObject* lpBaseObject = (IBaseObject*)m_pParent->QueryInterface(IID_IBaseObject, VER_IBaseObject);
if(lpBaseObject!=NULL){
piContainerPos = lpBaseObject->CalcContainerPosition();
}
}
return piContainerPos;
}
void* CBaseObject::QueryInterface(const IID &Guid, DWORD dwQueryVer){
QUERYINTERFACE(IBaseObject,Guid,dwQueryVer);
QUERYINTERFACE_IUNKNOWNEX(IBaseObject,Guid,dwQueryVer);
return NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -