-
Notifications
You must be signed in to change notification settings - Fork 8
/
MainDlg.cpp
105 lines (91 loc) · 2.75 KB
/
MainDlg.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
// MainDlg.cpp : implementation of the CMainDlg class
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MainDlg.h"
#include "import_table_adapter.h"
#include "export_table_adapter.h"
#include "DragDrop.h"
CMainDlg::CMainDlg() : SHostWnd(_T("LAYOUT:dlg_main"))
{
}
CMainDlg::~CMainDlg()
{
}
BOOL CMainDlg::OnInitDialog(HWND hWnd, LPARAM lParam)
{
//HRESULT hr = ;
::RegisterDragDrop(m_hWnd, GetDropTarget());
m_imgMergerHandler.OnInit(this);
m_codeLineCounter.OnInit(this);
m_2UnicodeHandler.OnInit(this);
m_folderScanHandler.OnInit(this);
m_calcMd5Handler.OnInit(this);
m_windowHelperHander.OnInit(this);
STreeView * pTreeView1 = FindChildByName2<STreeView>("import_table_treeview");
STreeView *pTreeView2 = FindChildByName2<STreeView>("export_table_treeview");
if (pTreeView1&&pTreeView2)
{
CImportTableTreeViewAdapter *pImportTableTreeViewAdapter = new CImportTableTreeViewAdapter();
pTreeView1->SetAdapter(pImportTableTreeViewAdapter);
pImportTableTreeViewAdapter->Release();
CExportTableTreeViewAdapter *pExportTableTreeViewAdapter = new CExportTableTreeViewAdapter();
pTreeView2->SetAdapter(pExportTableTreeViewAdapter);
pExportTableTreeViewAdapter->Release();
RegisterDragDrop(pTreeView1->GetSwnd(), new CTreeViewDropTarget(pTreeView1, pTreeView2));
RegisterDragDrop(pTreeView2->GetSwnd(), new CTreeViewDropTarget(pTreeView1, pTreeView2));
}
return 0;
}
BOOL CMainDlg::OnTreeViewContextMenu(EventArgs *pEvt)
{
EventCtxMenu *pEvt2 = sobj_cast<EventCtxMenu>(pEvt);
POINT pt = pEvt2->pt;
//选中鼠标点击行
STreeView *pListview = sobj_cast<STreeView>(pEvt2->sender);
CPoint pt2 = pt;
ClientToScreen(&pt);
SItemPanel *pItem = pListview->HitTest(pt2);
int iItem = 0;
if (pItem)
{
iItem = pItem->GetItemIndex();
pListview->SetSel(iItem);
}
((CImportTableTreeViewAdapter*)pListview->GetAdapter())->HandleTreeViewContextMenu(pt, pItem, m_hWnd);
return TRUE;
}
//TODO:消息映射
void CMainDlg::OnClose()
{
DestroyWindow();
}
void CMainDlg::OnMaximize()
{
SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE);
}
void CMainDlg::OnRestore()
{
SendMessage(WM_SYSCOMMAND, SC_RESTORE);
}
void CMainDlg::OnMinimize()
{
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
}
void CMainDlg::OnSize(UINT nType, CSize size)
{
SetMsgHandled(FALSE);
SWindow *pBtnMax = FindChildByName(L"btn_max");
SWindow *pBtnRestore = FindChildByName(L"btn_restore");
if(!pBtnMax || !pBtnRestore) return;
if (nType == SIZE_MAXIMIZED)
{
pBtnRestore->SetVisible(TRUE);
pBtnMax->SetVisible(FALSE);
}
else if (nType == SIZE_RESTORED)
{
pBtnRestore->SetVisible(FALSE);
pBtnMax->SetVisible(TRUE);
}
}