// MBEmotionsWnd.cpp : implementation file
|
//
|
|
#include "stdafx.h"
|
#include "mbamui.h"
|
#include "MBGroupUserinfoWnd.h"
|
#include "MBAMWnd.h"
|
|
|
// CMBGroupUserinfoWnd
|
|
CMBGroupUserinfoWnd::CMBGroupUserinfoWnd() : SHostWnd(_T("LAYOUT:XML_GROUPUSERINFOWND"))
|
{
|
m_bLayoutInited = FALSE;
|
m_pServerMgr = NULL;
|
m_pUserLogin = NULL;
|
m_pMBAMWnd= NULL;
|
}
|
|
CMBGroupUserinfoWnd::~CMBGroupUserinfoWnd()
|
{
|
|
}
|
BOOL CMBGroupUserinfoWnd::OnInitDialog(HWND wndFocus, LPARAM lInitParam)
|
{
|
m_cxStart = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
m_cyStart = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
m_cxScreen = GetSystemMetrics( SM_CXVIRTUALSCREEN );
|
m_cyScreen = GetSystemMetrics( SM_CYVIRTUALSCREEN );
|
|
m_bLayoutInited = TRUE;
|
if( !m_itemUser.m_strLoginName.IsEmpty())
|
{
|
SetUser(m_itemUser);
|
}
|
|
return TRUE;
|
}
|
void CMBGroupUserinfoWnd::SetUser( CMBOrgUser &itemUser )
|
{
|
m_itemUser = itemUser;
|
if( !m_bLayoutInited)
|
return;
|
CString strLogin = _T("");
|
if(m_pUserLogin)
|
strLogin = m_pUserLogin->m_strLoginName;
|
SStatic *pTxt = FindChildByName2<SStatic>(_T("text_username"));
|
if(pTxt)
|
pTxt->SetWindowText(m_itemUser.m_strUserName);
|
pTxt = FindChildByName2<SStatic>(_T("text_loginname"));
|
if(pTxt)
|
pTxt->SetWindowText(m_itemUser.m_strLoginName);
|
|
SWindow *pWnd = FindChildByName2<SWindow>(_T("wnd_depart"));
|
if(m_itemUser.m_strDeptInfo.IsEmpty() && m_itemUser.m_strUnitInfo.IsEmpty())
|
{
|
if(pWnd)
|
pWnd->SetAttribute(L"visible", L"0");
|
}
|
else
|
{
|
if(pWnd)
|
pWnd->SetAttribute(L"visible", L"1");
|
pTxt = FindChildByName2<SStatic>(_T("text_depart"));
|
if(pTxt)
|
{
|
if(m_itemUser.m_strDeptInfo.IsEmpty())
|
pTxt->SetWindowText(m_itemUser.m_strDeptInfo);
|
else
|
pTxt->SetWindowText(m_itemUser.m_strUnitInfo);
|
}
|
}
|
pWnd = FindChildByName2<SWindow>(_T("wnd_place"));
|
if(m_itemUser.m_strPlace.IsEmpty())
|
{
|
if(pWnd)
|
pWnd->SetAttribute(L"visible", L"0");
|
}
|
else
|
{
|
if(pWnd)
|
pWnd->SetAttribute(L"visible", L"1");
|
pTxt = FindChildByName2<SStatic>(_T("text_place"));
|
}
|
if(pTxt)
|
pTxt->SetWindowText(m_itemUser.m_strPlace);
|
|
SStringW strSkin = _T("");
|
int nSex = 0;
|
nSex = _tstol(m_itemUser.m_strSex);
|
if(nSex == 1)
|
strSkin = _T("skin_user_mans");
|
else if(nSex == 1)
|
strSkin = _T("skin_user_womans");
|
else
|
strSkin = _T("skin_user_small");
|
SImageWndEx *pImg = FindChildByName2<SImageWndEx>(_T("img_usersex"));
|
SASSERT(pImg);
|
pImg->SetImage(NULL);
|
pImg->SetSkin(GETSKIN(strSkin, pImg->GetScale()));
|
|
pImg = FindChildByName2<SImageWndEx>(_T("img_userpic"));
|
SASSERT(pImg);
|
IBitmap * pBmp = GetMBOrgUserPhoto(m_itemUser.m_strLoginName,m_itemUser.m_strSex );
|
if( pBmp )
|
{
|
pImg->SetImage(pBmp,FilterLevel::kHigh_FilterLevel);
|
}else{
|
pImg->SetImage(NULL);
|
pImg->SetSkin(GETSKIN(strSkin, pImg->GetScale()));
|
}
|
|
SImageButton *pImgButton = FindChildByName2<SImageButton>(_T("btn_chat"));
|
if(pImgButton)
|
{
|
if(strLogin.CompareNoCase(m_itemUser.m_strLoginName) == 0)
|
pImgButton->SetAttribute(L"visible", L"0");
|
else
|
pImgButton->SetAttribute(L"visible", L"1");
|
}
|
/*CString strText ;
|
pTxt = FindChildByName2<SStatic>(_T("text_username"));
|
if(pTxt)
|
{
|
strText = pTxt->GetWindowText();
|
strText += _T("1");
|
pTxt->SetWindowText(strText);
|
}*/
|
KillTimer(WM_TIMER_SHOWWND);
|
SetTimer(WM_TIMER_SHOWWND,200);
|
}
|
void CMBGroupUserinfoWnd::SetServerMgrPtr( CMBServerMgr *pMBServerMgr )
|
{
|
m_pServerMgr = pMBServerMgr;
|
m_pUserLogin = pMBServerMgr->GetUserLogin();
|
}
|
void CMBGroupUserinfoWnd::SetAMWndPtr( CMBAMWnd *pMBAMWnd )
|
{
|
m_pMBAMWnd = pMBAMWnd;
|
}
|
void CMBGroupUserinfoWnd::SetParentWnd( HWND hParentWnd )
|
{
|
m_hParentWnd = hParentWnd;
|
}
|
void CMBGroupUserinfoWnd::OnClose()
|
{
|
ShowWindow(SW_HIDE);
|
}
|
// µãÔÚ´°¿ÚÖÐ
|
bool CMBGroupUserinfoWnd::IsInWnd( SOUI::CPoint pt )
|
{
|
if(!IsWindowVisible())
|
return false;
|
|
//::ScreenToClient(m_hParentWnd,&pt);
|
|
SOUI::CRect rect = GetClientRect();
|
ClientToScreen(&rect);
|
|
if(rect.PtInRect(pt))
|
return true;
|
return false;
|
}
|
|
void CMBGroupUserinfoWnd::ShowWnd()
|
{
|
SOUI::CPoint pt;
|
::GetCursorPos(&pt);
|
/*CString strText ;
|
SStatic *pTxt = FindChildByName2<SStatic>(_T("text_username"));
|
if(pTxt)
|
{
|
strText = pTxt->GetWindowText();
|
strText += _T("2");
|
pTxt->SetWindowText(strText);
|
}*/
|
if(pt.x + 270 > m_cxScreen + m_cxStart)
|
{
|
pt.x -= 270;
|
}
|
if(pt.y + 180 > m_cyScreen + m_cyStart)
|
{
|
pt.y -= 180;
|
}
|
::SetWindowPos(m_hWnd, NULL, pt.x,pt.y, 270,180, SWP_SHOWWINDOW);
|
ShowWindow(SW_SHOW);
|
}
|
|
// Òþ²Ø´°¿Ú
|
void CMBGroupUserinfoWnd::HideWnd()
|
{
|
|
ShowWindow(SW_HIDE);
|
//KillTimer(TIMER_HIDEWND);
|
}
|
void CMBGroupUserinfoWnd::OnUserChat()
|
{
|
ShowWindow(SW_HIDE);
|
if(m_pMBAMWnd)
|
m_pMBAMWnd->ShowAMUserChat(m_itemUser.m_strLoginName,m_itemUser.m_strUserName);
|
|
SStatic *pTxt = FindChildByName2<SStatic>(_T("text_username"));
|
if(pTxt)
|
pTxt->SetWindowText(_T(""));
|
}
|
void CMBGroupUserinfoWnd::OnActivate(UINT nState, BOOL bMinimized, HWND wndOther)
|
{
|
// TODO: Add your message handler code here
|
if(nState == WA_INACTIVE && IsWindowVisible())
|
{
|
//HWND hActvie = ::GetActiveWindow();
|
ShowWindow(SW_HIDE);
|
/*CString strText ;
|
SStatic *pTxt = FindChildByName2<SStatic>(_T("text_username"));
|
if(pTxt)
|
{
|
strText = pTxt->GetWindowText();
|
strText += _T("3");
|
pTxt->SetWindowText(strText);
|
}*/
|
if(wndOther == m_hParentWnd)
|
{
|
::SetWindowPos(m_hParentWnd, NULL, 0,0,0,0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
|
}
|
}
|
}
|
void CMBGroupUserinfoWnd::GetUserPicturePath( CString strUser,CString &strBigImg)
|
{
|
CString strFileDir = _T("");
|
CString strTmpPath = _T("");
|
CString strServerID= _T("");
|
CString strLogin= _T("");
|
|
strBigImg= _T("");
|
if(strUser.IsEmpty())
|
return;
|
if(m_pServerMgr)
|
{
|
strServerID = m_pServerMgr->GetUserLogin()->m_strOrgServerID;
|
strLogin = m_pServerMgr->GetUserLogin()->m_strLoginName;
|
}
|
strFileDir = CBaseCommFun::GetAMUserDataDir(strLogin, strServerID);
|
strFileDir += _T("\\UserPicture");
|
strBigImg = strFileDir + _T("\\") + strUser+ _T(".png");
|
if ( GetFileAttributes( strBigImg ) == -1 )
|
{
|
strBigImg = _T("");
|
return ;
|
}
|
}
|
IBitmap* CMBGroupUserinfoWnd::GetMBOrgUserPhoto( CString strUser,CString strSex )
|
{
|
IBitmap* pBmp;
|
if(strUser.IsEmpty())
|
return NULL;
|
if( !m_pServerMgr)
|
return NULL;
|
if ( m_pServerMgr->GetOrgListMgr()->LookupUserPhoto(strUser,pBmp))
|
{
|
return pBmp;
|
}
|
CString strBigImg;
|
GetUserPicturePath(strUser,strBigImg);
|
if( !strBigImg.IsEmpty())
|
{
|
SStringT strFile;
|
strFile.Format(_T("file:%s"),strBigImg);
|
IBitmap* pBmpTemp = LOADIMAGE2(strFile);
|
pBmp = NULL;
|
if(pBmpTemp)
|
{
|
pBmp= CMBOrgFunc::GetFixSizeImage(pBmpTemp,40, 40);
|
pBmpTemp->Release();
|
}
|
if(pBmp)
|
m_pServerMgr->GetOrgListMgr()->AddUserPhoto(strUser,pBmp);
|
}
|
if(pBmp)
|
return pBmp;
|
else
|
{
|
if ( m_pServerMgr->GetOrgListMgr()->LookupDeaultUserPhoto(pBmp,strSex))
|
{
|
return pBmp;
|
}
|
}
|
return pBmp;
|
}
|
void CMBGroupUserinfoWnd::OnTimer(UINT_PTR nIDEvent)
|
{
|
if(nIDEvent == WM_TIMER_SHOWWND)
|
{
|
KillTimer(nIDEvent);
|
ShowWnd();
|
}
|
}
|