-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainDlg.cpp
78 lines (68 loc) · 2.96 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
// MainDlg.cpp : implementation of the CMainDlg class
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MainDlg.h"
#include "CWindowEnumer.h"
CMainDlg::CMainDlg() : SHostWnd(_T("LAYOUT:XML_MAINWND"))
{
m_bLayoutInited = FALSE;
m_Captured = false;
}
CMainDlg::~CMainDlg()
{
}
int CMainDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
SetMsgHandled(FALSE);
return 0;
}
BOOL CMainDlg::OnInitDialog(HWND hWnd, LPARAM lParam)
{
m_bLayoutInited = TRUE;
ShowWindow(SW_HIDE);
m_iHotKeyId = GlobalAddAtom(_T("LaoYangJieTuHotKey")) - 0xC000;
if (!RegisterHotKey(m_hWnd, m_iHotKeyId, MOD_ALT| MOD_CONTROL, 'Y'))
{
SMessageBox(m_hWnd, _T("注册热键失败"), _T("Snapshot"), MB_OK);
m_iHotKeyId = 0xFFFF;
}
OnStart();
return 0;
}
void CMainDlg::OnDestroy()
{
if(m_iHotKeyId!= 0xFFFF)
UnregisterHotKey(m_hWnd, m_iHotKeyId);
SHostWnd::OnDestroy();
}
//TODO:消息映射
void CMainDlg::OnClose()
{
DestroyWindow();
}
void CMainDlg::OnStart()
{
if (!m_Captured)
{
m_Captured = true;
CSnapshotDlg snapshotDlg;
CWindowEnumer::EnumAllTopWindow();
snapshotDlg.DoModal();
m_Captured = false;
}
}
void CMainDlg::OnHotKey(int nHotKeyID, UINT uModifiers, UINT uVirtKey)
{
if (nHotKeyID != m_iHotKeyId)
{
SetMsgHandled(FALSE);
return;
}
OnStart();
}
LRESULT CMainDlg::StartCap(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandled)
{
OnStart();
return S_OK;
}