X64 transport [Part 5] (Update plugins.cpp)
[xy_vsfilter.git] / src / apps / mplayerc / PPageFileInfoRes.cpp
blob43a747dd94751cdacca7e6483ba5257891b3156e
1 /*
2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 // PPageFileInfoRes.cpp : implementation file
25 #include "stdafx.h"
26 #include "mplayerc.h"
27 #include "PPageFileInfoRes.h"
28 #include ".\ppagefileinfores.h"
30 // CPPageFileInfoRes dialog
32 IMPLEMENT_DYNAMIC(CPPageFileInfoRes, CPPageBase)
33 CPPageFileInfoRes::CPPageFileInfoRes(CString fn, IFilterGraph* pFG)
34 : CPPageBase(CPPageFileInfoRes::IDD, CPPageFileInfoRes::IDD)
35 , m_fn(fn)
36 , m_hIcon(NULL)
37 , m_pFG(pFG)
41 CPPageFileInfoRes::~CPPageFileInfoRes()
43 if(m_hIcon) DestroyIcon(m_hIcon);
46 void CPPageFileInfoRes::DoDataExchange(CDataExchange* pDX)
48 __super::DoDataExchange(pDX);
49 DDX_Control(pDX, IDC_DEFAULTICON, m_icon);
50 DDX_Text(pDX, IDC_EDIT1, m_fn);
51 DDX_Control(pDX, IDC_LIST1, m_list);
54 BEGIN_MESSAGE_MAP(CPPageFileInfoRes, CPPageBase)
55 ON_BN_CLICKED(IDC_BUTTON1, OnSaveAs)
56 ON_UPDATE_COMMAND_UI(IDC_BUTTON1, OnUpdateSaveAs)
57 ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnNMDblclkList1)
58 END_MESSAGE_MAP()
60 // CPPageFileInfoRes message handlers
62 BOOL CPPageFileInfoRes::OnInitDialog()
64 __super::OnInitDialog();
66 if(m_hIcon = LoadIcon(m_fn, false))
67 m_icon.SetIcon(m_hIcon);
69 m_fn.TrimRight('/');
70 int i = max(m_fn.ReverseFind('\\'), m_fn.ReverseFind('/'));
71 if(i >= 0 && i < m_fn.GetLength()-1)
72 m_fn = m_fn.Mid(i+1);
74 m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
76 m_list.InsertColumn(0, _T("Name"), LVCFMT_LEFT, 187);
77 m_list.InsertColumn(1, _T("Mime Type"), LVCFMT_LEFT, 127);
79 BeginEnumFilters(m_pFG, pEF, pBF)
81 if(CComQIPtr<IDSMResourceBag> pRB = pBF)
82 if(pRB && pRB->ResGetCount() > 0)
84 for(DWORD i = 0; i < pRB->ResGetCount(); i++)
86 CComBSTR name, desc, mime;
87 BYTE* pData = NULL;
88 DWORD len = 0;
89 if(SUCCEEDED(pRB->ResGet(i, &name, &desc, &mime, &pData, &len, NULL)))
91 CDSMResource r;
92 r.name = name;
93 r.desc = desc;
94 r.mime = mime;
95 r.data.SetCount(len);
96 memcpy(r.data.GetData(), pData, r.data.GetCount());
97 CoTaskMemFree(pData);
98 POSITION pos = m_res.AddTail(r);
99 int iItem = m_list.InsertItem(m_list.GetItemCount(), CString(name));
100 m_list.SetItemText(iItem, 1, CString(mime));
101 m_list.SetItemData(iItem, (DWORD_PTR)pos);
106 EndEnumFilters
108 UpdateData(FALSE);
110 return TRUE; // return TRUE unless you set the focus to a control
111 // EXCEPTION: OCX Property Pages should return FALSE
114 void CPPageFileInfoRes::OnSaveAs()
116 int i = m_list.GetSelectionMark();
117 if(i < 0) return;
119 CDSMResource& r = m_res.GetAt((POSITION)m_list.GetItemData(i));
121 CFileDialog fd(FALSE, NULL, CString(r.name),
122 OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
123 _T("All files|*.*||"), this, 0);
124 if(fd.DoModal() == IDOK)
126 if(FILE* f = _tfopen(fd.GetPathName(), _T("wb")))
128 fwrite(r.data.GetData(), 1, r.data.GetCount(), f);
129 fclose(f);
134 void CPPageFileInfoRes::OnUpdateSaveAs(CCmdUI* pCmdUI)
136 pCmdUI->Enable(m_list.GetSelectedCount());
139 void CPPageFileInfoRes::OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult)
141 int i = m_list.GetSelectionMark();
142 if(i < 0) return;
144 CDSMResource& r = m_res.GetAt((POSITION)m_list.GetItemData(i));
146 CString url;
147 url.Format(_T("http://localhost:%d/convres.html?id=%x"), AfxGetAppSettings().nWebServerPort, (DWORD)&r);
148 ShellExecute(NULL, _T("open"), url, NULL, NULL, SW_SHOWDEFAULT);
150 *pResult = 0;