summaryrefslogtreecommitdiff
path: root/plugins/SendScreenshotPlus/src/UMainForm.h
blob: 55b75e2373ffcdfbd6f1ad2b3123610905abdef0 (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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*

Miranda NG: the free IM client for Microsoft* Windows*

Copyright (C) 2012-22 Miranda NG team (https://miranda-ng.org),
Copyright (c) 2000-09 Miranda ICQ/IM project,

This file is part of Send Screenshot Plus, a Miranda IM plugin.
Copyright (c) 2010 Ing.U.Horn

Parts of this file based on original sorce code
(c) 2004-2006 Sérgio Vieira Rolanski (portet from Borland C++)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifndef UMainFormH
#define UMainFormH

#define SS_JUSTSAVE			0
#define SS_FILESEND			1
#define SS_EMAIL			2
#define SS_HTTPSERVER		3
#define SS_FTPFILE			4
#define SS_CLOUDFILE		5
#define SS_IMAGESHACK		6
#define SS_UPLOADPIE		7
#define SS_IMGUR			8

struct UPLOAD_INFO
{
	uint8_t sendBy;		//SS_*
	void *param;

	UPLOAD_INFO(uint8_t sb) : sendBy(sb), param(nullptr) { }
	UPLOAD_INFO(uint8_t sb, void *p) : sendBy(sb), param(p) { }
};

// Used for our own cheap TrackMouseEvent
#define BUTTON_POLLDELAY    50

// User Events
#define EVT_CaptureDone		1
#define EVT_SendFileDone	2
#define EVT_CheckOpenAgain	3

struct TAB_INFO
{
	TCITEMHEADER tcih;
	HWND hwndMain;		// main window
	HWND hwndTab;		// tab control
	HWND hwndTabPage;	// current child dialog box
};

/////////////////////////////////////////////////////////////////////////////////////////

class TfrmMain
{

public:
	// Deklaration Standardkonstruktor/Standarddestructor
	TfrmMain();
	~TfrmMain();

	uint8_t		m_opt_tabCapture;  // capture tab page
	uint8_t		m_opt_cboxDesktop; // TRadioButton *rbtnDesktop;
	uint8_t		m_opt_chkTimed;    // TCheckBox *chkTimed;
	uint8_t		m_opt_cboxSendBy;  // TComboBox *cboxSendBy;
	uint8_t		m_opt_btnDesc;     // TCheckBox *chkDesc;
	uint8_t		m_opt_chkEditor;   // TCheckBox *chkEditor;
	bool		m_bOnExitSave;

	static void Unload();
	void		Init(wchar_t* DestFolder, MCONTACT Contact);
	void		Close(){ SendMessage(m_hWnd, WM_CLOSE, 0, 0); }
	void		Show(){ ShowWindow(m_hWnd, SW_SHOW); }
	void		Hide(){ ShowWindow(m_hWnd, SW_HIDE); }
	void		SetTargetWindow(HWND hwnd = nullptr);
	void		btnCaptureClick();
	void		cboxSendByChange(void *param);

private:
	HWND		m_hWnd;
	MCONTACT	m_hContact;
	HWND		m_hTargetWindow, m_hLastWin;
	HWND		m_hTargetHighlighter;
	wchar_t*		m_FDestFolder;
	wchar_t*		m_pszFile;
	FIBITMAP*	m_Screenshot;
	RGBQUAD		m_AlphaColor;
	CSend*		m_cSend;

	void chkTimedClick();
	void btnExploreClick();
	void LoadOptions(void);
	void SaveOptions(void);
	INT_PTR SaveScreenshot(FIBITMAP* dib);
	void FormClose();
	static void edtSizeUpdate(HWND hWnd, BOOL ClientArea, HWND hTarget, UINT Ctrl);
	static void edtSizeUpdate(RECT rect, HWND hTarget, UINT Ctrl);

protected:
	MONITORINFOEX* m_Monitors;
	size_t         m_MonitorCount;
	RECT           m_VirtualScreen;

	uint8_t           m_opt_chkOpenAgain;        // TCheckBox *chkOpenAgain;
	uint8_t           m_opt_chkIndirectCapture;  // TCheckBox *chkIndirectCapture;
	uint8_t           m_opt_chkClientArea;       // TCheckBox *chkClientArea;
	uint8_t           m_opt_edtQuality;          // TLabeledEdit *edtQuality;
	bool           m_opt_btnDeleteAfterSend;  // TCheckBox *chkDeleteAfterSend;
	uint8_t           m_opt_cboxFormat;          // TComboBox *cboxFormat;
	uint8_t           m_opt_edtTimed;            // TLabeledEdit *edtTimed;
	bool           m_bCapture;                // is capture active
	HWND           m_hwndTab;                 // TabControl handle
	HWND           m_hwndTabPage;             // TabControl activ page handle
	HIMAGELIST     m_himlTab;                 // TabControl imagelist

	typedef std::map<HWND, TfrmMain *> CHandleMapping;
	static CHandleMapping _HandleMapping;
	static INT_PTR CALLBACK DlgTfrmMain(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

	void wmInitdialog(WPARAM wParam, LPARAM lParam);
	void wmCommand(WPARAM wParam, LPARAM lParam);
	void wmClose(WPARAM wParam, LPARAM lParam);
	void wmNotify(WPARAM wParam, LPARAM lParam);
	void wmTimer(WPARAM wParam, LPARAM lParam);

	void UMevent(WPARAM wParam, LPARAM lParam);

	static INT_PTR CALLBACK DlgProc_CaptureTabPage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
};

#endif