summaryrefslogtreecommitdiffabout
path: root/Trayer.cpp
blob: 1e1ab3c7cd93a3cce4782b2752bbcf3d4bb77cf1 (plain)
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
// Trayer.cpp : implementation file
//

#include "stdafx.h"
#include "PumpKIN.h"
#include "Trayer.h"

#include "PumpKINDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTrayer

CTrayer::CTrayer()
{
	m_inMenu=0;
}

CTrayer::~CTrayer()
{
}


BEGIN_MESSAGE_MAP(CTrayer, CWnd)
	//{{AFX_MSG_MAP(CTrayer)
	ON_MESSAGE(WM_TRAYICON, OnTray)
	ON_COMMAND(ID_TRAY_ABOUTPUMPKIN, OnTrayAboutpumpkin)
	ON_COMMAND(ID_TRAY_EXIT, OnTrayExit)
	ON_COMMAND(ID_TRAY_FETCHFILE, OnTrayFetchfile)
	ON_COMMAND(ID_TRAY_HELP, OnTrayHelp)
	ON_COMMAND(ID_TRAY_OPENFILESFOLDER, OnTrayOpenfilesfolder)
	ON_COMMAND(ID_TRAY_OPTIONS, OnTrayOptions)
	ON_COMMAND(ID_TRAY_SENDFILE, OnTraySendfile)
	ON_COMMAND(ID_TRAY_SHOWPUMPKINWINDOW, OnTrayShowpumpkinwindow)
	ON_COMMAND(ID_TRAY_LISTEN, OnTrayListen)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CTrayer message handlers

CTrayer::CTrayer(CPumpKINDlg* daddy)
	: m_Daddy(daddy)
{
	m_inMenu=0;
}

LRESULT CTrayer::OnTray(WPARAM wP,LPARAM lP)
{
	ASSERT(wP==IDC_TRAYICON);
	switch(lP){
	case WM_RBUTTONDOWN:
		{
		CMenu menu;
			VERIFY(menu.LoadMenu(IDM_POPUPS));
		CMenu *popUp = menu.GetSubMenu(0);
			ASSERT(popUp);
		CPoint pt;
			VERIFY(::GetCursorPos(&pt));
			m_inMenu++;
			SetForegroundWindow();
			popUp->CheckMenuItem(ID_TRAY_SHOWPUMPKINWINDOW,MF_BYCOMMAND|(IsWindowVisible()?MF_CHECKED:MF_UNCHECKED));
			popUp->CheckMenuItem(ID_TRAY_LISTEN,MF_BYCOMMAND|(m_Daddy->m_Listener.m_bListen?MF_CHECKED:MF_UNCHECKED));
			popUp->TrackPopupMenu(TPM_RIGHTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON,pt.x,pt.y,this);
			m_inMenu--;
			SendMessage(WM_NULL);
		}
		break;
	case WM_LBUTTONDOWN:
		m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_SHOWPUMPKINWINDOW);
		break;
	}
	return 0;
}

void CTrayer::OnTrayAboutpumpkin() 
{
	m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_ABOUTPUMPKIN);
}

void CTrayer::OnTrayExit() 
{
	m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_EXIT);
}

void CTrayer::OnTrayFetchfile() 
{
	m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_FETCHFILE);
}

void CTrayer::OnTrayHelp() 
{
	m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_HELP);
}

void CTrayer::OnTrayOpenfilesfolder() 
{
	m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_OPENFILESFOLDER);
}

void CTrayer::OnTrayOptions() 
{
	m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_OPTIONS);
}

void CTrayer::OnTraySendfile() 
{
	m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_SENDFILE);
}

void CTrayer::OnTrayShowpumpkinwindow() 
{
	m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_SHOWPUMPKINWINDOW);
}

void CTrayer::OnTrayListen() 
{
	m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_LISTEN);
}