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

📄 skin.c

📁 < VC++视频音频开发>> 这本书的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
        positionpercentage =
            (float) globals.main_int_track_position /
            (float) Skin.Object[PositionSlider].h;
    } else {
        positionpercentage =
            (float) globals.main_int_track_position /
            (float) Skin.Object[PositionSlider].w;
    }
    globals.main_int_title_scroll_position = 0;
    globals.mail_int_title_scroll_max_position = 0;
    if (*options.main_skin_file == 0) {
        MessageBox(GetForegroundWindow(), "No Skin file selected!",
                   "Error", MB_ICONERROR);
        options.use_default_skin = TRUE;
        return FALSE;
    } else
        strcpy(pathbuf, options.main_skin_file);
    memset(&Skin, 0, sizeof(Skin));
    GetPrivateProfileString(NULL, NULL, NULL,
                            buffer, sizeof(buffer), pathbuf);
    returnval = GetPrivateProfileSection("CoolPlayer Skin",	
                                         values,
                                         32767,	
                                         pathbuf	
                                        );
    if (returnval == 0) {
        char    textbuf[MAX_PATH + 50];
        sprintf(textbuf, "Not a valid CoolPlayer Skin file: %s", pathbuf);
        MessageBox(GetForegroundWindow(), textbuf, "error", MB_ICONERROR);
        options.use_default_skin = TRUE;
        return FALSE;
    }
    textposition = values;
    while (*textposition != 0) {

        main_skin_check_ini_value(textposition, associate);
        textposition = textposition + strlen(textposition) + 1;
    }
    path_remove_filespec(pathbuf);
    strcat(pathbuf, Skin.CoolUp);
    hInstance = GetModuleHandle(NULL);
    DeleteObject(graphics.bmp_main_up);
    graphics.bmp_main_up =
        (HBITMAP) LoadImage(hInstance, pathbuf, IMAGE_BITMAP, 0, 0,
                            LR_LOADFROMFILE);
    if (!graphics.bmp_main_up) {
        strcat(errorbuf, pathbuf);
        strcat(errorbuf, "\n");
    }
    path_remove_filespec(pathbuf);
    strcat(pathbuf, Skin.CoolDown);
    DeleteObject(graphics.bmp_main_down);
    graphics.bmp_main_down =
        (HBITMAP) LoadImage(hInstance, pathbuf, IMAGE_BITMAP, 0, 0,
                            LR_LOADFROMFILE);
    if (!graphics.bmp_main_down) {
        strcat(errorbuf, pathbuf);
        strcat(errorbuf, "\n");
    }
    path_remove_filespec(pathbuf);
    strcat(pathbuf, Skin.CoolSwitch);
    DeleteObject(graphics.bmp_main_switch);
    graphics.bmp_main_switch =
        (HBITMAP) LoadImage(hInstance, pathbuf, IMAGE_BITMAP, 0, 0,
                            LR_LOADFROMFILE);
    if (!graphics.bmp_main_switch) {
        strcat(errorbuf, pathbuf);
        strcat(errorbuf, "\n");
    }
    path_remove_filespec(pathbuf);
    strcat(pathbuf, Skin.aTimeFont);
    DeleteObject(graphics.bmp_main_time_font);
    graphics.bmp_main_time_font =
        (HBITMAP) LoadImage(hInstance, pathbuf, IMAGE_BITMAP, 0, 0,
                            LR_LOADFROMFILE);
    if (!graphics.bmp_main_time_font) {
        strcat(errorbuf, pathbuf);
        strcat(errorbuf, "\n");
    }
    path_remove_filespec(pathbuf);
    strcat(pathbuf, Skin.aTrackFont);
    DeleteObject(graphics.bmp_main_track_font);
    graphics.bmp_main_track_font =
        (HBITMAP) LoadImage(hInstance, pathbuf, IMAGE_BITMAP, 0, 0,
                            LR_LOADFROMFILE);
    if (!graphics.bmp_main_track_font) {
        strcat(errorbuf, pathbuf);
        strcat(errorbuf, "\n");
    }
    path_remove_filespec(pathbuf);
    strcat(pathbuf, Skin.aTextFont);
    DeleteObject(graphics.bmp_main_title_font);
    graphics.bmp_main_title_font =
        (HBITMAP) LoadImage(hInstance, pathbuf, IMAGE_BITMAP, 0, 0,
                            LR_LOADFROMFILE);
    if (!graphics.bmp_main_title_font) {
        strcat(errorbuf, pathbuf);
        strcat(errorbuf, "\n");
    }
    if (!graphics.bmp_main_up || !graphics.bmp_main_down
            || !graphics.bmp_main_switch || !graphics.bmp_main_time_font
            || !graphics.bmp_main_title_font || !graphics.bmp_main_track_font) {
        char    errorstring[5000];

        sprintf(errorstring, "Can\'t load bitmaps!\n%s", errorbuf);
        MessageBox(GetForegroundWindow(), errorstring, "error",
                   MB_ICONERROR);
        options.use_default_skin = TRUE;
        return FALSE;

    }
    if (Skin.Object[PositionSlider].maxw == 1) {
        globals.main_int_track_position =
            (int) ((float) (Skin.Object[PositionSlider].h) *
                   positionpercentage);

    } else {
        globals.main_int_track_position =
            (int) ((float) (Skin.Object[PositionSlider].w) *
                   positionpercentage);
    }
    main_update_title_text();
    return 1;
}

void    main_skin_check_ini_value(char *textposition,
                                  Associate * associate)
{
    char    name[128] = "";
    int     x = 0, y = 0, w = 0, h = 0, maxw = 0, x2 = 0, y2 = 0, w2 =
                                         0, h2 = 0;
    char    tooltip[100] = "";
    int teller = 0;

    while (teller < strlen(textposition)) {
        if (textposition[teller] == '=' || textposition[teller] == ',')
            textposition[teller] = ' ';
        teller++;
    }
    sscanf(textposition, "%s %d %d %d %d %d %d %d %d %d %[^\0]", name, &x,
           &y, &w, &h, &maxw, &x2, &y2, &w2, &h2, tooltip);
    for (teller = 0; teller < Lastone; teller++) {
        if (stricmp(name, associate[teller].name) == 0) {
            main_skin_set_struct_value(associate[teller].Object, x, y, w,
                                       h, maxw, x2, y2, w2, h2, tooltip);
            return;
        }
        if (stricmp(name, "PlaylistSkin") == 0) {
            char    pathbuf[MAX_PATH];
            if (path_is_relative(textposition + strlen(name) + 1)) {
                strcpy(pathbuf, options.main_skin_file);
                path_remove_filespec(pathbuf);
                strcat(pathbuf, textposition + strlen(name) + 1);
            } else
                strcpy(pathbuf, textposition + strlen(name) + 1);
            if (!globals.playlist_bool_force_skin_from_options)
                strcpy(options.playlist_skin_file, pathbuf);
        }
        if (stricmp(name, "transparentcolor") == 0) {
            int     colortext;
            sscanf(textposition, "%s %x", name, &colortext);
            Skin.transparentcolor = colortext;
            return;
        }
        if (stricmp(name, "BmpCoolUp") == 0) {
            strcpy(Skin.CoolUp, textposition + strlen(name) + 1);
        }

        if (stricmp(name, "BmpCoolDown") == 0) {
            strcpy(Skin.CoolDown, textposition + strlen(name) + 1);
        }

        if (stricmp(name, "BmpCoolSwitch") == 0) {
            strcpy(Skin.CoolSwitch, textposition + strlen(name) + 1);
        }

        if (stricmp(name, "BmpTextFont") == 0) {
            strcpy(Skin.aTextFont, textposition + strlen(name) + 1);
        }
        if (stricmp(name, "BmpTimeFont") == 0) {
            strcpy(Skin.aTimeFont, textposition + strlen(name) + 1);
        }
        if (stricmp(name, "BmpTrackFont") == 0) {
            strcpy(Skin.aTrackFont, textposition + strlen(name) + 1);
        }
        if (stricmp(name, "NextSkin") == 0) {
            if (stricmp(textposition + strlen(name) + 1, "default") == 0) {
                globals.main_bool_skin_next_is_default = TRUE;
            } else {
                char    drive[_MAX_DRIVE];
                char    fname[MAX_PATH];
                char    modpathbuf[MAX_PATH];
                char    ext[_MAX_EXT];
                char    dir[_MAX_DIR];
                char    skinfile2[MAX_PATH];
                strcpy(skinfile2, options.main_skin_file);
                path_remove_filespec(skinfile2);

                main_get_program_path(GetModuleHandle(NULL), modpathbuf,
                                      MAX_PATH);
                _splitpath(textposition + strlen(name) + 1, drive, dir,
                           fname, ext);
                if (strcmp(drive, "") == 0) {
                    sprintf(options.main_skin_file, "%s%s%s", skinfile2,
                            fname, ext);
                } else
                    strcpy(options.main_skin_file,
                           textposition + strlen(name) + 1);
                if (_access(options.main_skin_file, 0) == -1) {
                    sprintf(options.main_skin_file, "%s%s%s%s", modpathbuf,
                            dir, fname, ext);
                }
                globals.main_bool_skin_next_is_default = FALSE;
            }
        }
    }
}

⌨️ 快捷键说明

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