-
Notifications
You must be signed in to change notification settings - Fork 0
/
FormList.cpp
157 lines (132 loc) · 3.87 KB
/
FormList.cpp
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
// FormList.cpp: implementation of the CFormList class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "resource.h"
#include "FormList.h"
#include "usermsgs.h"
#include "formframe.h"
#include "MainFrm.h"
extern CMainFrame wndMain;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CFormList::CFormList()
{
}
CFormList::~CFormList()
{
}
LRESULT CFormList::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
// register object for message filtering and idle updates
CMessageLoop* pLoop = _Module.GetMessageLoop();
ATLASSERT(pLoop != NULL);
pLoop->AddMessageFilter(this);
m_lb1.Attach(GetDlgItem(IDC_LIST1));
DlgResize_Init(false,false,WS_CLIPCHILDREN);
ReloadList();
return TRUE;
}
LRESULT CFormList::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
CMessageLoop* pLoop = _Module.GetMessageLoop();
ATLASSERT(pLoop != NULL);
pLoop->RemoveMessageFilter(this);
return 0;
}
LRESULT CFormList::OnDeleteViewer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
CPreviewDlg *p = (CPreviewDlg *)lParam;
delete p;
return 0;
}
LRESULT CFormList::OnList1DClick(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
CString sFile;
if(GetCurSel(sFile)){
// create the preview dialog
CPreviewDlg *pDlg = new CPreviewDlg(m_hWnd,TRUE);
USES_CONVERSION;
pDlg->m_AutoSizing=FALSE;
pDlg->m_FileName = (CString)wndMain.m_FormsPath;
pDlg->m_FileName += sFile;
// expose objects - see OnInitialUpdate() for more details
// class1
CExposedObjectInfo ExposedObjectInfo;
CComQIPtr<IDispatch> sp; wndMain.m_pIrc->QueryInterface(&sp);
ExposedObjectInfo.m_Name=_T("no5");
ExposedObjectInfo.m_spDispatch= sp;
pDlg->m_ExposedObjectInfoArray.Add(ExposedObjectInfo);
// show the preview
pDlg->Create(m_hWnd);
pDlg->ShowWindow(SW_NORMAL);
}
return 0;
}
LRESULT CFormList::OnBtRun(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
BOOL b;
OnList1DClick(0,0,0,b);
return 0;
}
// edit ( only not running scripts )
LRESULT CFormList::OnBtEdit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
CString sFile;
if(GetCurSel(sFile)){
CRect r(0,0,CW_USEDEFAULT,CW_USEDEFAULT);
CString path = wndMain.m_FormsPath;
path += sFile;
CFormFrame *pFrame = new CFormFrame(path);
pFrame->CreateEx(wndMain.m_hWnd,r,NULL);
//
}
return 0;
}
// new
LRESULT CFormList::OnBtNew(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
CRect r(0,0,CW_USEDEFAULT,CW_USEDEFAULT);
CFormFrame *pFrame = new CFormFrame();
pFrame->CreateEx(wndMain.m_hWnd,r,0);
ATLASSERT(pFrame->IsWindow());
return 0;
}
LRESULT CFormList::OnBtReload(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
ReloadList();
return 0;
}
void CFormList::ReloadList(void)
{
WIN32_FIND_DATA f = {0};
HANDLE hFind = NULL;
CString sSearch;
LPCTSTR exts[] = { _T("*.ddf") };
const int count = sizeof(exts)/sizeof(exts[0]);
m_lb1.ResetContent();
for(int i=0;i<count;i++){
sSearch = ((CString)wndMain.m_FormsPath + exts[i]);
hFind = ::FindFirstFile(sSearch,&f);
if(hFind != INVALID_HANDLE_VALUE){
if((f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0){
m_lb1.AddString(f.cFileName);
while(FindNextFile(hFind,&f)){
if((f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0){
m_lb1.AddString(f.cFileName);
}
}
}
FindClose(hFind);
}
}
}
bool CFormList::GetCurSel(CString &s)
{
int idx = m_lb1.GetCurSel();
bool res = false;
if(idx >= 0)
res = (m_lb1.GetText(idx,s) > 0);
return res;
}