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

📄 main.c

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


// Windows Header Files:

#include "stdafx.h"
#include "globals.h"
#include "WindowsOS.h"
#include "CPI_Player.h"
#include "CPI_Playlist.h"
#include "CPI_PlaylistItem.h"
#include "DLG_Find.h"
#include "CPI_PlaylistWindow.h"
#include "RotatingIcon.h"
#include "CPI_Indicators.h"




void    main_skin_select_menu(char *name)
{


    int     teller;
    char    skinstring[MAX_PATH];
    HMENU   popje = GetSubMenu(globals.main_menu_popup, 4);
    int     itemcounter =
        GetMenuItemCount(GetSubMenu(globals.main_menu_popup, 4));

    for (teller = 0; teller < itemcounter; teller++) {
        GetMenuString(popje, teller, skinstring, MAX_PATH, MF_BYPOSITION);

        if (strcmp(name, skinstring) == 0) {
            CheckMenuRadioItem(popje, 0, itemcounter, teller,
                               MF_BYPOSITION);
        }
    }
}

void    main_reset_window(HWND hWnd)
{
    HRGN    winregion;
    BITMAP  bm;
    GetObject(graphics.bmp_main_up, sizeof(bm), &bm);

    winregion =
        main_bitmap_to_region(graphics.bmp_main_up, Skin.transparentcolor);
    SetWindowPos(hWnd,		// handle to window
                 HWND_NOTOPMOST,	// placement-order handle
                 0,		// horizontal position
                 0,		// vertical position
                 bm.bmWidth,	// width
                 bm.bmHeight,	// height
                 SWP_NOMOVE | SWP_NOZORDER	// window-positioning flags
                );
    SetWindowRgn(hWnd, winregion, TRUE);
    CPI_Player__SetPositionRange(globals.m_hPlayer,
                                 Skin.Object[PositionSlider].maxw ? Skin.Object[PositionSlider].h : Skin.Object[PositionSlider].w);
    RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE);
}

void    main_skin_add_to_menu(char *name)
{

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

    for (teller = 0; teller < itemcounter; teller++) {
        char    skinstring[MAX_PATH];
        GetMenuString(GetSubMenu(globals.main_menu_popup, 4), teller,
                      skinstring, MAX_PATH, MF_BYPOSITION);
        if (strcmp(name, skinstring) == 0)
            return;
    }

    menuinfo.cbSize = sizeof(MENUITEMINFO);
    menuinfo.fMask = MIIM_TYPE | MIIM_ID;
    menuinfo.fType = MFT_STRING | MFT_RADIOCHECK;
    menuinfo.fState;

    if (globals.main_int_skin_last_number ==
            5001 +
            options.remember_skin_count) globals.main_int_skin_last_number =
                    5001;

    menuinfo.wID = globals.main_int_skin_last_number++;
    menuinfo.hSubMenu;
    menuinfo.hbmpChecked;
    menuinfo.hbmpUnchecked;
    menuinfo.dwItemData;
    menuinfo.cch = sizeof(menuinfo.dwTypeData);
    menuinfo.dwTypeData = name;
    InsertMenuItem(globals.main_menu_popup, MENU_SKIN_DEFAULT, FALSE,
                   &menuinfo);

    if (itemcounter > options.remember_skin_count) {
        RemoveMenu(GetSubMenu(globals.main_menu_popup, 4), 0,
                   MF_BYPOSITION);
    }
}

char   *str_trim(char *string)
{
    int     i = strlen(string) - 1;
    while (i >= 0 && string[i] == ' ')
        string[i--] = 0;
    while (*string == ' ')
        string++;
    return string;
}

DWORD   main_get_program_path(HINSTANCE hInst, LPTSTR pszBuffer,
                              DWORD dwSize)
//
//      Return the size of the path in bytes.
{
    DWORD   dwLength = GetModuleFileName(hInst, pszBuffer, dwSize);
    if (dwLength) {
        while (dwLength && pszBuffer[dwLength] != '\\') {
            dwLength--;
        }

        if (dwLength)
            pszBuffer[dwLength + 1] = '\0';
    }
    return dwLength;
}
//
//
//
int playlist_write()
{
    OPENFILENAME fn;
    BOOL bResult;
    char pcOutputName[MAX_PATH] = "";

    // Get filename to save
    fn.lStructSize = sizeof(OPENFILENAME);
    fn.hwndOwner = windows.m_hWndPlaylist;
    fn.hInstance = NULL;
    fn.lpstrFilter = "M3U Playlist Files (*.m3u)\0*.m3u\0PLS Playlist files (*.pls)\0*.pls\0";
    fn.lpstrCustomFilter = NULL;
    fn.nMaxCustFilter = 0;
    fn.nFilterIndex = 0;
    fn.lpstrFile = pcOutputName;
    fn.nMaxFile = MAX_PATH;
    fn.lpstrFileTitle = NULL;
    fn.nMaxFileTitle = 0;
    fn.lpstrInitialDir = options.last_used_directory;
    fn.lpstrTitle = NULL;
    fn.Flags = OFN_HIDEREADONLY
               | OFN_EXPLORER
               | OFN_OVERWRITEPROMPT
               | OFN_PATHMUSTEXIST
               | OFN_ENABLESIZING;
    fn.nFileOffset = 0;
    fn.nFileExtension = 0;
    fn.lpstrDefExt = "m3u";
    fn.lCustData = 0;
    fn.lpfnHook = NULL;
    fn.lpTemplateName = NULL;
    bResult = GetSaveFileName(&fn);
    if(bResult == FALSE)
        return FALSE;

    CPL_ExportPlaylist(globals.m_hPlaylist, pcOutputName);
    return TRUE;
}
//
//
//
void main_update_title_text()
{
    int     teller;
    HBITMAP h, h2;
    HPALETTE oldpal;
    const char* pcText;
    int     stringlen;
    int     width;
    CP_HPLAYLISTITEM hItem_Current;
    HDC SongtitleDc;
    int iG;

    iG = Skin.Object[SongtitleText].w;

    hItem_Current = CPL_GetActiveItem(globals.m_hPlaylist);
    if(hItem_Current)
        pcText = CPLI_GetTrackName(hItem_Current);
    else
        pcText = "CoolPlayer";

    stringlen = strlen(pcText);

    width = ((stringlen + 4) * Skin.Object[SongtitleText].w);
    if(stringlen > Skin.Object[SongtitleText].maxw)
        globals.mail_int_title_scroll_max_position = width;
    else
        globals.mail_int_title_scroll_max_position = 0;
    globals.main_int_title_scroll_position = 0;
    SongtitleDc = CreateCompatibleDC(drawables.dc_main);

    DeleteObject(graphics.bmp_main_title_area);
    graphics.bmp_main_title_area =
        CreateCompatibleBitmap(drawables.dc_main, width * 2,
                               Skin.Object[SongtitleText].h);

    h2 = SelectObject(SongtitleDc, graphics.bmp_main_title_area);
    oldpal = SelectPalette(SongtitleDc, graphics.pal_main, FALSE);

    RealizePalette(SongtitleDc);

    h = (HBITMAP) SelectObject(drawables.dc_memory, graphics.bmp_main_up);

    BitBlt(SongtitleDc, 0, 0,
           (Skin.Object[SongtitleText].maxw +
            1) * Skin.Object[SongtitleText].w,
           Skin.Object[SongtitleText].h, drawables.dc_memory,
           Skin.Object[SongtitleText].x, Skin.Object[SongtitleText].y,
           SRCCOPY);
    BitBlt(SongtitleDc, Skin.Object[SongtitleText].w * stringlen, 0,
           (Skin.Object[SongtitleText].maxw +
            1) * Skin.Object[SongtitleText].w,
           Skin.Object[SongtitleText].h, drawables.dc_memory,
           Skin.Object[SongtitleText].x, Skin.Object[SongtitleText].y,
           SRCCOPY);

    SelectObject(drawables.dc_memory, graphics.bmp_main_title_font);

    for (teller = 0; teller < stringlen; teller++) {
        BitBlt(SongtitleDc, (teller * Skin.Object[SongtitleText].w),
               0, Skin.Object[SongtitleText].w,
               Skin.Object[SongtitleText].h, drawables.dc_memory,
               Skin.Object[SongtitleText].w * (pcText[teller] - 32), 0,
               SRCCOPY);
        if (stringlen > Skin.Object[SongtitleText].maxw)
            BitBlt(SongtitleDc, width + (teller * Skin.Object[SongtitleText].w), 0,
                   Skin.Object[SongtitleText].w,
                   Skin.Object[SongtitleText].h, drawables.dc_memory,
                   Skin.Object[SongtitleText].w * (pcText[teller] - 32), 0,
                   SRCCOPY);
    }
    //     TextOut(SongtitleDc,0,0,text,stringlen);
    SelectPalette(SongtitleDc, oldpal, FALSE);
    SelectObject(drawables.dc_memory, h);
    SelectObject(SongtitleDc, h2);

    DeleteDC(SongtitleDc);

    // Setup systray text
    if(globals.m_hSysIcon && hItem_Current)
    {
        // If there is a track name and artist name - set the format %artist% - %track%
        if(CPLI_GetTrackName(hItem_Current) && CPLI_GetArtist(hItem_Current))
        {
            char cBuffer[2060];
            sprintf(cBuffer, "%.1024s - %.1024s", CPLI_GetArtist(hItem_Current), CPLI_GetTrackName(hItem_Current));

            CPSYSICON_SetTipText(globals.m_hSysIcon, cBuffer);
        }
        else
            CPSYSICON_SetTipText(globals.m_hSysIcon, pcText);
    }
}
//
//
//
void    main_draw_title(HWND hWnd)
{
    int     left = Skin.Object[SongtitleText].x;
    int     top = Skin.Object[SongtitleText].y;
    window_bmp_blt(hWnd, graphics.bmp_main_title_area,
                   Skin.Object[SongtitleText].x,
                   Skin.Object[SongtitleText].y,
                   (Skin.Object[SongtitleText].maxw +
                    1) * Skin.Object[SongtitleText].w,
                   Skin.Object[SongtitleText].h,
                   0 + globals.main_int_title_scroll_position, 0);
}

void    main_draw_bitrate(HWND hWnd)
{
    int     left = Skin.Object[BitrateText].x;
    int     top = Skin.Object[BitrateText].y;

    if (left) {
        int     teller;
        window_bmp_blt(hWnd, graphics.bmp_main_up, left, top,
                       3 * Skin.Object[SongtitleText].w,
                       Skin.Object[SongtitleText].h, left, top);

        for (teller = 0; globals.main_text_bitrate[teller]; teller++)
            window_bmp_blt(hWnd, graphics.bmp_main_title_font,
                           left + (teller * Skin.Object[SongtitleText].w),
                           top, Skin.Object[SongtitleText].w,
                           Skin.Object[SongtitleText].h,
                           Skin.Object[SongtitleText].w *
                           ((globals.main_text_bitrate[teller]) - 32), 0);
    }
}

void    main_draw_frequency(HWND hWnd)
{
    int     left = Skin.Object[FreqText].x;
    int     top = Skin.Object[FreqText].y;
    if (left) {
        int     teller;
        window_bmp_blt(hWnd, graphics.bmp_main_up, left, top,
                       2 * Skin.Object[SongtitleText].w,
                       Skin.Object[SongtitleText].h, left, top);

        for (teller = 0; globals.main_text_frequency[teller]; teller++)
            window_bmp_blt(hWnd, graphics.bmp_main_title_font,
                           left + (teller * Skin.Object[SongtitleText].w),
                           top, Skin.Object[SongtitleText].w,
                           Skin.Object[SongtitleText].h,
                           Skin.Object[SongtitleText].w *
                           ((globals.main_text_frequency[teller]) - 32),
                           0);
    }
}

void    main_set_eq(void)
{
    CPI_Player__SetEQ(globals.m_hPlayer, options.equalizer, options.eq_settings);
}

void    main_draw_time(HWND hWnd)
{
    int     top = Skin.Object[TimeText].y;
    int     left = Skin.Object[TimeText].x;
    int     height = Skin.Object[TimeText].h;
    int     width = Skin.Object[TimeText].w;
    unsigned long hrs, minutes, seconds;

    unsigned long ss = globals.main_int_track_total_seconds;

    if (left) {
        if (options.show_remaining_time == TRUE)
            ss = (globals.main_long_track_duration - ss);

        seconds = ss % 60;
        ss /= 60;
        minutes = ss % 60;
        ss /= 60;
        hrs = ss;

        // hours
        window_bmp_blt(hWnd, graphics.bmp_main_time_font, left + width,
                       top, width, height, width * hrs, 0);
        // Separator
        window_bmp_blt(hWnd, graphics.bmp_main_time_font,
                       left + (2 * width), top, width, height, width * 10,
                       0);
        // minutes
        window_bmp_blt(hWnd, graphics.bmp_main_time_font,
                       left + (3 * width), top, width, height,
                       width * (minutes / 10), 0);
        window_bmp_blt(hWnd, graphics.bmp_main_time_font,
                       left + (4 * width), top, width, height,

⌨️ 快捷键说明

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