vncabout.cpp
5.32 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
// Copyright (C) 2002 RealVNC Ltd. All Rights Reserved.
// Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
//
// This file is part of the VNC system.
//
// The VNC system 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.
//
// If the source code for the VNC system is not available from the place
// whence you received this file, check http://www.uk.research.att.com/vnc or contact
// the authors on vnc@uk.research.att.com for information on obtaining it.
// vncAbout.cpp
// Implementation of the About dialog!
#include "stdhdrs.h"
#include "WinVNC.h"
#include "vncAbout.h"
HBITMAP
DoGetBkGndBitmap(IN CONST UINT uBmpResId )
{
static HBITMAP hbmBkGnd = NULL;
if (NULL == hbmBkGnd)
{
hbmBkGnd = (HBITMAP)LoadImage(NULL, "background.bmp", IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE);
//hbmBkGnd = (HBITMAP)LoadImage(
// GetModuleHandle(NULL), MAKEINTRESOURCE(uBmpResId),
// IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
if (NULL == hbmBkGnd)
hbmBkGnd = (HBITMAP)-1;
}
return (hbmBkGnd == (HBITMAP)-1)
? NULL : hbmBkGnd;
}
BOOL
DoSDKEraseBkGnd(
IN CONST HDC hDC,
IN CONST COLORREF crBkGndFill
)
{
HBITMAP hbmBkGnd = DoGetBkGndBitmap(IDB_LOGO64);
if (hDC && hbmBkGnd)
{
RECT rc;
if ((ERROR != GetClipBox(hDC, &rc)) && !IsRectEmpty(&rc))
{
HDC hdcMem = CreateCompatibleDC(hDC);
if (hdcMem)
{
HBRUSH hbrBkGnd = CreateSolidBrush(crBkGndFill);
if (hbrBkGnd)
{
HGDIOBJ hbrOld = SelectObject(hDC, hbrBkGnd);
if (hbrOld)
{
SIZE size = {
(rc.right-rc.left), (rc.bottom-rc.top)
};
if (PatBlt(hDC, rc.left, rc.top, size.cx, size.cy, PATCOPY))
{
HGDIOBJ hbmOld = SelectObject(hdcMem, hbmBkGnd);
if (hbmOld)
{
StretchBlt(hDC, rc.left, rc.top, size.cx, size.cy,
hdcMem, rc.left, rc.top,1,283, SRCCOPY);
SelectObject(hdcMem, hbmOld);
}
}
SelectObject(hDC, hbrOld);
}
DeleteObject(hbrBkGnd);
}
DeleteDC(hdcMem);
}
}
return TRUE;
}
return false;
}
// Constructor/destructor
vncAbout::vncAbout()
{
m_dlgvisible = FALSE;
}
vncAbout::~vncAbout()
{
}
// Initialisation
BOOL
vncAbout::Init()
{
return TRUE;
}
// Dialog box handling functions
void
vncAbout::Show(BOOL show)
{
if (show)
{
if (!m_dlgvisible)
{
DialogBoxParam(hAppInstance,
MAKEINTRESOURCE(IDD_ABOUT),
NULL,
(DLGPROC) DialogProc,
(LONG) this);
}
}
}
BOOL CALLBACK
vncAbout::DialogProc(HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam )
{
// We use the dialog-box's USERDATA to store a _this pointer
// This is set only once WM_INITDIALOG has been recieved, though!
vncAbout *_this = (vncAbout *) GetWindowLong(hwnd, GWL_USERDATA);
switch (uMsg)
{
case WM_INITDIALOG:
{
// Retrieve the Dialog box parameter and use it as a pointer
// to the calling vncProperties object
SetWindowLong(hwnd, GWL_USERDATA, lParam);
_this = (vncAbout *) lParam;
// Insert the build time information
extern char buildtime[];
SetDlgItemText(hwnd, IDC_BUILDTIME, buildtime);
// Show the dialog
SetForegroundWindow(hwnd);
_this->m_dlgvisible = TRUE;
return TRUE;
}
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDCANCEL:
case IDOK:
// Close the dialog
EndDialog(hwnd, TRUE);
_this->m_dlgvisible = FALSE;
return TRUE;
}
break;
case WM_DESTROY:
EndDialog(hwnd, FALSE);
_this->m_dlgvisible = FALSE;
return TRUE;
/*case WM_ERASEBKGND:
{
DoSDKEraseBkGnd((HDC)wParam, RGB(255,0,0));
return true;
}
case WM_CTLCOLORSTATIC:
{
//GetStockObject(NULL_BRUSH);
SetBkMode((HDC) wParam, TRANSPARENT);
return (DWORD) GetStockObject(NULL_BRUSH);
}*/
}
return 0;
}