Repository navigation
Expand file tree
/
Copy pathUIDesignerDoc.cpp
More file actions
190 lines (153 loc) · 3.82 KB
/
Copy pathUIDesignerDoc.cpp
File metadata and controls
190 lines (153 loc) · 3.82 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
// UIDesignerDoc.cpp : CUIDesignerDoc 类的实现
//
#include "stdafx.h"
#include "DuiDesigner.h"
#include "UIDesignerDoc.h"
#include "DialogSkinFileNew.h"
#include "UIUtil.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CUIDesignerDoc
IMPLEMENT_DYNCREATE(CUIDesignerDoc, CDocument)
BEGIN_MESSAGE_MAP(CUIDesignerDoc, CDocument)
ON_COMMAND(ID_MDITABS_COPY_FULLPATH, &CUIDesignerDoc::OnMdiCopyFullPath)
ON_COMMAND(ID_MDITABS_OPEN_FULLPATH, &CUIDesignerDoc::OnMdiOpenFullPath)
END_MESSAGE_MAP()
// CUIDesignerDoc 构造/析构
CUIDesignerDoc::CUIDesignerDoc()
{
// TODO: 在此添加一次性构造代码
}
CUIDesignerDoc::~CUIDesignerDoc()
{
}
BOOL CUIDesignerDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: 在此添加重新初始化代码
// (SDI 文档将重用该文档)
CDialogSkinFileNew dlg;
dlg.m_strUITitle = this->GetTitle();
if(dlg.DoModal() == IDOK)
{
CString strFilePath = dlg.GetStyleFilePath();
if(!strFilePath.IsEmpty())
this->SetPathName(strFilePath);
if(!dlg.m_strUITitle.IsEmpty())
this->SetTitle(dlg.m_strUITitle);
}
else
return FALSE;
return TRUE;
}
// CUIDesignerDoc 序列化
void CUIDesignerDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: 在此添加存储代码
}
else
{
// TODO: 在此添加加载代码
}
}
// CUIDesignerDoc 诊断
#ifdef _DEBUG
void CUIDesignerDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CUIDesignerDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
// CUIDesignerDoc 命令
BOOL CUIDesignerDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
// TODO: 在此添加专用代码和/或调用基类
POSITION pos = this->GetFirstViewPosition();
while(pos)
{
CView* pView = this->GetNextView(pos);
CUIDesignerView* pUIView = DYNAMIC_DOWNCAST(CUIDesignerView, pView);
ASSERT(pUIView);
pUIView->SaveSkinFile(lpszPathName);
this->SetModifiedFlag(FALSE);
}
return TRUE;/*CDocument::OnSaveDocument(lpszPathName);*/
}
void CUIDesignerDoc::SetTitle(LPCTSTR lpszTitle)
{
// TODO: 在此添加专用代码和/或调用基类
if(m_strTitle != lpszTitle)
{
POSITION pos = this->GetFirstViewPosition();
while(pos)
{
CView* pView = this->GetNextView(pos);
CUIDesignerView* pUIView = DYNAMIC_DOWNCAST(CUIDesignerView, pView);
ASSERT(pUIView);
pUIView->OnTitleChanged(m_strTitle, lpszTitle);
}
}
CDocument::SetTitle(lpszTitle);
}
void CUIDesignerDoc::SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU)
{
// TODO: 在此添加专用代码和/或调用基类
if(*lpszPathName == _T('\0'))
m_strPathName.Empty();
else
CDocument::SetPathName(lpszPathName, bAddToMRU);
}
void CUIDesignerDoc::OnMdiCopyFullPath()
{
if(m_strPathName.IsEmpty())
{
MessageBox(NULL, _T("请先保存当前文件。"), _T("提示"), MB_ICONINFORMATION);
return;
}
HGLOBAL hClip;
if(OpenClipboard(NULL))
{
EmptyClipboard();
CStringA strFullPath = StringConvertor::WideToAnsi(m_strPathName);
hClip = GlobalAlloc(GMEM_MOVEABLE, strFullPath.GetLength() + 1);
char* pbufCopy;
pbufCopy = (char*)GlobalLock(hClip);
strcpy(pbufCopy, strFullPath);
GlobalUnlock(hClip);
SetClipboardData(CF_TEXT, hClip);
CloseClipboard();
}
}
void CUIDesignerDoc::OnMdiOpenFullPath()
{
if(m_strPathName.IsEmpty())
{
MessageBox(NULL, _T("请先保存当前文件。"), _T("提示"), MB_ICONINFORMATION);
return;
}
CString strFileName = m_strPathName;
if ( GetFileAttributes(strFileName)==-1 ){
//文件不存在打开它所在的目录
CString strFolder;
int nPos=strFileName.ReverseFind('\\');
if ( nPos!=-1 ){
strFolder=strFileName.Left(nPos);
}
if ( GetFileAttributes(strFolder)==-1 ){
//AfxMessageBox("以下文件不存在,可能已经被删除了:\n"+strFileName);
}else{
ShellExecute(NULL,_T("open"),_T("explorer.exe"),strFolder,NULL,SW_NORMAL);
}
}else{
CString strCmdLine;
strCmdLine.Format( _T("/select, \"%s\""), strFileName );
ShellExecute(NULL,_T("open"),_T("explorer.exe"),strCmdLine,NULL,SW_NORMAL);
}
}