// 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(L"tab_main"); if(pTab) pTab->SetCurSel(0); m_pTileVEmotionItem = FindChildByName2("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("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("link_default"); if(pLink) pLink->SetVisible(true,true); SLink *pLink2 = FindChildByName2("link_extern1"); if(pLink2) { pLink2->SetWindowText(strExtrenFolder3); pLink2->SetVisible(true,true); } } if( !strExtrenFolder3.IsEmpty()) { bExtrenEmotion = TRUE; m_pTileVEmotionExtren2 = FindChildByName2("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("link_default"); if(pLink) pLink->SetVisible(true,true); SLink *pLink2 = FindChildByName2("link_extern2"); if(pLink2) { pLink2->SetWindowText(strExtrenFolder3); pLink2->SetVisible(true,true); } } if( !bExtrenEmotion) { SWindow *pWindow= FindChildByName2("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(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(L"tab_main"); if(pTab) pTab->SetCurSel(0); } void CMBEmotionsWnd::OnMsgExtrenEmotions() { STabCtrl *pTab = FindChildByName2(L"tab_main"); if(pTab) pTab->SetCurSel(1); } void CMBEmotionsWnd::OnMsgExtren2Emotions() { STabCtrl *pTab = FindChildByName2(L"tab_main"); if(pTab) pTab->SetCurSel(2); }