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

📄 dialog.cpp

📁 FreeAMP(MP3播放)程序源代码-用来研究MP3解码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/*____________________________________________________________________________

        FreeAmp - The Free MP3 Player

        Portions Copyright (C) 1999 EMusic.com

        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

        You should have received a copy of the GNU General Public License
        along with this program; if not, write to the Free Software
        Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

        $Id: Dialog.cpp,v 1.105 2001/02/13 14:25:39 skx Exp $
____________________________________________________________________________*/

#include <windows.h>
#include <windowsx.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <direct.h>

#include "config.h"
#include "utility.h"
#include "resource.h"
#include "Win32MusicBrowser.h"
#include "eventdata.h"
#include "help.h"
#include "preferences.h"
#include "player.h"

#define UWM_EMPTYDBCHECK WM_USER + 69
 

TBBUTTON tbButtons[] = {
    { 0, ID_FILE_NEWPLAYLIST, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0L, -1},
    { 1, ID_FILE_SAVEPLAYLIST, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0L, -1},
	{ 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0L, -1},
    { 2, ID_FILE_IMPORT, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0L, -1},
	{ 3, ID_EDIT_REMOVE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0L, -1},
	{ 4, ID_EDIT_EDITINFO, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0L, -1},
    { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, 0L, -1},
    { 5, ID_EDIT_ADDTRACK, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0L, -1},
    { 6, ID_EDIT_ADDFILE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0L, -1},
    { 7, ID_EDIT_MOVEUP, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0L, -1},
    { 8, ID_EDIT_MOVEDOWN, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0L, -1} 
};

#define kNumPanes       2
#define kControlsWidth  104
#define kTimeWidth      70
int32   panes[kNumPanes]= {0, /*0,*/ -1};

static BOOL CALLBACK MainDlgProc(HWND hwnd, UINT msg, 
                                 WPARAM wParam, LPARAM lParam )
{
    MusicBrowserUI* ui = (MusicBrowserUI*)GetWindowLong(hwnd, GWL_USERDATA);
    switch (msg)
    {
        case WM_INITDIALOG:
        {
            ui = (MusicBrowserUI*)lParam;
            assert(ui != NULL);
            SetWindowLong(hwnd, GWL_USERDATA, (LONG)ui);
            
        	ui->InitDialog(hwnd);
        	ui->SetMinMaxInfo();
            return 1;
        }
        default:
            return ui->DialogProc(hwnd, msg, wParam, lParam);
    }
}        

BOOL MusicBrowserUI::DialogProc(HWND hwnd, UINT msg, 
                                WPARAM wParam, LPARAM lParam )
{
    bool filesAreURLs = false;

    switch (msg)
    {
        case WM_DESTROY:
        {
            Destroy();
            break;
        }

		case WM_CLOSE:
        {
			Close();
            return 1;
        }

        case WM_ENDSESSION:
        {
            SaveCurrentPlaylist();
            break;
        }

        case UWM_DROPURLS:
            filesAreURLs = true;
        case WM_DROPFILES:
        {
            DropFiles((HDROP)wParam, filesAreURLs);
            return 0;
        }

        case WM_SYSCOLORCHANGE:
        {
            SendMessage(m_hMusicView, WM_SYSCOLORCHANGE, 0, 0);
            SendMessage(m_hPlaylistView, WM_SYSCOLORCHANGE, 0, 0);
            SendMessage(m_hRebar, WM_SYSCOLORCHANGE, 0, 0);

             // update REBARBANDINFO for all rebar bands
            REBARBANDINFO rbb;

	        rbb.cbSize = sizeof(REBARBANDINFO);
	        rbb.fMask = RBBIM_COLORS;
	        rbb.clrFore = GetSysColor(COLOR_BTNTEXT);
	        rbb.clrBack = GetSysColor(COLOR_BTNFACE );	       

            SendMessage(m_hRebar, RB_SETBANDINFO, 0, (LPARAM)&rbb);
            SendMessage(m_hToolbar, WM_SYSCOLORCHANGE, 0, 0);
            break;
        }

		case WM_SIZE:
        {
            SizeWindow(wParam, LOWORD(lParam), HIWORD(lParam));
            return 1;
        } 
		case WM_NOTIFY:
            return Notify(wParam, (LPNMHDR)lParam);
            
		case WM_GETMINMAXINFO:
            GetMinMaxInfo((MINMAXINFO *)lParam);
            break;

        case WM_SETCURSOR:
            return SetCursor(LOWORD(lParam), HIWORD(lParam));
            break;

        case WM_MOUSEMOVE:
        {
            POINT sPoint;   
            sPoint.x = LOWORD(lParam);
            sPoint.y = HIWORD(lParam);  
            MouseMove((uint32)wParam, sPoint);
            return 1;
        }

        case WM_LBUTTONDOWN:
            MouseButtonDown(wParam, LOWORD(lParam), HIWORD(lParam));
            return 1;

        case WM_LBUTTONUP:
            MouseButtonUp(wParam, LOWORD(lParam), HIWORD(lParam));
            return 1;
            
        case UWM_EMPTYDBCHECK:
            EmptyDBCheck();
            return 1;

        case WM_HELP:
            ShowHelp(m_context, Music_Browser);
            return 1;

        case WM_COMMAND:
        {
        	switch(LOWORD(wParam))
            {
                case 2: // what is this? we get it when we press ESC.
                    if(m_bSearchInProgress)
                    {
                        StartStopMusicSearch();  
                    }
                    return 1;

                case ID_POPUP_RENAME:
                    RenameEvent();
                    return 1;

                case ID_POPUP_ADDTRACK_PLAY:
                    AddTrackAndPlayEvent();
                    return 1;

                case ID_POPUP_SUPDATE:
					StreamsTimer();
					return 1;

                case ID_POPUP_PLAY:
                    PlayNowEvent();
                    return 1;

				case ID_POPUP_TIP:
					TipEvent();
					return 1;

                case ID_FILE_NEWPLAYLIST:
                    NewPlaylist();
                    return 1;

                case ID_FILE_OPENPLAYLIST:
                    OpenPlaylist();
                    return 1;

                case ID_FILE_SAVEPLAYLIST:
                    SavePlaylist();
                    return 1;

                case ID_FILE_SAVEASPLAYLIST:
                    SavePlaylistAs();
                    return 1;

                case ID_FILE_IMPORT:
                    ImportTracksAndPlaylists();
                    return 1;

                case ID_FILE_EXPORTPLAYLIST:
                    ExportPlaylistEvent();
                    return 1;
                
                case ID_FILE_SEARCHFORMUSIC:
                    StartStopMusicSearch();
                    return 1;
                
                case ID_FILE_CLOSEPLAYLIST:
                    Close();
                    return 1;

                case ID_EDIT_UNDO_ACTION:
                    m_plm->Undo();
                    return 1;

                case ID_EDIT_REDO_ACTION:
                    m_plm->Redo();
                    return 1;

                case ID_POPUP_VISITWEB:
                    VisitWebEvent();
                    return 1;

                case ID_POPUP_ADDTRACK:
                case ID_EDIT_ADDTRACK:
                    AddTrackEvent();
                    return 1;

                case ID_EDIT_ADDFILE:
                    AddFileEvent(m_hWnd);
                    return 1;

                case ID_POPUP_REMOVE:
                case ID_EDIT_REMOVE:
                    RemoveEvent();
                    return 1;

                case ID_POPUP_MOVEUP:
                case ID_EDIT_MOVEUP:
                    MoveUpEvent();
                    return 1;

                case ID_POPUP_MOVEDOWN:
                case ID_EDIT_MOVEDOWN:
                    MoveDownEvent();
                    return 1;

                case ID_EDIT_CLEARPLAYLIST:
                    ClearPlaylistEvent();
                    return 1;

                case ID_EDIT_GENERATEPLAYLIST:
                    GenPlaylistEvent();
                    return 1;
                
                case ID_EDIT_SUBMITPLAYLIST:
                    SubmitPlaylistEvent();
                    return 1;

				case ID_SL_QUERY_NOMAX:
					GenSLPlaylistEvent(-1.0);
					return 1;

				case ID_RELATABLE_EDITPROFILE:
                    m_context->target->AcceptEvent(new ShowPreferencesEvent(8));
                    return 1;

                case ID_EDIT_STARTSIGNATURING:
                    HandleSignature();
                    return 1;

                case ID_POPUP_EDITPLAYLIST:
                case ID_EDIT_EDITPLAYLIST:
                    EditPlaylistEvent();
                    return 1;

                case ID_POPUP_EDITINFO:
                case ID_EDIT_EDITINFO:
                    EditInfoEvent();
                    return 1;

                case ID_POPUP_FAVORITE:
                    AddFavoriteEvent();
                    return 1;

                case ID_POPUP_REMOVEFAVORITE:
                    RemoveFavoriteEvent();
                    return 1;

                case ID_POPUP_EDITSTREAMINFO:
                    EditStreamInfoEvent();
                    return 1;

                case ID_CONTROLS_EJECT:
                case ID_POPUP_EJECT:
                    EjectCDEvent();
                    return 1;
                
				case ID_POPUP_REFRESH_CD:
					m_cdId = -1;
					m_context->player->UpdateCDNow();
					return 1;

                case ID_VIEW_MUSICCATALOG:
                    ExpandCollapseEvent();
                    return 1;

                case ID_VIEW_OPTIONS:
                    m_context->target->AcceptEvent(new ShowPreferencesEvent());
                    return 1;

                case ID_VIEW_LOCATECURRENTITEM:
                    DisplayCurrentItem();
                    return 1;
                    

                case ID_CONTROLS_PLAYPAUSE:
                case ID_CONTROLS_STOP:
                case ID_CONTROLS_PREVIOUSSONG:
                case ID_CONTROLS_NEXTSONG:
                case ID_CONTROLS_NORMALORDER:
                case ID_CONTROLS_SHUFFLE:
                case ID_CONTROLS_REPEATNONE:
                case ID_CONTROLS_REPEATONE:
                case ID_CONTROLS_REPEATALL:
                    PlayerControlsEvent(LOWORD(wParam));
                    return 1;


                case ID_SORT_ARTIST:
                case ID_SORT_ALBUM:
                case ID_SORT_TITLE:
                case ID_SORT_LENGTH:
                case ID_SORT_YEAR:
                case ID_SORT_TRACK:
                case ID_SORT_GENRE:
                case ID_SORT_LOCATION:
                case ID_SORT_FILENAME:
                case ID_SORT_RANDOMIZE:
                case IDC_RANDOMIZE:
                    SortEvent(LOWORD(wParam));
                    return 1;


                case ID_HELP_CONTENTS:
                    ShowHelp(m_context, Music_Browser);
                    return 1;

                case ID_HELP_FREEAMPWEBSITE:
                    ShellExecute(   hwnd, 
                                    "open", 
                                    "http://www.freeamp.org/", 
                                    NULL, 
                                    NULL, 
                                    SW_SHOWNORMAL);
                    return 1;

                case ID_HELP_EMUSICCOMWEBSITE:
                    ShellExecute(   hwnd, 
                                    "open", 
                                    "http://www.emusic.com/", 
                                    NULL, 
                                    NULL, 
                                    SW_SHOWNORMAL);
					return 1;

				case ID_HELP_RELATABLEWEBSITE:
					ShellExecute(	hwnd,
									"open",
									"http://www.relatable.com/",
									NULL,
									NULL,

⌨️ 快捷键说明

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