📄 dialogs.c
字号:
WNDCLASS wc; int x, y; if(add) addurl = 1; if(FindWindow(NULL, "MPlayer - Open URL...")) return; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = OpenUrlWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hIcon = gui->icon; wc.hbrBackground = SOLID_GREY2; wc.lpszClassName = "MPlayer - URL"; wc.lpszMenuName = NULL; RegisterClass(&wc); x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (320 / 2); y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2); hWnd = CreateWindow("MPlayer - URL", "MPlayer - Open URL...", WS_POPUPWINDOW | WS_CAPTION, x, y, 320, 100, NULL, NULL, hInstance, NULL); SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); ShowWindow(hWnd, SW_SHOW); UpdateWindow(hWnd);}static void create_playlistmenu(gui_t *gui){ gui->playlistmenu = CreatePopupMenu(); AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDFILE, "Add File..."); AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDURL, "Add Url..."); AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0); AppendMenu(gui->playlistmenu, MF_STRING, ID_REMOVE, "Remove Selected"); AppendMenu(gui->playlistmenu, MF_STRING, ID_CLEAR, "Clear Playlist"); AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0); AppendMenu(gui->playlistmenu, MF_STRING, ID_CLOSE, "Close");}static void updatetracklist(HWND hwnd){ int i=0; gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); /* clear listbox */ SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_RESETCONTENT, 0, 0); for (i=0; i < gui->playlist->trackcount; i++) if (gui->playlist->tracks[i]->title) SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->title); else SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->filename);}static LRESULT CALLBACK PlayListWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam){ HWND wdg; POINT cursor; gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); playlist_t *pl = gui ? gui->playlist : NULL; switch (iMsg) { case WM_CREATE: { wdg = CreateWindow("button", "Play", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 4, 10, 80, 25, hwnd, (HMENU) ID_PLAY, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); wdg = CreateWindow ("button", "Up", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 4, 37, 80, 25, hwnd, (HMENU) ID_UP, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); SendMessage(wdg, WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); wdg = CreateWindow ("button", "Down", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 4, 64, 80, 25, hwnd, (HMENU) ID_DOWN, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); wdg = CreateWindow ("button", "Remove", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 4, 91, 80, 25, hwnd, (HMENU) ID_REMOVE, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); wdg = CreateWindow ("button", "Load", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 4, 118, 80, 25, hwnd, (HMENU) ID_PLAYLISTLOAD, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); wdg = CreateWindow ("button", "Save", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 4, 145, 80, 25, hwnd, (HMENU) ID_PLAYLISTSAVE, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); wdg = CreateWindow ("button", "Close", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 4, 193, 80, 25, hwnd, (HMENU) ID_CLOSE, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0); wdg = CreateWindow ("listbox", "tracklist", WS_CHILD | WS_VISIBLE | LBS_NOTIFY | WS_VSCROLL | WS_HSCROLL | LBS_DISABLENOSCROLL, 92, 10, 300, 208, hwnd, (HMENU) ID_TRACKLIST, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); SendMessage(wdg, LB_SETHORIZONTALEXTENT, MAX_PATH*4, 0); break; } case WM_CONTEXTMENU: { GetCursorPos(&cursor); SetForegroundWindow(hwnd); TrackPopupMenu(gui->playlistmenu, 0, cursor.x, cursor.y, 0, hwnd, NULL); break; } case WM_COMMAND: { int selected = 0; int i; for (i=0; i<pl->trackcount; i++) if(0 < SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_GETSEL, i, 0)) selected = i + 1; switch (LOWORD(wParam)) { case ID_CLOSE: DestroyWindow(hwnd); return 0; case ID_TRACKLIST: if(HIWORD(wParam) == LBN_DBLCLK) { case ID_PLAY: if(selected) pl->current = selected - 1; mplSetFileName(NULL, pl->tracks[pl->current]->filename, STREAMTYPE_STREAM); gui->startplay(gui); } return 0; case ID_UP: { if(selected) pl->moveup_track(pl, selected); selected--; break; } case ID_DOWN: { if(selected) pl->movedown_track(pl, selected); selected++; break; } case ID_REMOVE: if(selected) pl->remove_track(pl, selected); break; case ID_ADDFILE: { if(guiIntfStruct.StreamType == STREAMTYPE_DVD || guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; display_openfilewindow(gui, 1); break; } case ID_ADDURL: { if(guiIntfStruct.StreamType == STREAMTYPE_DVD || guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; display_openurlwindow(gui, 1); break; } case ID_CLEAR: { if(!gui->playlist->trackcount) return 0; gui->playlist->clear_playlist(gui->playlist); break; } case ID_PLAYLISTLOAD: { if(guiIntfStruct.StreamType == STREAMTYPE_DVD || guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; display_loadplaylistwindow(gui); break; } case ID_PLAYLISTSAVE: { /* no point saving an empty playlist */ if(!gui->playlist->trackcount || guiIntfStruct.StreamType == STREAMTYPE_DVD || guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0; display_saveplaylistwindow(gui); break; } } updatetracklist(hwnd); if(selected < 1) selected = 1; else if(selected>pl->trackcount) selected = pl->trackcount; SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_SETCURSEL, selected - 1, 0); return 0; } case WM_DROPFILES: { char file[MAX_PATH]; int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH); int i; for (i=0; i<filecount; i++) { DragQueryFile((HDROP) wParam, i, file, MAX_PATH); if(!parse_filename(file, playtree, mconfig, 0)) pl->add_track(pl, file, NULL, NULL, 0); } DragFinish((HDROP) wParam); updatetracklist(hwnd); } break; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, iMsg, wParam, lParam);}void update_playlistwindow(void){ HWND hWnd = FindWindow(NULL, "MPlayer Playlist"); if (hWnd) updatetracklist(hWnd);}void display_playlistwindow(gui_t *gui){ HWND hWnd = FindWindow(NULL, "MPlayer Playlist"); HINSTANCE hInstance = GetModuleHandle(NULL); WNDCLASS wc; int x, y; if (hWnd) { SendMessage(hWnd, WM_CLOSE, 0, 0); return; } wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = PlayListWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL,IDC_ARROW); wc.hIcon = gui->icon; wc.hbrBackground = SOLID_GREY2; wc.lpszClassName = "MPlayer - Playlist"; wc.lpszMenuName = NULL; RegisterClass(&wc); create_playlistmenu(gui); x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (400 / 2); /* Erik: center popup window on screen */ y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (254 / 2); hWnd = CreateWindow("MPlayer - Playlist", "MPlayer Playlist", WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX, x, y, 400, 254, NULL, NULL, hInstance, NULL); SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD)gui); updatetracklist(hWnd); DragAcceptFiles(hWnd,TRUE); ShowWindow(hWnd, SW_SHOW); UpdateWindow(hWnd);}static LRESULT CALLBACK SkinBrowserWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam){ static HWND listbox; static char skinspath[MAX_PATH]; gui_t* gui = (gui_t*) GetWindowLongPtr(hwnd, GWLP_USERDATA); switch (iMsg) { case WM_CREATE: { HANDLE skinHandle = INVALID_HANDLE_VALUE; WIN32_FIND_DATA finddata; listbox = CreateWindow("listbox", NULL, WS_CHILD | WS_VISIBLE | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP, 4, 5, 166, 60, hwnd, (HMENU) ID_DIR, ((LPCREATESTRUCT) lParam) -> hInstance, NULL); SendMessage(listbox, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0); /* This opens the skins directory, lists the directory names, and adds them to the listbox */ sprintf(skinspath, "%s/*.", get_path("skins")); skinHandle = FindFirstFile(skinspath, &finddata); if (skinHandle != INVALID_HANDLE_VALUE) { do { if (finddata.cFileName[0] == '.') continue; /* populate the listbox */ capitalize(finddata.cFileName); SendDlgItemMessage(hwnd, ID_DIR, LB_ADDSTRING, 0, (LPARAM) finddata.cFileName); } while (FindNextFile(skinHandle, &finddata)); FindClose(skinHandle); } else mp_msg(MSGT_GPLAYER, MSGL_FATAL, "Error opening %s\n", get_path("skins")); break; } case WM_COMMAND: { if ((HWND) lParam == listbox) { if(HIWORD(wParam) == LBN_DBLCLK) { int index = SendMessage(listbox, LB_GETCURSEL, 0, 0); int len = SendMessage(listbox, LB_GETTEXTLEN, index, 0); if (len) { if (guiIntfStruct.Playing) guiGetEvent(guiCEvent, (void *) guiSetStop); if (skinName) free(skinName); skinName = (char *) malloc(len+1); SendMessage(listbox, LB_GETTEXT, (WPARAM) index, (LPARAM) skinName); /* fill out the full pathname to the skin */ strcpy(skinspath, get_path("skins")); strcat(skinspath, "\\"); strcat(skinspath, skinName); ShowWindow(hwnd, SW_HIDE); Shell_NotifyIcon(NIM_DELETE, &nid); destroy_window(gui); create_window(gui, skinspath); create_subwindow(gui, skinspath); SendMessage(hwnd, WM_CLOSE, 0, 0); /* Avoid crashing when switching skin */ } } } } return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, iMsg, wParam, lParam);}void display_skinbrowser(gui_t* gui){ HWND hWnd = FindWindow(NULL, "Skin Browser"); HINSTANCE hInstance = GetModuleHandle(NULL); WNDCLASS wc; int x, y; if (hWnd) { SendMessage(hWnd, WM_CLOSE, 0, 0); return; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -