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

📄 options.c

📁 VC++视频开发实例集锦(包括“远程视频监控”"语音识别系统"等13个经典例子)
💻 C
📖 第 1 页 / 共 2 页
字号:


#include "stdafx.h"
#include "globals.h"
#include "CPI_Player.h"
#include "CPI_Playlist.h"


LRESULT CALLBACK
url_windowproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)
    {
    case WM_INITDIALOG:
        return TRUE;

    case WM_CLOSE:
        EndDialog(hwndDlg, 1);
        return TRUE;

    case WM_COMMAND:

        switch (LOWORD(wParam))
        {
        case IDOK:
            {
                char urlbuf[MAX_PATH];
                GetDlgItemText(hwndDlg,IDC_URL,urlbuf,MAX_PATH);
                CPL_Empty(globals.m_hPlaylist);
                CPL_SyncLoadNextFile(globals.m_hPlaylist);
                CPL_AddSingleFile(globals.m_hPlaylist, urlbuf, urlbuf);
                CPL_PlayItem(globals.m_hPlaylist, TRUE, pmCurrentItem);
            }
            EndDialog(hwndDlg, TRUE);
            break;

        case IDCANCEL:
            EndDialog(hwndDlg, TRUE);
            break;
        }
    }
    return FALSE;
}
//
//
//
LRESULT CALLBACK
options_windowproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{

    switch (msg) {
        /* This message means the dialog is started but not yet visible.
           Do All initializations here
         */
    case WM_INITDIALOG:
        {
            if (options.use_default_skin == TRUE)
                SendDlgItemMessage(hwndDlg, IDC_PLAYERSKINCHECK,
                                   BM_SETCHECK, BST_UNCHECKED, 0);
            else
                SendDlgItemMessage(hwndDlg, IDC_PLAYERSKINCHECK,
                                   BM_SETCHECK, BST_CHECKED, 0);
            SendDlgItemMessage(hwndDlg, IDC_EASYMOVE, BM_SETCHECK,
                               options.easy_move, 0);
            SendDlgItemMessage(hwndDlg, IDC_SCROLLTITLE, BM_SETCHECK,
                               options.scroll_track_title, 0);

            SendDlgItemMessage(hwndDlg, IDC_ONTOP, BM_SETCHECK,
                               options.always_on_top, 0);
            SendDlgItemMessage(hwndDlg, IDC_AUTOEXIT, BM_SETCHECK,
                               options.auto_exit_after_playing, 0);
            SendDlgItemMessage(hwndDlg, IDC_REMEMBERPLS, BM_SETCHECK,
                               options.remember_playlist, 0);
            SendDlgItemMessage(hwndDlg, IDC_REMAINING, BM_SETCHECK,
                               options.show_remaining_time, 0);
            SendDlgItemMessage(hwndDlg, IDC_READTAG, BM_SETCHECK,
                               options.read_id3_tag, 0);
            SendDlgItemMessage(hwndDlg, IDC_SUPPORTID3_V2, BM_SETCHECK,
                               options.support_id3v2, 0);
            SendDlgItemMessage(hwndDlg, IDC_PREFERNATIVEOGGTAGS, BM_SETCHECK,
                               options.prefer_native_ogg_tags, 0);
            SendDlgItemMessage(hwndDlg, IDC_READTRACKTIME, BM_SETCHECK,
                               options.work_out_track_lengths, 0);
            SendDlgItemMessage(hwndDlg, IDC_READID3INBACKGROUND, BM_SETCHECK,
                               options.read_id3_tag_in_background, 0);
            SendDlgItemMessage(hwndDlg, IDC_ROTATE, BM_SETCHECK,
                               options.rotate_systray_icon, 0);

            SendDlgItemMessage(hwndDlg, IDC_REMSONG, BM_SETCHECK,
                               options.remember_last_played_track, 0);
            SendDlgItemMessage(hwndDlg, IDC_FILEONCE, BM_SETCHECK,
                               options.allow_file_once_in_playlist, 0);

            SendDlgItemMessage(hwndDlg, IDC_MULTIPLEINSTANCES, BM_SETCHECK,
                               options.allow_multiple_instances, 0);
            SendDlgItemMessage(hwndDlg, IDC_READSELTAG, BM_SETCHECK,
                               options.read_id3_tag_of_selected, 0);
            SendDlgItemMessage(hwndDlg, IDC_AUTOPLAY, BM_SETCHECK,
                               options.auto_play_when_started, 0);

            SendDlgItemMessage(hwndDlg, IDC_TASKBAR, BM_SETCHECK,
                               options.show_on_taskbar, 0);

            SendDlgItemMessage(hwndDlg, IDC_REMEMBERSKIN, UDM_SETRANGE,
                               0, MAKELONG(50, 1));
            SendDlgItemMessage(hwndDlg, IDC_DELAYTIMES, UDM_SETRANGE, 0,
                               MAKELONG(10, 0));
            SetDlgItemInt(hwndDlg, IDC_REMSKINVAL,
                          options.remember_skin_count, FALSE);
            SetDlgItemInt(hwndDlg, IDC_DELAYTIME,
                          options.seconds_delay_after_track, FALSE);

            SetDlgItemText(hwndDlg, IDC_LOADSKIN, options.main_skin_file);
            if (*options.playlist_skin_file)
                SendDlgItemMessage(hwndDlg, IDC_PLAYLISTSKINCHECK,
                                   BM_SETCHECK, options.use_playlist_skin,
                                   0);

            SendDlgItemMessage(hwndDlg, IDC_MIXER, CB_ADDSTRING, 0, (LPARAM)"System MASTER volume");
            SendDlgItemMessage(hwndDlg, IDC_MIXER, CB_ADDSTRING, 0, (LPARAM)"System WAVE volume");
            SendDlgItemMessage(hwndDlg, IDC_MIXER, CB_ADDSTRING, 0, (LPARAM)"Internal volume");
            if(globals.m_enMixerMode == mmMasterVolume)
                SendDlgItemMessage(hwndDlg, IDC_MIXER, CB_SETCURSEL, 0, 0);
            else if(globals.m_enMixerMode == mmWaveVolume)
                SendDlgItemMessage(hwndDlg, IDC_MIXER, CB_SETCURSEL, 1, 0);
            else
                SendDlgItemMessage(hwndDlg, IDC_MIXER, CB_SETCURSEL, 2, 0);

            CPI_Player__EnumOutputDevices(globals.m_hPlayer);
            globals.m_bOptions_ChangedSkin = FALSE;
            return TRUE;
        }

    case WM_CLOSE:
        EndDialog(hwndDlg, 1);
        return TRUE;

    case WM_COMMAND:
        switch (LOWORD(wParam)) {
        case IDC_SKINBUTTON:
            {
                OPENFILENAME fn;
                char    filefilter[] =
                    "CoolPlayer Skin Initialization Files (*.ini)\0*.ini\0All Files (*.*)\0*.*\0";
                BOOL    returnval;
                char    initialfilename[MAX_PATH * 100] = "";
                char    pathbuffie[MAX_PATH];
                strcpy(pathbuffie, options.main_skin_file);
                path_remove_filespec(pathbuffie);
                fn.lStructSize = sizeof(OPENFILENAME);
                fn.hwndOwner = hwndDlg;
                fn.hInstance = NULL;
                fn.lpstrFilter = filefilter;
                fn.lpstrCustomFilter = NULL;
                fn.nMaxCustFilter = 0;
                fn.nFilterIndex = 0;
                fn.lpstrFile = initialfilename;
                fn.nMaxFile = MAX_PATH * 200;
                fn.lpstrFileTitle = NULL;
                fn.nMaxFileTitle = 0;
                fn.lpstrInitialDir = pathbuffie;
                fn.lpstrTitle = NULL;
                fn.Flags =
                    OFN_HIDEREADONLY | OFN_EXPLORER | OFN_FILEMUSTEXIST
                    | OFN_PATHMUSTEXIST | OFN_ENABLESIZING;
                fn.nFileOffset = 0;
                fn.nFileExtension = 0;
                fn.lpstrDefExt = NULL;
                fn.lCustData = 0;
                fn.lpfnHook = NULL;
                fn.lpTemplateName = NULL;
                returnval = GetOpenFileName(&fn);
                if (returnval != FALSE) {
                    char    pathbuf[MAX_PATH] = "";
                    SetDlgItemText(hwndDlg, IDC_LOADSKIN, fn.lpstrFile);
                    SendDlgItemMessage(hwndDlg, IDC_PLAYERSKINCHECK,
                                       BM_SETCHECK, BST_CHECKED, 0);
                    globals.m_bOptions_ChangedSkin = TRUE;
                }
                break;
            }

        case IDC_FLUSH_SKINLIST:

            {
                int     itemcounter =
                    GetMenuItemCount(GetSubMenu
                                     (globals.main_menu_popup, 4));
                int     teller;

                for (teller = 0; teller < itemcounter - 1; teller++) {
                    RemoveMenu(GetSubMenu(globals.main_menu_popup, 4), 0,
                               MF_BYPOSITION);
                }

            }
            break;

        case IDCANCEL:
            EndDialog(hwndDlg, 1);
            break;

        case IDOK:
            {
                BOOL    duplicatesalreadyremoved =
                    options.allow_file_once_in_playlist;
                int     index;
                HWND    hWnd = GetParent(hwndDlg);
                BOOL	bSkinChosen;

                options.auto_exit_after_playing =
                    SendDlgItemMessage(hwndDlg, IDC_AUTOEXIT, BM_GETCHECK,
                                       0, 0);
                options.remember_playlist =
                    SendDlgItemMessage(hwndDlg, IDC_REMEMBERPLS,
                                       BM_GETCHECK, 0, 0);
                options.show_remaining_time =
                    SendDlgItemMessage(hwndDlg, IDC_REMAINING, BM_GETCHECK,
                                       0, 0);
                options.read_id3_tag =
                    SendDlgItemMessage(hwndDlg, IDC_READTAG, BM_GETCHECK,
                                       0, 0);
                options.support_id3v2 =
                    SendDlgItemMessage(hwndDlg, IDC_SUPPORTID3_V2, BM_GETCHECK,
                                       0, 0);
                options.prefer_native_ogg_tags =
                    SendDlgItemMessage(hwndDlg, IDC_PREFERNATIVEOGGTAGS, BM_GETCHECK,
                                       0, 0);
                options.read_id3_tag_in_background =
                    SendDlgItemMessage(hwndDlg, IDC_READID3INBACKGROUND, BM_GETCHECK,
                                       0, 0);
                options.work_out_track_lengths =
                    SendDlgItemMessage(hwndDlg, IDC_READTRACKTIME, BM_GETCHECK,
                                       0, 0);
                options.easy_move =
                    SendDlgItemMessage(hwndDlg, IDC_EASYMOVE, BM_GETCHECK,
                                       0, 0);
                options.rotate_systray_icon =
                    SendDlgItemMessage(hwndDlg, IDC_ROTATE, BM_GETCHECK, 0,
                                       0);
                options.allow_file_once_in_playlist =
                    SendDlgItemMessage(hwndDlg, IDC_FILEONCE, BM_GETCHECK,
                                       0, 0);
                options.allow_multiple_instances =
                    SendDlgItemMessage(hwndDlg, IDC_MULTIPLEINSTANCES, BM_GETCHECK,
                                       0, 0);
                options.read_id3_tag_of_selected =
                    SendDlgItemMessage(hwndDlg, IDC_READSELTAG,
                                       BM_GETCHECK, 0, 0);
                options.auto_play_when_started =
                    SendDlgItemMessage(hwndDlg, IDC_AUTOPLAY, BM_GETCHECK,
                                       0, 0);
                options.show_on_taskbar =
                    SendDlgItemMessage(hwndDlg, IDC_TASKBAR, BM_GETCHECK,
                                       0, 0);
                if (options.show_on_taskbar) {
                    SetWindowLong(hWnd, GWL_EXSTYLE,
                                  GetWindowLong(hWnd,
                                                GWL_EXSTYLE) &
                                  ~WS_EX_TOOLWINDOW);
                    SetWindowLong(hWnd, GWL_STYLE,
                                  GetWindowLong(hWnd,
                                                GWL_STYLE) | WS_SYSMENU);
                } else {
                    ShowWindow(hWnd, SW_HIDE);
                    SetWindowLong(hWnd, GWL_EXSTYLE,
                                  GetWindowLong(hWnd,
                                                GWL_EXSTYLE) |
                                  WS_EX_TOOLWINDOW);
                    SetWindowLong(hWnd, GWL_STYLE,
                                  GetWindowLong(hWnd,
                                                GWL_STYLE) | WS_SYSMENU);
                    ShowWindow(hWnd, SW_SHOW);

                }

                options.remember_last_played_track =
                    SendDlgItemMessage(hwndDlg, IDC_REMSONG, BM_GETCHECK,
                                       0, 0);

                options.remember_skin_count =
                    GetDlgItemInt(hwndDlg, IDC_REMSKINVAL, NULL, FALSE);
                options.seconds_delay_after_track =
                    GetDlgItemInt(hwndDlg, IDC_DELAYTIME, NULL, FALSE);

                options.scroll_track_title =
                    SendDlgItemMessage(hwndDlg, IDC_SCROLLTITLE,
                                       BM_GETCHECK, 0, 0);
                options.always_on_top =
                    SendDlgItemMessage(hwndDlg, IDC_ONTOP, BM_GETCHECK, 0,
                                       0);
                window_set_always_on_top(hWnd, options.always_on_top);

                GetDlgItemText(hwndDlg, IDC_LOADSKIN,
                               options.main_skin_file, MAX_PATH);


                bSkinChosen = SendDlgItemMessage(hwndDlg, IDC_PLAYERSKINCHECK, BM_GETCHECK, 0, 0);
                if(bSkinChosen != !options.use_default_skin
                        || globals.m_bOptions_ChangedSkin == TRUE)
                {
                    options.use_default_skin = !bSkinChosen;
                    globals.main_bool_skin_next_is_default = options.use_default_skin;

                    globals.playlist_bool_force_skin_from_options = TRUE;
                    main_play_control(ID_LOADSKIN, hWnd);
                }

                index = SendDlgItemMessage(hwndDlg, IDC_OUTPUT, CB_GETCURSEL, 0, 0);
                if (options.decoder_output_mode != index)
                {
                    options.decoder_output_mode = index;
                    CPI_Player__OnOutputDeviceChange(globals.m_hPlayer);
                }

                // Mixer control
                {

⌨️ 快捷键说明

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