使用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
// MBEmotionsWnd.cpp : implementation file
//
 
#include "stdafx.h"
#include "mbamui.h"
#include "MBEmotionsWnd.h"
 
 
 
// CMBEmotionsWnd
 
CMBEmotionsWnd::CMBEmotionsWnd(IListener* pListner) : SHostWnd(_T("LAYOUT:XML_EMOTIONSWND")), m_pListner(pListner)
{
    m_bLayoutInited      = FALSE;  
    m_pTileVEmotionItem    = NULL;
    m_pAdapterEmotionItemTile = NULL;
    m_pTileVEmotionExtren1    = NULL;
    m_pAdapterExtren1Tile = NULL;
    m_pTileVEmotionExtren2    = NULL;
    m_pAdapterExtren2Tile = NULL;
    m_pEmotions = NULL;
}
 
CMBEmotionsWnd::~CMBEmotionsWnd()
{
    
}
BOOL CMBEmotionsWnd::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_pEmotions = CMBEmotions::Instance();
    STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
    if(pTab)
        pTab->SetCurSel(0);
    m_pTileVEmotionItem = FindChildByName2<STileViewEx>("tileex_emotions");
    if(m_pTileVEmotionItem)
    {
        m_pAdapterEmotionItemTile = new CMBEmotionTileAdapter(this);    
        m_pAdapterEmotionItemTile->SetDataPtr( m_pEmotions );
        m_pAdapterEmotionItemTile->SetEmotionRange(0, m_pEmotions->GetDefEndIndex() + 1,TRUE);
        m_pTileVEmotionItem->SetAdapter(m_pAdapterEmotionItemTile); 
        m_pAdapterEmotionItemTile->Release();     // ²»»áÕæµÄÊÍ·Å£¬ÈüÆÊýÆ÷¼õÒ»
    }    
    BOOL  bExtrenEmotion = FALSE;
    CString strExtrenFolder2;
    CString strExtrenFolder3;
    m_pEmotions->GetExtEmotionFolderName( strExtrenFolder2 ,strExtrenFolder3);
    if( !strExtrenFolder2.IsEmpty())
    {
         bExtrenEmotion = TRUE;
        m_pTileVEmotionExtren1 = FindChildByName2<STileViewEx>("tileex_emoextern1");
        if(m_pTileVEmotionExtren1)
        {
            m_pAdapterExtren1Tile = new CMBEmotionTileAdapter(this);        
            m_pAdapterExtren1Tile->SetDataPtr( m_pEmotions );
            m_pAdapterExtren1Tile->SetEmotionRange( m_pEmotions->GetDefEndIndex(),m_pEmotions->GetExt2EndIndex() + 1,TRUE);
            m_pTileVEmotionExtren1->SetAdapter(m_pAdapterExtren1Tile); 
            m_pAdapterExtren1Tile->Release();     // ²»»áÕæµÄÊÍ·Å£¬ÈüÆÊýÆ÷¼õÒ»
        }    
        SLink *pLink = FindChildByName2<SLink>("link_default");
        if(pLink)
            pLink->SetVisible(true,true);
        SLink *pLink2 = FindChildByName2<SLink>("link_extern1");
        if(pLink2)
        {
            pLink2->SetWindowText(strExtrenFolder3);
            pLink2->SetVisible(true,true);
        }
    }
    if( !strExtrenFolder3.IsEmpty())
    {
        bExtrenEmotion = TRUE;
        m_pTileVEmotionExtren2 = FindChildByName2<STileViewEx>("tileex_emoextern2");
        if(m_pTileVEmotionExtren2)
        {
            m_pAdapterExtren2Tile = new CMBEmotionTileAdapter(this);        
            m_pAdapterExtren2Tile->SetDataPtr( m_pEmotions );
            m_pAdapterExtren2Tile->SetEmotionRange( m_pEmotions->GetExt2EndIndex(),m_pEmotions->GetExt3EndIndex() + 1,TRUE);
            m_pTileVEmotionExtren2->SetAdapter(m_pAdapterExtren2Tile); 
            m_pAdapterExtren2Tile->Release();     // ²»»áÕæµÄÊÍ·Å£¬ÈüÆÊýÆ÷¼õÒ»
        }    
        SLink *pLink = FindChildByName2<SLink>("link_default");
        if(pLink)
            pLink->SetVisible(true,true);
        SLink *pLink2 = FindChildByName2<SLink>("link_extern2");
        if(pLink2)
        {
            pLink2->SetWindowText(strExtrenFolder3);
            pLink2->SetVisible(true,true);
        }
    }
    if( !bExtrenEmotion)
    {
        SWindow *pWindow= FindChildByName2<SWindow>("bar_extern");
        if(pWindow)
            pWindow->SetVisible(false,true);
        if(pTab)
        {
            pTab->SetAttribute(L"pos",L"1,1,-1,-1");
            /*SOUI::CRect rcWnd;
            pTab->GetWindowRect(&rcWnd);
            rcWnd.bottom += 30;
            pTab->Move(&rcWnd);*/
        }
    }
    m_bLayoutInited = TRUE;
    return TRUE;
}
 
void CMBEmotionsWnd::SetParentWnd( HWND  hParentWnd )
{
    m_hParentWnd = hParentWnd;    
}
void CMBEmotionsWnd::OnClose()
{
    ShowWindow(SW_HIDE); 
}
// µãÔÚ´°¿ÚÖÐ
bool CMBEmotionsWnd::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 CMBEmotionsWnd::ShowWnd(SWindow *pWnd)
{
    if( NULL == pWnd )
        return ;
    STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
    if(pTab)
        pTab->SetCurSel(0);
    //SetTimer(TIMER_HIDEWND,200);
    SOUI::CRect rect =  pWnd->GetWindowRect();
    
    SOUI::CPoint pt;
    pt.x = rect.left - 200;
    pt.y = rect.top - 320;
    
    ::ClientToScreen(m_hParentWnd, &pt); 
    if(pt.x  < m_cxStart )
        pt.x = m_cxStart+5;
    if(pt.y  < m_cyStart )
        pt.y= m_cyStart+5;
 
    if(pt.x + 410 >  m_cxScreen + m_cxStart )
        pt.x = m_cxScreen + m_cxStart- 410 - 5;
    if(pt.y + 320 >  m_cyScreen + m_cyStart )
        pt.y= m_cyScreen + m_cyStart- 320 - 5;
    ::SetWindowPos(m_hWnd, NULL, pt.x,pt.y, 410,320, SWP_SHOWWINDOW);
    //MoveWindow(pt.x,pt.y,410,320);  
    // ÏÔʾµ¯³ö´°¿Ú
    ShowWindow(SW_SHOW); 
}
 
// Òþ²Ø´°¿Ú  
void CMBEmotionsWnd::HideWnd()
{
    ShowWindow(SW_HIDE);  
    //KillTimer(TIMER_HIDEWND);  
}
void CMBEmotionsWnd::OnEmotionItemClick(int nIndexD)
{
    m_pListner->EmotionTileViewItemClick(nIndexD);
    ShowWindow(SW_HIDE);  
}
 
//int CMBEmotionsWnd::OnMouseActivate(HWND wndTopLevel, UINT nHitTest, UINT message)
//{
//    if(nState == WA_INACTIVE && IsWindowVisible())
//    {        
//        ShowWindow(SW_HIDE);
//    }
//    return MA_NOACTIVATE;
//}
void CMBEmotionsWnd::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);
        if(wndOther == m_hParentWnd)
        {
            ::SetWindowPos(m_hParentWnd, NULL, 0,0,0,0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
        }
    }
}
void CMBEmotionsWnd::OnDefaultEmotions()
{
    STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
    if(pTab)
        pTab->SetCurSel(0);
}
void CMBEmotionsWnd::OnMsgExtrenEmotions()
{
    STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
    if(pTab)
        pTab->SetCurSel(1);
}
void CMBEmotionsWnd::OnMsgExtren2Emotions()
{
    STabCtrl *pTab = FindChildByName2<STabCtrl>(L"tab_main");
    if(pTab)
        pTab->SetCurSel(2);
}