📄 main.c
字号:
}
else if(globals.main_bool_slider_keep_focus == FALSE)
{
if (Skin.Object[teller].maxw == 0)
{
globals.main_int_track_position = cursorpos.x - Skin.Object[teller].x;
CPI_Player__Seek(globals.m_hPlayer, globals.main_int_track_position, Skin.Object[teller].w);
}
else
{
globals.main_int_track_position = ((Skin.Object[teller].y + Skin.Object[teller].h) - cursorpos.y);
CPI_Player__Seek(globals.m_hPlayer, globals.main_int_track_position, Skin.Object[teller].h);
}
waarde=globals.main_int_track_position;
}
break;
}
// main_draw_vu_from_mouse(hWnd, teller, Skin.Object[teller].maxw ? cursorpos.y : cursorpos.x);
main_draw_vu_from_value(hWnd, teller, waarde);
}
}
return moveit;
}
int window_bmp_blt(HWND hWnd, HBITMAP SrcBmp, int srcx, int srcy, int srcw, int srch, int dstx, int dsty)
{
if (srcw && srch) {
HBITMAP h = (HBITMAP) SelectObject(drawables.dc_memory, SrcBmp);
int retval = BitBlt(drawables.dc_main, srcx, srcy, srcw, srch,
drawables.dc_memory, dstx, dsty,
SRCCOPY);
SelectObject(drawables.dc_memory, h);
return retval;
}
return FALSE;
}
void main_draw_controls_all(HWND hWnd)
{
int teller;
for (teller = PlaySwitch; teller <= ExitButton; teller++) {
window_bmp_blt(hWnd, graphics.bmp_main_up, Skin.Object[teller].x,
Skin.Object[teller].y, Skin.Object[teller].w,
Skin.Object[teller].h, Skin.Object[teller].x,
Skin.Object[teller].y);
window_bmp_blt(hWnd, graphics.bmp_main_up, Skin.Object[teller].x2,
Skin.Object[teller].y2, Skin.Object[teller].w2,
Skin.Object[teller].h2, Skin.Object[teller].x2,
Skin.Object[teller].y2);
switch (teller) {
case RepeatSwitch:
if (options.repeat_playlist)
window_bmp_blt(hWnd, graphics.bmp_main_switch,
Skin.Object[RepeatSwitch].x2,
Skin.Object[RepeatSwitch].y2,
Skin.Object[RepeatSwitch].w2,
Skin.Object[RepeatSwitch].h2,
Skin.Object[RepeatSwitch].x2,
Skin.Object[RepeatSwitch].y2);
break;
case ShuffleSwitch:
if (options.shuffle_play)
window_bmp_blt(hWnd, graphics.bmp_main_switch,
Skin.Object[ShuffleSwitch].x2,
Skin.Object[ShuffleSwitch].y2,
Skin.Object[ShuffleSwitch].w2,
Skin.Object[ShuffleSwitch].h2,
Skin.Object[ShuffleSwitch].x2,
Skin.Object[ShuffleSwitch].y2);
break;
case EqSwitch:
if (options.equalizer)
window_bmp_blt(hWnd, graphics.bmp_main_switch,
Skin.Object[EqSwitch].x2,
Skin.Object[EqSwitch].y2,
Skin.Object[EqSwitch].w2,
Skin.Object[EqSwitch].h2,
Skin.Object[EqSwitch].x2,
Skin.Object[EqSwitch].y2);
break;
case PlaySwitch:
if(globals.m_enPlayerState == cppsPlaying)
window_bmp_blt(hWnd, graphics.bmp_main_switch,
Skin.Object[teller].x2,
Skin.Object[teller].y2,
Skin.Object[teller].w2,
Skin.Object[teller].h2,
Skin.Object[teller].x2,
Skin.Object[teller].y2);
break;
case PauseSwitch:
if(globals.m_enPlayerState == cppsPaused)
window_bmp_blt(hWnd, graphics.bmp_main_switch,
Skin.Object[teller].x2,
Skin.Object[teller].y2,
Skin.Object[teller].w2,
Skin.Object[teller].h2,
Skin.Object[teller].x2,
Skin.Object[teller].y2);
break;
case StopSwitch:
if(globals.m_enPlayerState == cppsStopped)
window_bmp_blt(hWnd, graphics.bmp_main_switch,
Skin.Object[teller].x2,
Skin.Object[teller].y2,
Skin.Object[teller].w2,
Skin.Object[teller].h2,
Skin.Object[teller].x2,
Skin.Object[teller].y2);
break;
}
}
}
void options_create(HWND hWnd)
{
windows.dlg_options = CreateDialog(GetModuleHandle(NULL), // handle to application instance
MAKEINTRESOURCE(IDD_OPTIONS), // identifies dialog box template
hWnd, // handle to owner window
options_windowproc); // pointer to dialog box procedure
ShowWindow(windows.dlg_options, SW_SHOWNORMAL);
}
void url_create(HWND hWnd)
{
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_URL),
hWnd, url_windowproc);
}
void main_menuproc(HWND hWnd, LPPOINT points)
{
int retval;
/* SetForegroundWindow and the ensuing null PostMessage is a
workaround for a Windows 95 bug (see MSKB article Q135788,
http://www.microsoft.com/kb/articles/q135/7/88.htm, I think).
In typical Microsoft style this bug is listed as "by design".
SetForegroundWindow also causes our MessageBox to pop up in front
of any other application's windows. */
SetForegroundWindow(hWnd);
/* We specifiy TPM_RETURNCMD, so TrackPopupMenu returns the menu
selection instead of returning immediately and our getting a
WM_COMMAND with the selection. You don't have to do it this way.
*/
switch (retval =
TrackPopupMenu(globals.main_menu_popup,
TPM_RETURNCMD | TPM_RIGHTBUTTON, points->x,
points->y, 0, hWnd, NULL)) // LPRECT user can click in
// without dismissing menu
{
case MENU_EXIT:
DestroyWindow(hWnd);
break;
case MENU_PLAYLIST:
CPVERB_TogglePlaylistWindow(vaDoVerb, hWnd);
break;
case MENU_OPENFILE:
main_play_control(ID_LOAD, hWnd);
break;
case MENU_ABOUT:
about_create(hWnd);
break;
case MENU_OPENLOC:
url_create(hWnd);
break;
case MENU_OPTIONS:
options_create(hWnd);
break;
case MENU_SKIN_DEFAULT:
{
options.use_default_skin = TRUE;
globals.main_bool_skin_next_is_default = TRUE;
main_play_control(ID_LOADSKIN, hWnd);
break;
}
default:
{
if (main_play_control((WORD) retval, hWnd) != -1)
break;
if (GetMenuString
(globals.main_menu_popup, retval, NULL, 0, MF_BYCOMMAND)) {
GetMenuString(globals.main_menu_popup, retval,
options.main_skin_file, MAX_PATH,
MF_BYCOMMAND);
main_skin_select_menu(options.main_skin_file);
options.use_default_skin = FALSE;
globals.main_bool_skin_next_is_default = FALSE;
main_play_control(ID_LOADSKIN, hWnd);
}
break;
}
}
PostMessage(hWnd, 0, 0, 0); // see above
}
LRESULT CALLBACK
main_windowproc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// Give the player a crack at the messages - it needs these so that it can call the notification callbacks
if(globals.m_hPlayer)
{
LRESULT lResult;
const BOOL bHandled = CPI_Player__HandleNotifyMessages(globals.m_hPlayer, message, wParam, lParam, &lResult);
if(bHandled == TRUE)
return lResult;
}
switch (message) {
POINTS cursorpos;
case WM_TIMER:
if (wParam == CPC_TIMERID_SCROLLTITLETEXT) {
main_draw_title(hWnd);
if(globals.mail_int_title_scroll_max_position == 0)
globals.main_int_title_scroll_position = 0;
else
{
globals.main_int_title_scroll_position++;
if(globals.main_int_title_scroll_position > globals.mail_int_title_scroll_max_position)
globals.main_int_title_scroll_position -= globals.mail_int_title_scroll_max_position;
}
}
else if(wParam == CPC_TIMERID_INTERTRACKDELAY)
{
KillTimer(hWnd, CPC_TIMERID_INTERTRACKDELAY);
CPL_PlayItem(globals.m_hPlaylist, FALSE, pmNextItem);
}
else if(wParam == CPC_TIMERID_ROTATINGSMILY)
{
CPSYSICON_AdvanceFrame(globals.m_hSysIcon);
}
break;
case WM_MOUSEWHEEL:
{
short zDelta = (short) HIWORD(wParam);
if (zDelta < 0)
globals.m_iVolume -= 5;
else
globals.m_iVolume += 5;
if (globals.m_iVolume > 100)
globals.m_iVolume = 100;
if (globals.m_iVolume < 0)
globals.m_iVolume = 0;
main_draw_vu_from_value(hWnd, VolumeSlider, globals.m_iVolume);
CPI_Player__SetVolume(globals.m_hPlayer, globals.m_iVolume);
return 0;
}
case WM_COPYDATA:
{
PCOPYDATASTRUCT copydata = (PCOPYDATASTRUCT) lParam;
int i=0,count=0;
BOOL wegotsome;
char *string=copydata->lpData;
int argc = copydata->dwData;
char *argv[255]={0};
while(count<argc)
{
argv[count++]=string;
string+=strlen(string)+1;
}
cmdline_parse_options(argc,argv);
wegotsome = cmdline_parse_files(argc,argv);
if (globals.playlist_bool_addsong == FALSE
&& wegotsome == TRUE) {
CPL_PlayItem(globals.m_hPlaylist, TRUE, pmCurrentItem);
}
main_draw_controls_all(hWnd);
main_set_eq();
globals.playlist_bool_addsong = FALSE;
globals.playlist_last_add_time = GetTickCount();
break;
}
case WM_NOTIFYICON:
switch (lParam) {
case WM_RBUTTONUP:
{
POINT pt;
GetCursorPos(&pt);
main_menuproc(hWnd, &pt);
}
break;
case WM_MBUTTONUP:
if(globals.m_enPlayerState == cppsPlaying || globals.m_enPlayerState == cppsPaused)
CPVERB_Pause(vaDoVerb, hWnd);
break;
case WM_LBUTTONUP:
{
RECT rcClip;
RECT rcClient;
int Result;
GetClientRect(hWnd, &rcClient);
Result = GetClipBox(drawables.dc_main, &rcClip);
if (Result == COMPLEXREGION
&& EqualRect(&rcClip, &rcClient)) {
if (options.show_on_taskbar)
ShowWindow(hWnd, SW_MINIMIZE);
else
ShowWindow(hWnd, SW_HIDE);
} else {
ShowWindow(hWnd, SW_RESTORE);
}
}
BringWindowToTop(hWnd);
SetForegroundWindow(hWnd);
break;
}
break;
case WM_CREATE:
if(options.scroll_track_title)
SetTimer(hWnd, CPC_TIMERID_SCROLLTITLETEXT, 50, NULL);
else
KillTimer(hWnd, CPC_TIMERID_SCROLLTITLETEXT);
SetTimer(hWnd, CPC_TIMERID_ROTATINGSMILY, 100, NULL);
break;
case WM_RBUTTONDOWN:
{
POINT points;
GetCursorPos(&points);
main_menuproc(hWnd, &points);
break;
}
case WM_CAPTURECHANGED:
ReleaseCapture();
break;
case WM_LBUTTONDOWN:
{
int teller;
BOOL moveit = TRUE;
SetCapture(hWnd);
cursorpos = MAKEPOINTS(lParam);
for (teller = 0; teller <= ExitButton; teller++) {
if (cursorpos.x >= Skin.Object[teller].x
&& cursorpos.y >= Skin.Object[teller].y
&& cursorpos.x <=
Skin.Object[teller].x + Skin.Object[teller].w
&& cursorpos.y <=
Skin.Object[teller].y + Skin.Object[teller].h) {
window_bmp_blt(hWnd, graphics.bmp_main_down,
Skin.Object[teller].x,
Skin.Object[teller].y,
Skin.Object[teller].w,
Skin.Object[teller].h,
Skin.Object[teller].x,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -