使用soui开发的mbc,只支持windows版本
w1146869587
2022-01-24 0408576e9da10015ffa9da0079b8c985113ce4b3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
// 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();
    }
}