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);
}
Example #2
0
static int init_playlist()
{
	WNDCLASS wc;
	HINSTANCE user32;
	LANGID _SysLangId;
	HINSTANCE hInstance = GetModuleHandle(NULL);

	if(hPlaylistWnd) {
		updatetracklist(hPlaylistWnd);
		ShowWindow(hPlaylistWnd, SW_SHOW);
		return 0;
	}

	if(sys_Language == 1) {
		LoadString(hInstance, IDS_PLAYLIST_SC, TitalPlaylist, 20);
		LoadString(hInstance, IDS_BT_PLAY_SC, BottonPlayAll, 20);
		LoadString(hInstance, IDS_BT_UP_SC, BottonUp, 20);
		LoadString(hInstance, IDS_BT_DOWN_SC, BottonDown, 20);
		LoadString(hInstance, IDS_BT_ADD_SC, BottonAdd, 20);
		LoadString(hInstance, IDS_BT_REMOVE_SC, BottonRemove, 20);
		LoadString(hInstance, IDS_BT_SAVE_SC, BottonSave, 20);
		LoadString(hInstance, IDS_BT_CLOSE_SC, BottonClose, 20);
		LoadString(hInstance, IDS_MU_ADD_SC, MenuAdd, 20);
		LoadString(hInstance, IDS_MU_REMOVE_SC, MenuRemove, 20);
		LoadString(hInstance, IDS_MU_CLEAR_SC, MenuClear, 20);
		LoadString(hInstance, IDS_MU_CLOSE_SC, MenuClose, 20);
	} else if(sys_Language == 3 || sys_Language == 4) {
		LoadString(hInstance, IDS_PLAYLIST_TC, TitalPlaylist, 20);
		LoadString(hInstance, IDS_BT_PLAY_TC, BottonPlayAll, 20);
		LoadString(hInstance, IDS_BT_UP_TC, BottonUp, 20);
		LoadString(hInstance, IDS_BT_DOWN_TC, BottonDown, 20);
		LoadString(hInstance, IDS_BT_ADD_TC, BottonAdd, 20);
		LoadString(hInstance, IDS_BT_REMOVE_TC, BottonRemove, 20);
		LoadString(hInstance, IDS_BT_SAVE_TC, BottonSave, 20);
		LoadString(hInstance, IDS_BT_CLOSE_TC, BottonClose, 20);
		LoadString(hInstance, IDS_MU_ADD_TC, MenuAdd, 20);
		LoadString(hInstance, IDS_MU_REMOVE_TC, MenuRemove, 20);
		LoadString(hInstance, IDS_MU_CLEAR_TC, MenuClear, 20);
		LoadString(hInstance, IDS_MU_CLOSE_TC, MenuClose, 20);
	} else {
		LoadString(hInstance, IDS_PLAYLIST_EN, TitalPlaylist, 20);
		LoadString(hInstance, IDS_BT_PLAY_EN, BottonPlayAll, 20);
		LoadString(hInstance, IDS_BT_UP_EN, BottonUp, 20);
		LoadString(hInstance, IDS_BT_DOWN_EN, BottonDown, 20);
		LoadString(hInstance, IDS_BT_ADD_EN, BottonAdd, 20);
		LoadString(hInstance, IDS_BT_REMOVE_EN, BottonRemove, 20);
		LoadString(hInstance, IDS_BT_SAVE_EN, BottonSave, 20);
		LoadString(hInstance, IDS_BT_CLOSE_EN, BottonClose, 20);
		LoadString(hInstance, IDS_MU_ADD_EN, MenuAdd, 20);
		LoadString(hInstance, IDS_MU_REMOVE_EN, MenuRemove, 20);
		LoadString(hInstance, IDS_MU_CLEAR_EN, MenuClear, 20);
		LoadString(hInstance, IDS_MU_CLOSE_EN, MenuClose, 20);
	}

	code_page = CP_ACP;
	_SysLangId = GetSystemDefaultLangID();
	if(PRIMARYLANGID(_SysLangId) == LANG_CHINESE) {
		if(SUBLANGID(_SysLangId) == SUBLANG_CHINESE_SIMPLIFIED)
			code_page = 936;
		else
			code_page = 950;
	}

	wc.style		 = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc   = PlayListWndProc;
	wc.cbClsExtra	= 0;
	wc.cbWndExtra	= 0;
	wc.hInstance	 = hInstance;
	wc.hCursor	   = LoadCursor(NULL,IDC_ARROW);
	mplayericon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPICON));
	wc.hIcon		 = mplayericon;
	wc.hbrBackground = SOLID_GREY;
	wc.lpszClassName = "MPlayer - Playlist";
	wc.lpszMenuName  = NULL;
	RegisterClass(&wc);
	create_playlistmenu();
	bkgndbrush = CreateSolidBrush(RGB(236,236,236));
	if(playlist_x < 0)
		playlist_x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (WinWidth / 2);   /* Erik: center popup window on screen */
	if(playlist_y < 0)
		playlist_y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (WinHeight / 2);
	hPlaylistWnd = CreateWindow("MPlayer - Playlist",
						TitalPlaylist, WS_OVERLAPPEDWINDOW | WS_SIZEBOX,
						playlist_x, playlist_y, WinWidth, WinHeight,
						playlist_parent, NULL, hInstance, NULL);

	if((vo_dirver != VO_DIRV_OPENGL || is_vista) && controlbar_alpha > 0) {
		user32 = GetModuleHandle("user32.dll");
		if (user32) {
			SetLayeredWinAttributes = GetProcAddress(user32, "SetLayeredWindowAttributes");
			if(SetLayeredWinAttributes) {
				SetWindowLong(hPlaylistWnd, GWL_EXSTYLE, GetWindowLong(hPlaylistWnd ,GWL_EXSTYLE) | WS_EX_LAYERED );
				SetLayeredWinAttributes(hPlaylistWnd, 0, 255, 2);
			}
		}
	}

	DragAcceptFiles(hPlaylistWnd, TRUE);

	if(!playlist)
		playlist = create_playlist();
	if(!need_update_playtree) {
		playlist->clear_playlist(playlist);
		import_playtree_into_playlist(mpctx->playtree, mconfig);
	}
	updatetracklist(hPlaylistWnd);
	SetWindowPos(hPlaylistWnd, playlist_layer,playlist_x,playlist_y,WinWidth,WinHeight,SWP_SHOWWINDOW);

	return 1;
}