⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialog.cpp

📁 vc++ mp3 源码下载 使用vc写的mp3 播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            ShowWindow(m_hWnd, SW_NORMAL);
            UpdateWindow(m_hWnd);
        }
        
        while(GetMessage(&msg,NULL,0,0))
        {
            if(!IsDialogMessage(m_hWnd, &msg))
            {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
        }
    }
    
    DestroyWindow(m_hWnd);
    m_hWnd = NULL;

    return false;
}

void MusicBrowserUI::UIThreadFunc(void* arg)
{
    MusicBrowserUI* ui = (MusicBrowserUI*)arg;

    if (ui->CreateMainDialog())
       delete ui;
}

Error MusicBrowserUI::CloseMainDialog()
{ 
    if(m_pParent)
    {
        if(m_bListChanged)
        {
            ShowWindow(m_hWnd, SW_RESTORE);
            SetForegroundWindow(m_hWnd);
            if (MessageBox(m_hWnd, "Would you like to save this playlist?",
                  BRANDING, MB_YESNO) == IDYES)
            {
                if(!m_portableDevice)
                    SavePlaylist();
                else
                    SavePortablePlaylist();
            }
        }    
    }

    m_bListChanged = false;   
    PostMessage(m_hWnd, WM_QUIT, 0, 0);
   
    return kError_NoErr;
}

void MusicBrowserUI::ShowBrowser(bool bShowExpanded)
{
    ShowWindow(m_hWnd, SW_RESTORE);
	ShowWindow(m_hWnd, SW_SHOW);
    SetForegroundWindow(m_hWnd);
    PostMessage(m_hWnd, UWM_EMPTYDBCHECK, 0, 0);
}

void MusicBrowserUI::HideBrowser()
{
	isVisible = false;
	ShowWindow(m_hWnd, SW_HIDE);
}

void MusicBrowserUI::Close()
{
    if(m_pParent == NULL)
       HideBrowser();
    else
       CloseMainDialog();
}

void MusicBrowserUI::Destroy()
{
    RevokeDragDrop(m_hPlaylistView);
    OleUninitialize(); 

    ImageList_Destroy(TreeView_SetImageList(
                        m_hMusicView,
                        NULL, TVSIL_NORMAL)); 
    ImageList_Destroy(ListView_SetImageList(
                        m_hPlaylistView,
                        NULL, LVSIL_SMALL)); 

    m_playlistDropTarget->Release();

    if(m_pParent)
    {
        m_pParent->RemoveMusicBrowserWindow(this);
        delete this;
    }
}

void MusicBrowserUI::ExpandCollapseEvent()
{
    HMENU        hMenu;
    MENUITEMINFO sItem;
    RECT catalogRect, playlistRect, titleRect;

    GetWindowRect(m_hMusicView, &catalogRect);
    GetWindowRect(m_hPlaylistView, &playlistRect);
    GetWindowRect(m_hPlaylistTitle, &titleRect);
    MapWindowPoints(NULL, m_hWnd, (LPPOINT)&catalogRect, 2);
    MapWindowPoints(NULL, m_hWnd, (LPPOINT)&playlistRect, 2);
    MapWindowPoints(NULL, m_hWnd, (LPPOINT)&titleRect, 2);

    if (m_state == STATE_COLLAPSED)
    {
       m_state = STATE_EXPANDED;
       SetWindowText(m_hWnd,  "My Music - " BRANDING);
       sItem.dwTypeData = "View &Playlist Only";

       ShowWindow(m_hMusicView, SW_SHOW);
       ShowWindow(m_hMusicViewTitle, SW_SHOW);

       MoveWindow(m_hPlaylistView, 
                  catalogRect.left + m_iCollapseMoveAmount, 
                  catalogRect.top, 
        	      (playlistRect.right - playlistRect.left) - m_iCollapseMoveAmount,
                  playlistRect.bottom - playlistRect.top,
                  TRUE);

       MoveWindow(m_hPlaylistTitle, 
                  titleRect.left + m_iCollapseMoveAmount, 
                  titleRect.top, 
        	      (titleRect.right - titleRect.left) - m_iCollapseMoveAmount,
                  titleRect.bottom - titleRect.top,
                  TRUE);
    }            
    else
    {                
       m_state = STATE_COLLAPSED;
       SetWindowText(m_hWnd, "Playlist - " BRANDING);
       sItem.dwTypeData = "View &My Music";

       ShowWindow(m_hMusicView, SW_HIDE);
       ShowWindow(m_hMusicViewTitle, SW_HIDE);

       m_iCollapseMoveAmount = playlistRect.left - catalogRect.left;
       
       MoveWindow(m_hPlaylistView, 
                  catalogRect.left, 
                  catalogRect.top, 
        	      (playlistRect.right - playlistRect.left) + m_iCollapseMoveAmount,
                  playlistRect.bottom - playlistRect.top,
                  TRUE);

       MoveWindow(m_hPlaylistTitle, 
                  titleRect.left - m_iCollapseMoveAmount, 
                  titleRect.top, 
        	      (titleRect.right - titleRect.left) + m_iCollapseMoveAmount,
                  titleRect.bottom - titleRect.top,
                  TRUE);
    }

    hMenu = GetMenu(m_hWnd);
    hMenu = GetSubMenu(hMenu, 2);
    sItem.cbSize = sizeof(MENUITEMINFO);
    sItem.fMask = MIIM_TYPE;
    sItem.fType = MFT_STRING;
    sItem.cch = strlen(sItem.dwTypeData);
    SetMenuItemInfo(hMenu, ID_VIEW_MUSICCATALOG, false, &sItem);
    
    SendMessage(m_hStatus, SB_SETTEXT, 0, (LPARAM)"");
    InvalidateRect(m_hWnd, NULL, true);
    UpdateWindow(m_hWnd);
}

void MusicBrowserUI::SizeWindow(int iType, int iWidth, int iHeight)
{
    RECT windowRect;
    RECT clientRect;
    RECT controlRect;
    uint32 windowHeight, windowWidth;
    uint32 clientHeight, clientWidth;
    uint32 controlHeight, controlWidth;
    uint32 statusbarHeight;
    RECT oldListViewRect;

    GetWindowRect(m_hWnd, &windowRect);
    windowHeight = windowRect.bottom - windowRect.top;
    windowWidth = windowRect.right - windowRect.left;

    GetClientRect(m_hWnd, &clientRect);
    clientHeight = clientRect.bottom - clientRect.top;
    clientWidth = clientRect.right - clientRect.left;

    HDWP hdwp = BeginDeferWindowPos(5);
    
    // Status Bar
    GetWindowRect(m_hStatus, &controlRect); 
    controlHeight = controlRect.bottom - controlRect.top;
    controlWidth = controlRect.right - controlRect.left;

    statusbarHeight = controlHeight;
    hdwp = DeferWindowPos(hdwp, m_hStatus, NULL,
                           windowRect.left, 
                           windowRect.bottom - controlHeight,
                           windowWidth,
                           controlHeight,
                           SWP_NOZORDER);

    int32 panes[2]= {0, -1};
    panes[0] = clientRect.right - clientRect.left - 70;
    SendMessage(m_hStatus, SB_SETPARTS, 2, (LPARAM) panes);

    // Tool Bar
    GetWindowRect(m_hRebar, &controlRect); 
    controlHeight = controlRect.bottom - controlRect.top;
    controlWidth = controlRect.right - controlRect.left;

    hdwp = DeferWindowPos(hdwp, m_hRebar, NULL,
                           0, 
                           0,
                           clientWidth,
                           controlHeight,
                           SWP_NOZORDER);

    // Music Catalog View
    GetWindowRect(m_hMusicView, &controlRect); 
    MapWindowPoints(NULL, m_hWnd, (LPPOINT)&controlRect, 2);
    controlHeight = controlRect.bottom - controlRect.top;
    controlWidth = controlRect.right - controlRect.left;

    hdwp = DeferWindowPos(hdwp, m_hMusicView, NULL,
                           controlRect.left,
                           controlRect.top,
                           controlWidth,
                           clientRect.bottom - controlRect.top - statusbarHeight,
                           SWP_NOZORDER);


    // Current Playlist Title
    GetWindowRect(m_hPlaylistTitle, &controlRect);
    MapWindowPoints(NULL, m_hWnd, (LPPOINT)&controlRect, 2);
    controlHeight = controlRect.bottom - controlRect.top;
    controlWidth = clientRect.right - controlRect.left;

    hdwp = DeferWindowPos(hdwp, m_hPlaylistTitle, NULL,
                           controlRect.left,
                           controlRect.top,
                           controlWidth,
                           controlHeight,
                           SWP_NOZORDER);

    // Playlist View
    GetClientRect(m_hPlaylistView, &oldListViewRect);
    GetWindowRect(m_hPlaylistView, &controlRect);
    MapWindowPoints(NULL, m_hWnd, (LPPOINT)&controlRect, 2);
    controlHeight = clientRect.bottom - controlRect.top;
    controlWidth = clientRect.right - controlRect.left;

    hdwp = DeferWindowPos(hdwp, m_hPlaylistView, NULL,
                           controlRect.left,
                           controlRect.top,
                           controlWidth,
                           controlHeight - statusbarHeight,
                           SWP_NOZORDER);

    /*int delta = controlRect.right - controlRect.left - oldListViewRect.right - oldListViewRect.left;

    controlWidth -= delta;

    if(controlWidth < oldListViewRect.right - oldListViewRect.left)
    {
        int32 oldWidth = 0;
        HWND hwnd = m_hPlaylistView;

        oldWidth += ListView_GetColumnWidth(hwnd, 0);
        oldWidth += ListView_GetColumnWidth(hwnd, 1);
        oldWidth += ListView_GetColumnWidth(hwnd, 2);
        oldWidth += ListView_GetColumnWidth(hwnd, 3);
        oldWidth += ListView_GetColumnWidth(hwnd, 4);

        int32 headerResizeAmount = controlWidth - oldWidth;

        int32 eachHeaderAmount = headerResizeAmount/3;
        int32 titleExtraAmount = headerResizeAmount%3;
        int32 width;

        if(eachHeaderAmount)
        {
            width = ListView_GetColumnWidth(m_hPlaylistView, 1);
            width += eachHeaderAmount;    
            ListView_SetColumnWidth(m_hPlaylistView, 1, width);

            width = ListView_GetColumnWidth(m_hPlaylistView, 2);
            width += eachHeaderAmount;
            ListView_SetColumnWidth(m_hPlaylistView, 2, width);

            width = ListView_GetColumnWidth(m_hPlaylistView, 3);
            width += eachHeaderAmount;
            ListView_SetColumnWidth(m_hPlaylistView, 3, width);
        }

        if(titleExtraAmount)
        {
            static uint32 lastColumn = 1;

            while(titleExtraAmount)
            {
                width = ListView_GetColumnWidth(m_hPlaylistView, lastColumn);
   
                if(titleExtraAmount > 0)
                {
                    width += 1;
                    titleExtraAmount--;
                }
                else
                {
                    width -= 1;
                    titleExtraAmount++;
                }

                ListView_SetColumnWidth(m_hPlaylistView, lastColumn, width);

                if(++lastColumn > 3)
                    lastColumn = 1;
            }
        }        
    }*/
                           
    EndDeferWindowPos(hdwp);

    /*GetClientRect(m_hPlaylistView, &controlRect);

    controlWidth = controlRect.right - controlRect.left;

    if(controlWidth > oldListViewRect.right - oldListViewRect.left)
    {
        int32 oldWidth = 0;
        HWND hwnd = m_hPlaylistView;

        oldWidth += ListView_GetColumnWidth(hwnd, 0);
        oldWidth += ListView_GetColumnWidth(hwnd, 1);
        oldWidth += ListView_GetColumnWidth(hwnd, 2);
        oldWidth += ListView_GetColumnWidth(hwnd, 3);
        oldWidth += ListView_GetColumnWidth(hwnd, 4);

        int32 headerResizeAmount = controlWidth - oldWidth;

        int32 eachHeaderAmount = headerResizeAmount/3;
        int32 titleExtraAmount = headerResizeAmount%3;
        int32 width;

        if(eachHeaderAmount)
        {
            width = ListView_GetColumnWidth(m_hPlaylistView, 1);
            width += eachHeaderAmount;    
            ListView_SetColumnWidth(m_hPlaylistView, 1, width);

            width = ListView_GetColumnWidth(m_hPlaylistView, 2);
            width += eachHeaderAmount;
            ListView_SetColumnWidth(m_hPlaylistView, 2, width);

            width = ListView_GetColumnWidth(m_hPlaylistView, 3);
            width += eachHeaderAmount;
            ListView_SetColumnWidth(m_hPlaylistView, 3, width);
        }

        if(titleExtraAmount)
        {
            static uint32 lastColumn = 1;

            while(titleExtraAmount)
            {
                width = ListView_GetColumnWidth(m_hPlaylistView, lastColumn);
   
                if(titleExtraAmount > 0)
                {
                    width += 1;
                    titleExtraAmount--;
                }
                else
                {
                    width -= 1;
                    titleExtraAmount++;
                }

                ListView_SetColumnWidth(m_hPlaylistView, lastColumn, width);

                if(++lastColumn > 3)
                    lastColumn = 1;
            }
        }        
    }*/
}

void MusicBrowserUI::GetMinMaxInfo(MINMAXINFO *pInfo)
{
    pInfo->ptMinTrackSize = m_sMinSize;
}

void MusicBrowserUI::SetMinMaxInfo()
{
	RECT  sLoc, sLoc2;
    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -