📄 playlist.c
字号:
#include "stdafx.h"
#include "globals.h"
#include "CPI_Player.h"
#include "CPI_Playlist.h"
#include "CPI_PlaylistItem.h"
#include "CPI_ID3.h"
////////////////////////////////////////////////////////////////////////
//
//
//
void playlist_move_control(int ControlID, LPRECT NewPlaylistrect,
int type)
{
/*
RECT winrect;
int xsize, ysize;
HWND hwndDlg = windows.dlg_playlist;
HWND hwndControl = GetDlgItem(hwndDlg, ControlID);
GetWindowRect(hwndControl, // handle to window
&winrect); // address of structure for window coordinates
xsize = winrect.right - winrect.left;
ysize = winrect.bottom - winrect.top;
ScreenToClient(hwndDlg, // window handle for source coordinates
(LPPOINT) & winrect); // address of structure containing coordinates);
switch (type) {
case TOPRIGHT:
MoveWindow(hwndControl, // handle to window
winrect.left +
((NewPlaylistrect->right - globals.playlist_rect.right)
+ (globals.playlist_rect.left - NewPlaylistrect->left)), // horizontal position
winrect.top, //+NewPlaylistrect->top, // vertical position
xsize, // width
ysize, // height
TRUE); // repaint flag
break;
case RESIZE:
MoveWindow(hwndControl, // handle to window
winrect.left, // horizontal position
winrect.top, //+NewPlaylistrect->top, // vertical position
xsize +
((NewPlaylistrect->right - globals.playlist_rect.right)
+ (globals.playlist_rect.left - NewPlaylistrect->left)), // width
ysize +
((NewPlaylistrect->bottom
- globals.playlist_rect.bottom) +
(globals.playlist_rect.top - NewPlaylistrect->top)), // height
TRUE); // repaint flag
break;
case BOTTOMLEFT:
MoveWindow(hwndControl, // handle to window
winrect.left, // horizontal position
// horizontal position
winrect.top +
((NewPlaylistrect->bottom
- globals.playlist_rect.bottom) +
(globals.playlist_rect.top - NewPlaylistrect->top)), //+NewPlaylistrect->top, // vertical position
xsize, // width
ysize, // height
TRUE); // repaint flag
break;
case BOTTOMRIGHT:
MoveWindow(hwndControl, // handle to window
winrect.left +
((NewPlaylistrect->right - globals.playlist_rect.right)
+ (globals.playlist_rect.left - NewPlaylistrect->left)), // horizontal position
winrect.top +
((NewPlaylistrect->bottom
- globals.playlist_rect.bottom) +
(globals.playlist_rect.top - NewPlaylistrect->top)), //+NewPlaylistrect->top, // vertical position
xsize, // width
ysize, // height
TRUE); // repaint flag
break;
}
*/
}
BOOL playlist_skin_set_control_bitmap(char *position)
{
/*
HWND hDlg = windows.dlg_playlist;
HWND button;
unsigned int teller = 0;
char name[MAX_PATH];
int controlid = 0;
short i = 0;
LONG style;
UINT x = 0, y = 0, w = 0, h = 0;
char *items[] =
{ "Add", "Save", "AddDir", "Clear", "ClearSel", "MoveUp",
"MoveDown",
"Shuffle", "Close", "Close2",
"Minimize", "Maximize", "Find", NULL
};
UINT controlids[] =
{ IDC_OPENLIST, IDC_SAVELIST, IDC_ADDDIR, IDC_CLEAR, IDC_CLEARSEL,
IDC_MOVEUP, IDC_MOVEDOWN, IDC_SHUFFLE, IDOK, IDC_CLOSE, IDC_MINIMIZE,
IDC_MAXIMIZE, IDC_FIND,
0
};
RECT winrect;
WINDOWPLACEMENT wndpl;
if (IsIconic(hDlg)) {
wndpl.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(hDlg, &wndpl);
CopyRect(&winrect, &wndpl.rcNormalPosition);
} else
GetWindowRect(hDlg, &winrect);
winrect.right -= winrect.left;
winrect.bottom -= winrect.top;
winrect.left = 0;
winrect.top = 0;
while (teller < strlen(position)) {
if (position[teller] == '=' || position[teller] == ',')
position[teller] = ' ';
teller++;
}
sscanf(position, "%s %d %d %d %d", name, &x, &y, &w, &h);
while (items[i] != NULL) {
if (!stricmp(name, items[i])) {
controlid = controlids[i];
break;
};
i++;
}
if (!stricmp(name, "List")) {
button = GetDlgItem(hDlg, IDC_PLAYLIST);
SetWindowPos(button, NULL, x, y, winrect.right - w - x,
winrect.bottom - h - y,
SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOREDRAW);
return TRUE;
}
if (controlid) {
BITMAP bm;
char playlistbitmapfile[MAX_PATH];
char pathname[MAX_PATH];
button = GetDlgItem(hDlg, controlid);
style = GetWindowLong(button, GWL_STYLE);
style |= BS_OWNERDRAW;
SetWindowLong(button, GWL_STYLE, style);
SetWindowLong(button, GWL_USERDATA, w);
strcpy(playlistbitmapfile, options.playlist_skin_file);
path_remove_filespec(playlistbitmapfile);
sprintf(pathname, "%s%s.bmp", playlistbitmapfile, name);
DeleteObject(PlayListBitmap.bm[i]);
PlayListBitmap.bm[i] =
LoadImage(0, pathname, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE);
if (!PlayListBitmap.bm[i])
ShowWindow(GetDlgItem(hDlg, controlid), SW_HIDE);
GetObject(PlayListBitmap.bm[i], sizeof(bm), &bm);
SetWindowPos(GetDlgItem(hDlg, controlid), NULL, 0, 0,
bm.bmWidth, bm.bmHeight / 2,
SWP_NOREDRAW | SWP_NOMOVE | SWP_NOOWNERZORDER |
SWP_NOZORDER);
switch (w) {
case BOTTOMRIGHT:
SetWindowPos(button, NULL, winrect.right - x,
winrect.bottom - y, 0, 0,
SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER
| SWP_NOREDRAW);
break;
case TOPRIGHT:
SetWindowPos(button, NULL, winrect.right - x, y, 0, 0,
SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER
| SWP_NOREDRAW);
break;
case BOTTOMLEFT:
SetWindowPos(button, NULL, x, winrect.bottom - y, 0, 0,
SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER
| SWP_NOREDRAW);
break;
case TOPLEFT:
SetWindowPos(button, NULL, x, y, 0, 0,
SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOZORDER
| SWP_NOREDRAW);
break;
}
return TRUE;
}
*/
return FALSE;
}
BOOL playlist_skin_get_ini_value(char *key, char *position, SIZE * rect)
{
/*
SIZE readrect;
while (*position != 0) {
unsigned int teller = 0;
char name[MAX_PATH];
while (teller < strlen(position)) {
if (position[teller] == '=' || position[teller] == ',')
position[teller] = ' ';
teller++;
}
sscanf(position, "%s %i %i", name, &readrect.cx, &readrect.cy);
if (!stricmp(name, key)) {
rect->cx = readrect.cx;
rect->cy = readrect.cy;
return TRUE;
}
position = position + strlen(position) + 1;
}
*/
return FALSE;
}
/*
You should add your initialization code here. This function will be called
when the dialog box receives the WM_INITDIALOG message.
*/
int playlist_skin_read()
{
/*
char values[32768];
char playlistfile[MAX_PATH];
char playlistbitmapfile[MAX_PATH];
char *position;
char buffer[4096];
HWND hDlg = windows.dlg_playlist;
int i = 0;
UINT controlids[] =
{ IDC_OPENLIST, IDC_SAVELIST, IDC_ADDDIR, IDC_CLEAR, IDC_CLEARSEL,
IDC_MOVEUP, IDC_MOVEDOWN, IDC_SHUFFLE, IDOK, IDC_CLOSE,
IDC_MINIMIZE, IDC_MAXIMIZE, IDC_FIND,
0
};
while (controlids[i] != 0)
SetWindowLong(GetDlgItem(hDlg, controlids[i++]), GWL_USERDATA, 0);
if (!*options.playlist_skin_file || !options.use_playlist_skin)
return FALSE;
GetPrivateProfileString(NULL, NULL, NULL,
buffer, sizeof(buffer),
options.playlist_skin_file);
if (GetPrivateProfileSection
("Playlist", values, 32767, options.playlist_skin_file) == 0) {
MessageBox(hDlg, "Can\'t open ini file!",
options.playlist_skin_file,
MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST);
} // points to initialization filename
strcpy(playlistfile, options.playlist_skin_file);
path_remove_filespec(playlistfile);
position = values;
while (*position != 0) {
playlist_skin_set_control_bitmap(position);
position = position + strlen(position) + 1;
}
sprintf(playlistbitmapfile, "%sPlaylist.bmp", playlistfile);
DeleteObject(graphics.bmp_playlist_bg);
graphics.bmp_playlist_bg =
LoadImage(0, playlistbitmapfile, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE);
if (!graphics.bmp_playlist_bg)
MessageBox(hDlg, "Can\'t load bitmap", playlistbitmapfile,
MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST);
position = values;
playlist_skin_get_ini_value("UpLeft", position,
&PlayListBitmap.UpLeft);
position = values;
playlist_skin_get_ini_value("UpRight", position,
&PlayListBitmap.UpRight);
position = values;
playlist_skin_get_ini_value("DownLeft", position,
&PlayListBitmap.DownLeft);
position = values;
playlist_skin_get_ini_value("DownRight", position,
&PlayListBitmap.DownRight);
position = values;
playlist_skin_get_ini_value("UpMid", position, &PlayListBitmap.UpMid);
position = values;
playlist_skin_get_ini_value("DownMid", position,
&PlayListBitmap.DownMid);
position = values;
playlist_skin_get_ini_value("LeftMid", position,
&PlayListBitmap.LeftMid);
position = values;
playlist_skin_get_ini_value("RightMid", position,
&PlayListBitmap.RightMid);
position = values;
playlist_skin_get_ini_value("MinSize", position,
&PlayListBitmap.MinSize);
position = values;
playlist_skin_get_ini_value("Colors", position,
&PlayListBitmap.Colors);
if (PlayListBitmap.UpLeft.cx) {
LONG style;
HWND button;
LONG data;
style = GetWindowLong(hDlg, GWL_STYLE);
style &= ~WS_CAPTION;
style &= ~WS_THICKFRAME;
style &= ~WS_BORDER;
SetWindowLong(hDlg, GWL_STYLE, style);
ShowWindow(GetDlgItem(hDlg, IDC_MINIMIZE), SW_SHOW);
ShowWindow(GetDlgItem(hDlg, IDC_MAXIMIZE), SW_SHOW);
ShowWindow(GetDlgItem(hDlg, IDC_CLOSE), SW_SHOW);
ShowWindow(GetDlgItem(hDlg, IDC_SORTTEXT), SW_HIDE);
ShowWindow(GetDlgItem(hDlg, IDC_MOVETEXT), SW_HIDE);
// Check for the find button.
button = GetDlgItem(hDlg, IDC_FIND);
data = GetWindowLong(button, GWL_USERDATA);
if (!data) {
ShowWindow(button, SW_HIDE);
} else
ShowWindow(button, SW_SHOW);
} else
return FALSE;
*/
return 1;
}
void playlist_draw_control(UINT controlid, LPDRAWITEMSTRUCT ds)
{
/*
HDC winmemdc = CreateCompatibleDC(ds->hDC);
HBITMAP h;
HBITMAP image;
HPALETTE oldpal;
int height = 0, i = 0;
UINT controlids[] =
{ IDC_OPENLIST, IDC_SAVELIST, IDC_ADDDIR, IDC_CLEAR, IDC_CLEARSEL,
IDC_MOVEUP, IDC_MOVEDOWN, IDC_SHUFFLE, IDOK, IDC_CLOSE, IDC_MINIMIZE,
IDC_MAXIMIZE, IDC_FIND, 0
};
while (controlids[i] != 0) {
if (controlids[i] == ds->CtlID) {
image = PlayListBitmap.bm[i];
break;
}
i++;
}
if (ds->itemState & ODS_SELECTED) {
height = ds->rcItem.bottom;
}
h = (HBITMAP) SelectObject(winmemdc, image);
oldpal = SelectPalette(ds->hDC, graphics.pal_main, FALSE);
RealizePalette(ds->hDC);
BitBlt(ds->hDC, 0, 0, ds->rcItem.right, ds->rcItem.bottom, winmemdc,
0, height, SRCCOPY);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -