-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainDialog.cpp
More file actions
134 lines (109 loc) · 3.28 KB
/
MainDialog.cpp
File metadata and controls
134 lines (109 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// MainDialog.cpp : implementation file
//
#include "stdafx.h"
#include "mediaPlayer.h"
#include "MainDialog.h"
#include "afxdialogex.h"
#include "MainFrm.h"
#include "MediaPlayerDialog.h"
#include "PreView.h"
#include "MainFrm.h"
#pragma comment(lib, "Version.lib ")
extern CMainFrame* g_pMainFrame;
// CMainDialog dialog
IMPLEMENT_DYNAMIC(CMainDialog, CDialogEx)
CMainDialog::CMainDialog(CFrameWnd* pFrameWnd, CWnd* pParent /*=NULL*/)
: CDialogEx(CMainDialog::IDD, pParent)
{
m_pFrameWnd = pFrameWnd;
}
CMainDialog::~CMainDialog()
{
}
void CMainDialog::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CMainDialog, CDialogEx)
ON_WM_SIZE()
ON_WM_CLOSE()
END_MESSAGE_MAP()
// CMainDialog message handlers
static CString GetAppVersion()
{
char cPath[200],szVersionBuffer[200];
DWORD dwHandle,InfoSize;
CString strVersion;
::GetModuleFileName(NULL,cPath,sizeof(cPath)); //首先获得版本信息资源的长度
InfoSize = GetFileVersionInfoSize(cPath,&dwHandle); //将版本信息资源读入缓冲区
if(InfoSize==0) return _T("None VerSion Supprot");
char *InfoBuf = new char[InfoSize];
GetFileVersionInfo(cPath,0,InfoSize,InfoBuf); //获得生成文件使用的代码页及文件版本
unsigned int cbTranslate = 0;
struct LANGANDCODEPAGE {
WORD wLanguage;
WORD wCodePage;
} *lpTranslate;
VerQueryValue(InfoBuf, TEXT("\\VarFileInfo\\Translation"),(LPVOID*)&lpTranslate,&cbTranslate);
// Read the file description for each language and code page.
for( int i=0; i < (cbTranslate/sizeof(struct LANGANDCODEPAGE)); i++ )
{
char SubBlock[200];
wsprintf( SubBlock,
TEXT("\\StringFileInfo\\%04x%04x\\FileVersion"),
lpTranslate[i].wLanguage,
lpTranslate[i].wCodePage);
void *lpBuffer=NULL;
unsigned int dwBytes=0;
VerQueryValue(InfoBuf,
SubBlock,
&lpBuffer,
&dwBytes);
CString strTemp=(char *)lpBuffer;
strVersion+=strTemp;
}
return strVersion;
}
void CMainDialog::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CRect rt;
GetClientRect(&rt);
if (m_pFrameWnd)
{
m_pFrameWnd->MoveWindow(&rt);
}
}
BOOL CMainDialog::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: Add extra initialization here
this->ShowWindow(SW_HIDE | SW_SHOWMAXIMIZED);
// CString strVersion = GetAppVersion();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CMainDialog::UpdateFrameWnd(CFrameWnd* pFramWnd)
{
if (pFramWnd)
{
m_pFrameWnd = pFramWnd;
}
}
void CMainDialog::OnClose()
{
// TODO: Add your message handler code here and/or call default
this->ShowWindow(SW_HIDE);
CVLCPlayer::Instance()->Release();
CSplitterWnd& split = g_pMainFrame->GetSplitterWnd2();
CPreView* pFilePrevView = (CPreView*)(split.GetPane(0, 0));
CMediaPlayerDialog* pPlayDlg = pFilePrevView->GetMediaPlayDlg();
if (pPlayDlg)
{
::SendMessage(pPlayDlg->GetSafeHwnd(), WM_RESETPLAYSTATUS, WPARAM(false), NULL);
}
CmediaPlayerApp* pApp = (CmediaPlayerApp*)AfxGetApp();
pApp->SetTerminate(true);
// CDialogEx::OnClose();
}