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

📄 dialog.cpp

📁 freeamp有名的媒体播放器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    SendMessage(m_hTextToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
    SendMessage(m_hBothToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);

    SendMessage(m_hImageToolbar, TB_SETBITMAPSIZE, 0, MAKELPARAM(22, 18)); 
    SendMessage(m_hTextToolbar, TB_SETBITMAPSIZE, 0, MAKELPARAM(0, 0)); 
    SendMessage(m_hBothToolbar, TB_SETBITMAPSIZE, 0, MAKELPARAM(22, 18)); 

    TBADDBITMAP tbab; 

    // Add the bitmap containing button images to the toolbar.
    tbab.hInst = g_hinst; 
    tbab.nID   = IDB_TOOLBAR; 
    SendMessage(m_hImageToolbar, TB_ADDBITMAP, (WPARAM) 10, (WPARAM) &tbab);
    SendMessage(m_hBothToolbar, TB_ADDBITMAP, (WPARAM) 10, (WPARAM) &tbab);

    SendMessage(m_hImageToolbar, TB_ADDBUTTONS, (WPARAM) 11, (LPARAM) &tbButtons);
    SendMessage(m_hImageToolbar, TB_AUTOSIZE, (WPARAM) 0, (LPARAM) 0);

    tbButtons[0].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"New Playlist");
    tbButtons[1].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Save Playlist");
    tbButtons[3].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Import Items");
    tbButtons[4].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Remove Items");
    tbButtons[5].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Edit Info");
    tbButtons[7].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Add Items");
    tbButtons[8].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Add Files");
    tbButtons[9].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Move Up");
    tbButtons[10].iString = SendMessage(m_hBothToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Move Down");
    SendMessage(m_hBothToolbar, TB_ADDBUTTONS, (WPARAM) 11, (LPARAM) &tbButtons);
    SendMessage(m_hBothToolbar, TB_AUTOSIZE, (WPARAM) 0, (LPARAM) 0);

    tbButtons[0].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"New Playlist");
    tbButtons[1].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Save Playlist");
    tbButtons[3].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Import Items");
    tbButtons[4].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Remove Items");
    tbButtons[5].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Edit Info");
    tbButtons[7].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Add Items");
    tbButtons[8].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Add Files");
    tbButtons[9].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Move Up");
    tbButtons[10].iString = SendMessage(m_hTextToolbar, TB_ADDSTRING, (WPARAM) 0, (LPARAM)"Move Down");
    SendMessage(m_hTextToolbar, TB_ADDBUTTONS, (WPARAM) 11, (LPARAM) &tbButtons);
    SendMessage(m_hTextToolbar, TB_AUTOSIZE, (WPARAM) 0, (LPARAM) 0);
   
    RECT buttonRect;
    SIZE sizeString;
    char temp[] = "HowBigAmI?";
    HDC hdc = GetDC(m_hTextToolbar);

    SendMessage(m_hTextToolbar, TB_GETITEMRECT , (WPARAM) 0, (LPARAM) &buttonRect); 

    GetTextExtentPoint32(hdc, temp, strlen(temp), &sizeString); 
    
    ReleaseDC(m_hTextToolbar, hdc);

    SendMessage(m_hTextToolbar, TB_SETBUTTONSIZE , 0, 
        MAKELPARAM(buttonRect.right - buttonRect.left, sizeString.cy + 6));

    bool useTextLabels, useImages;
    m_context->prefs->GetShowToolbarTextLabels(&useTextLabels);
    m_context->prefs->GetShowToolbarImages(&useImages);

    AddToolbarButtons(useTextLabels, useImages);
}

void MusicBrowserUI::SetTitles()
{
    if (m_pParent == NULL)
    {
       SetWindowText(m_hPlaylistTitle, 
                     "Currently Listening To:");
       SetWindowText(m_hWnd, 
                     "My Music - " BRANDING);
    }   
    else
    {
       string oTitle, oName;
       
       if (m_currentListName.length() == 0)
          oName = "New Playlist";
       else
       {
          char szBase[MAX_PATH];
       
          _splitpath(m_currentListName.c_str(), NULL, NULL, szBase, NULL);
          oName = szBase;
       }
       
       oTitle = string("Editing playlist: ") + oName;
       SetWindowText(m_hPlaylistTitle, 
                     oTitle.c_str());
       oTitle = "Editing " + oName + " - " + BRANDING;
       SetWindowText(m_hWnd, oTitle.c_str());
    }   
}

void MusicBrowserUI::DropFiles(HDROP dropHandle, bool filesAreURLs)
{
    uint32 count;
    char url[1024];

    count = DragQueryFile(  dropHandle,
                            -1L,
                            url,
                            sizeof(url));

    for(uint32 i = 0; i < count; i++)
    {
        DragQueryFile(  dropHandle,
                        i,
                        url,
                        sizeof(url));

        //MessageBox(NULL, url, "url", MB_OK);
    }
}

BOOL MusicBrowserUI::SetCursor(int hitTest, int mouseMsg)
{
    BOOL result = FALSE;

    if((m_overSplitter || m_trackSplitter) && hitTest == HTCLIENT)
    {
        ::SetCursor(m_hSplitterCursor);
        result = TRUE;
    }
    return result;
}

void MusicBrowserUI::MouseMove(uint32 uFlags, POINT &sPoint)
{
    if(m_trackSplitter)
    {
        HDC hdc = GetDC(NULL);
        POINT pt = sPoint;

        MapWindowPoints(m_hWnd, NULL, (LPPOINT)&pt, 1);

        HBRUSH oldBrush = (HBRUSH)SelectObject(hdc, m_splitterBrush);

        PatBlt(hdc,
               m_splitterRect.left, 
               m_splitterRect.top, 
               m_splitterRect.right - m_splitterRect.left, 
               m_splitterRect.bottom - m_splitterRect.top, 
               PATINVERT);

        OffsetRect(&m_splitterRect, (pt.x - m_splitterRect.left), 0);

        PatBlt(hdc,
               m_splitterRect.left, 
               m_splitterRect.top, 
               m_splitterRect.right - m_splitterRect.left, 
               m_splitterRect.bottom - m_splitterRect.top, 
               PATINVERT);

        SelectObject(hdc, oldBrush);

        ReleaseDC(NULL, hdc);
    }
    else
    {
        RECT catalogRect,playlistRect;
        
        GetWindowRect(m_hMusicView, &catalogRect);
        GetWindowRect(m_hPlaylistView, &playlistRect);
        MapWindowPoints(NULL, m_hWnd, (LPPOINT)&catalogRect, 2);
        MapWindowPoints(NULL, m_hWnd, (LPPOINT)&playlistRect, 2);

        m_splitterRect.top = playlistRect.top;
        m_splitterRect.bottom = playlistRect.bottom;
        m_splitterRect.left = catalogRect.right + 1;
        m_splitterRect.right = playlistRect.left - 1;

        if(PtInRect(&m_splitterRect, sPoint))
        {
            m_overSplitter = true;
        }
        else
        {
            m_overSplitter = false;
        }
   
    }
} 

void MusicBrowserUI::MouseButtonDown(int keys, int x, int y)
{
    RECT catalogRect,playlistRect;
    RECT clientRect;
    POINT pt;

    pt.x = x;
    pt.y = y;

    GetClientRect(m_hWnd, &clientRect);
    //InflateRect(&clientRect, -150, 0);
    clientRect.left += 125;
    clientRect.right -= 175;
    GetWindowRect(m_hMusicView, &catalogRect);
    GetWindowRect(m_hPlaylistView, &playlistRect);
    MapWindowPoints(m_hWnd, NULL, (LPPOINT)&pt, 1);
    MapWindowPoints(m_hWnd, NULL, (LPPOINT)&clientRect, 2);

    m_splitterRect.top = playlistRect.top;
    m_splitterRect.bottom = playlistRect.bottom;
    m_splitterRect.left = catalogRect.right + 1;
    m_splitterRect.right = playlistRect.left - 1;

    if(PtInRect(&m_splitterRect, pt))
    {
        m_trackSplitter = true;
        SetCapture(m_hWnd);
        ClipCursor(&clientRect);
        m_hSavedCursor = ::SetCursor(m_hSplitterCursor);

        HDC hdc = GetDC(NULL);

        HBRUSH oldBrush = (HBRUSH)SelectObject(hdc, m_splitterBrush);

        PatBlt(hdc,
               m_splitterRect.left, 
               m_splitterRect.top, 
               m_splitterRect.right - m_splitterRect.left, 
               m_splitterRect.bottom - m_splitterRect.top, 
               PATINVERT);

        SelectObject(hdc, oldBrush);

        ReleaseDC(NULL, hdc);
    }
}

void MusicBrowserUI::MouseButtonUp(int keys, int x, int y)
{
    POINT pt;

    pt.x = x;
    pt.y = y;

    if(m_trackSplitter)
    {
        m_trackSplitter = false;
        ReleaseCapture();
        ClipCursor(NULL);
        ::SetCursor(m_hSavedCursor);

        HDC hdc = GetDC(NULL);

        HBRUSH oldBrush = (HBRUSH)SelectObject(hdc, m_splitterBrush);

        PatBlt(hdc,
               m_splitterRect.left, 
               m_splitterRect.top, 
               m_splitterRect.right - m_splitterRect.left, 
               m_splitterRect.bottom - m_splitterRect.top, 
               PATINVERT);

        SelectObject(hdc, oldBrush);

        ReleaseDC(NULL, hdc);


        RECT catalogRect, playlistRect, titleRect;
        int32 delta;

        GetWindowRect(m_hMusicView, &catalogRect);
        GetWindowRect(m_hPlaylistView, &playlistRect);
        GetWindowRect(m_hPlaylistTitle, &titleRect);

        delta = (m_splitterRect.right + 1) - playlistRect.left;
        catalogRect.right = m_splitterRect.left - 1;
        playlistRect.left = m_splitterRect.right + 1;
        titleRect.left += delta;

        MapWindowPoints(NULL, m_hWnd, (LPPOINT)&catalogRect, 2);
        MapWindowPoints(NULL, m_hWnd, (LPPOINT)&playlistRect, 2);
        MapWindowPoints(NULL, m_hWnd, (LPPOINT)&titleRect, 2);

        
        MoveWindow(m_hMusicView, 
                  catalogRect.left, 
                  catalogRect.top, 
        	      (catalogRect.right - catalogRect.left),
                  catalogRect.bottom - catalogRect.top,
                  TRUE);

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

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


    }
}

void MusicBrowserUI::UpdateButtonStates()
{
    // start off disabling everything, then enable only what 
    // should be.

    SendMessage(m_hToolbar, TB_ENABLEBUTTON,
                ID_EDIT_REMOVE, MAKELPARAM(FALSE, 0));

    SendMessage(m_hToolbar, TB_ENABLEBUTTON,
                ID_EDIT_EDITINFO, MAKELPARAM(FALSE, 0));

    SendMessage(m_hToolbar, TB_ENABLEBUTTON,
                ID_EDIT_ADDTRACK, MAKELPARAM(FALSE, 0));    

    SendMessage(m_hToolbar, TB_ENABLEBUTTON,
                ID_EDIT_MOVEUP, MAKELPARAM(FALSE, 0));

    SendMessage(m_hToolbar, TB_ENABLEBUTTON,
                ID_EDIT_MOVEDOWN, MAKELPARAM(FALSE, 0));

    // File Menu
    SendMessage(m_hToolbar, TB_ENABLEBUTTON, 
                    ID_FILE_SAVEPLAYLIST, MAKELPARAM(m_bListChanged, 0)); 

    if(m_hPlaylistView == GetFocus())
    {
        // Can we move items up and down?
        uint32 index = ListView_GetItemCount(m_hPlaylistView);
        uint32 count = ListView_GetSelectedCount(m_hPlaylistView);
        uint32 state;

        state = ListView_GetItemState(m_hPlaylistView, 
                                      index - 1, 
                                      LVIS_SELECTED);

        SendMessage(m_hToolbar, TB_ENABLEBUTTON, 
                    ID_EDIT_MOVEDOWN, MAKELPARAM(!(state & LVIS_SELECTED || !count), 0)); 

        state = ListView_GetItemState(m_hPlaylistView, 
                                      0, 
                                      LVIS_SELECTED);

        SendMessage(m_hToolbar, TB_ENABLEBUTTON, 
                    ID_EDIT_MOVEUP, MAKELPARAM(!(state & LVIS_SELECTED || !count), 0)); 
        
        SendMessage(m_hToolbar, TB_ENABLEBUTTON, 
                    ID_EDIT_REMOVE, MAKELPARAM(count!=0, 0)); 

        SendMessage(m_hToolbar, TB_ENABLEBUTTON, 
                    ID_EDIT_EDITINFO, MAKELPARAM(count!=0, 0)); 

        SendMessage(m_hToolbar, TB_ENABLEBUTTON, 
            ID_EDIT_ADDTRACK, 0); 
    }

    // what about items which deal with the treeview?

    //HTREEITEM treeSelect = TreeView_GetSelection(m_hMusicView);

    if(m_hMusicView == GetFocus())
    {
        SendMessage(m_hToolbar, TB_ENABLEBUTTON, 
            ID_EDIT_ADDTRACK, 0); 

        uint32 trackCount = 0;
        uint32 playlistCount = 0;

        trackCount = GetSelectedTrackCount();
        playlistCount = GetSelectedPlaylistCount();

        if(trackCount + playlistCount)
        {

            if(!IsItemSelected(m_hNewPlaylistItem) &&
                !IsItemSelected(m_hNewPlaylistItem))
            {
                SendMessage(m_hToolbar, TB_ENABLEBUTTON, 
                            ID_EDIT_ADDTRACK, MAKELPARAM(TRUE, 0)); 
            }

            if(!IsItemSelected(m_hPlaylistItem) &&
               !IsItemSelected(m_hNewPlaylistItem) && 
               !IsItemSelected(m_hPortableItem) &&
               !IsItemSelected(m_hNewPortableItem) &&
               !IsItemSelected(m_hAllItem))
            {
                SendMessage(m_hToolbar, TB_ENABLEBUTTON, 
                        ID_EDIT_REMOVE, MAKELPARAM(TRUE, 0)); 
            }
 
            if(!IsItemSelected(m_hPlaylistItem) &&
               !IsItemSelected(m_hNewPlaylistItem) && 
               !IsItemSelected(m_hPortableItem) &&
               !IsItemSelected(m_hNewPortableItem) &&
               trackCount)
            {
                SendMessage(m_hToolbar, TB_ENABLEBUTTON, 

⌨️ 快捷键说明

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