Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2004 TightVNC Team. All Rights Reserved. |
| 2 | * |
| 3 | * This is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This software is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this software; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 16 | * USA. |
| 17 | */ |
| 18 | |
| 19 | // -=- RFB Player for Win32 |
| 20 | |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 21 | #include <rfb/LogWriter.h> |
| 22 | #include <rfb/Exception.h> |
| 23 | #include <rfb/Threading.h> |
| 24 | |
| 25 | #include <rfb_win32/Win32Util.h> |
| 26 | #include <rfb_win32/WMShatter.h> |
| 27 | |
george82 | 0981b34 | 2005-03-19 11:19:00 +0000 | [diff] [blame] | 28 | #include <rfbplayer/PixelFormatList.h> |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 29 | #include <rfbplayer/rfbplayer.h> |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 30 | |
| 31 | using namespace rfb; |
| 32 | using namespace rfb::win32; |
| 33 | |
| 34 | // -=- Variables & consts |
| 35 | |
| 36 | static LogWriter vlog("RfbPlayer"); |
| 37 | |
| 38 | TStr rfb::win32::AppName("RfbPlayer"); |
| 39 | extern const char* buildTime; |
| 40 | |
george82 | e6883de | 2005-02-08 14:42:12 +0000 | [diff] [blame] | 41 | char wrong_cmd_msg[] = |
| 42 | "Wrong command-line parameters!\n" |
| 43 | "Use for help: rfbplayer -help"; |
| 44 | |
| 45 | char usage_msg[] = |
| 46 | "usage: rfbplayer <options> <filename>\n" |
| 47 | "Command-line options:\n" |
| 48 | " -help \t- Provide usage information.\n" |
george82 | 5caee41 | 2005-03-09 09:52:10 +0000 | [diff] [blame] | 49 | " -pf <mode> \t- Forces the pixel format for the session.\n" |
| 50 | " \t List of the pixel formats:\n" |
| 51 | " \t 0 - Auto,\n" |
| 52 | " \t 1 - depth 8 (RGB332),\n" |
| 53 | " \t 2 - depth 16 (RGB655),\n" |
| 54 | " \t 3 - depth 24 (RGB888).\n" |
george82 | e6883de | 2005-02-08 14:42:12 +0000 | [diff] [blame] | 55 | " -speed <value>\t- Sets playback speed, where 1 is normal speed,\n" |
| 56 | " \t is double speed, 0.5 is half speed. Default: 1.0.\n" |
| 57 | " -pos <ms> \t- Sets initial time position in the session file,\n" |
| 58 | " \t in milliseconds. Default: 0.\n" |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 59 | " -autoplay \t- Runs the player in the playback mode.\n"; |
george82 | e6883de | 2005-02-08 14:42:12 +0000 | [diff] [blame] | 60 | |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 61 | // -=- RfbPlayer's defines |
| 62 | |
| 63 | #define strcasecmp _stricmp |
george82 | 0981b34 | 2005-03-19 11:19:00 +0000 | [diff] [blame] | 64 | #define UPF_REGISTRY_PATH "Software\\TightVnc\\RfbPlayer\\UserDefinedPF" |
george82 | 5457d41 | 2005-02-19 06:43:09 +0000 | [diff] [blame] | 65 | #define MAX_SPEED 10.00 |
| 66 | #define CALCULATION_ERROR MAX_SPEED / 1000 |
george82 | d4d69e6 | 2005-02-05 09:23:18 +0000 | [diff] [blame] | 67 | #define MAX_POS_TRACKBAR_RANGE 50 |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 68 | #define CTRL_BAR_HEIGHT 28 |
george82 | 68d2514 | 2005-02-13 09:33:22 +0000 | [diff] [blame] | 69 | #define DEFAULT_PLAYER_WIDTH 640 |
| 70 | #define DEFAULT_PLAYER_HEIGHT 480 |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 71 | |
george82 | d070c69 | 2005-01-19 16:44:04 +0000 | [diff] [blame] | 72 | #define ID_TOOLBAR 500 |
| 73 | #define ID_PLAY 510 |
| 74 | #define ID_PAUSE 520 |
| 75 | #define ID_TIME_STATIC 530 |
| 76 | #define ID_SPEED_STATIC 540 |
| 77 | #define ID_SPEED_EDIT 550 |
| 78 | #define ID_POS_TRACKBAR 560 |
| 79 | #define ID_SPEED_UPDOWN 570 |
| 80 | |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 81 | // |
| 82 | // -=- RfbPlayerClass |
| 83 | |
| 84 | // |
| 85 | // Window class used as the basis for RfbPlayer instance |
| 86 | // |
| 87 | |
| 88 | class RfbPlayerClass { |
| 89 | public: |
| 90 | RfbPlayerClass(); |
| 91 | ~RfbPlayerClass(); |
| 92 | ATOM classAtom; |
| 93 | HINSTANCE instance; |
| 94 | }; |
| 95 | |
| 96 | LRESULT CALLBACK RfbPlayerProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { |
| 97 | LRESULT result; |
| 98 | |
| 99 | if (msg == WM_CREATE) |
| 100 | SetWindowLong(hwnd, GWL_USERDATA, (long)((CREATESTRUCT*)lParam)->lpCreateParams); |
| 101 | else if (msg == WM_DESTROY) { |
| 102 | RfbPlayer* _this = (RfbPlayer*) GetWindowLong(hwnd, GWL_USERDATA); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 103 | SetWindowLong(hwnd, GWL_USERDATA, 0); |
| 104 | } |
| 105 | RfbPlayer* _this = (RfbPlayer*) GetWindowLong(hwnd, GWL_USERDATA); |
| 106 | if (!_this) { |
| 107 | vlog.info("null _this in %x, message %u", hwnd, msg); |
| 108 | return DefWindowProc(hwnd, msg, wParam, lParam); |
| 109 | } |
| 110 | |
| 111 | try { |
| 112 | result = _this->processMainMessage(hwnd, msg, wParam, lParam); |
| 113 | } catch (rdr::Exception& e) { |
| 114 | vlog.error("untrapped: %s", e.str()); |
| 115 | } |
| 116 | |
| 117 | return result; |
| 118 | }; |
| 119 | |
| 120 | RfbPlayerClass::RfbPlayerClass() : classAtom(0) { |
| 121 | WNDCLASS wndClass; |
| 122 | wndClass.style = 0; |
| 123 | wndClass.lpfnWndProc = RfbPlayerProc; |
| 124 | wndClass.cbClsExtra = 0; |
| 125 | wndClass.cbWndExtra = 0; |
| 126 | wndClass.hInstance = instance = GetModuleHandle(0); |
| 127 | wndClass.hIcon = (HICON)LoadImage(GetModuleHandle(0), |
george82 | 7214b82 | 2004-12-12 07:02:51 +0000 | [diff] [blame] | 128 | MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 0, 0, LR_SHARED); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 129 | if (!wndClass.hIcon) |
| 130 | printf("unable to load icon:%ld", GetLastError()); |
| 131 | wndClass.hCursor = LoadCursor(NULL, IDC_ARROW); |
| 132 | wndClass.hbrBackground = HBRUSH(COLOR_WINDOW); |
george82 | c2c691f | 2004-12-08 18:04:14 +0000 | [diff] [blame] | 133 | wndClass.lpszMenuName = MAKEINTRESOURCE(IDR_MENU); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 134 | wndClass.lpszClassName = _T("RfbPlayerClass"); |
| 135 | classAtom = RegisterClass(&wndClass); |
| 136 | if (!classAtom) { |
| 137 | throw rdr::SystemException("unable to register RfbPlayer window class", |
| 138 | GetLastError()); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | RfbPlayerClass::~RfbPlayerClass() { |
| 143 | if (classAtom) { |
| 144 | UnregisterClass((const TCHAR*)classAtom, instance); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | RfbPlayerClass baseClass; |
| 149 | |
| 150 | // |
| 151 | // -=- RfbFrameClass |
| 152 | |
| 153 | // |
| 154 | // Window class used to displaying the rfb data |
| 155 | // |
| 156 | |
| 157 | class RfbFrameClass { |
| 158 | public: |
| 159 | RfbFrameClass(); |
| 160 | ~RfbFrameClass(); |
| 161 | ATOM classAtom; |
| 162 | HINSTANCE instance; |
| 163 | }; |
| 164 | |
| 165 | LRESULT CALLBACK FrameProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { |
| 166 | LRESULT result; |
| 167 | |
| 168 | if (msg == WM_CREATE) |
| 169 | SetWindowLong(hwnd, GWL_USERDATA, (long)((CREATESTRUCT*)lParam)->lpCreateParams); |
| 170 | else if (msg == WM_DESTROY) |
| 171 | SetWindowLong(hwnd, GWL_USERDATA, 0); |
| 172 | RfbPlayer* _this = (RfbPlayer*) GetWindowLong(hwnd, GWL_USERDATA); |
| 173 | if (!_this) { |
| 174 | vlog.info("null _this in %x, message %u", hwnd, msg); |
| 175 | return DefWindowProc(hwnd, msg, wParam, lParam); |
| 176 | } |
| 177 | |
| 178 | try { |
| 179 | result = _this->processFrameMessage(hwnd, msg, wParam, lParam); |
| 180 | } catch (rdr::Exception& e) { |
| 181 | vlog.error("untrapped: %s", e.str()); |
| 182 | } |
| 183 | |
| 184 | return result; |
| 185 | } |
| 186 | |
| 187 | RfbFrameClass::RfbFrameClass() : classAtom(0) { |
| 188 | WNDCLASS wndClass; |
| 189 | wndClass.style = 0; |
| 190 | wndClass.lpfnWndProc = FrameProc; |
| 191 | wndClass.cbClsExtra = 0; |
| 192 | wndClass.cbWndExtra = 0; |
| 193 | wndClass.hInstance = instance = GetModuleHandle(0); |
| 194 | wndClass.hIcon = 0; |
| 195 | wndClass.hCursor = LoadCursor(NULL, IDC_ARROW); |
| 196 | wndClass.hbrBackground = 0; |
| 197 | wndClass.lpszMenuName = 0; |
| 198 | wndClass.lpszClassName = _T("RfbPlayerClass1"); |
| 199 | classAtom = RegisterClass(&wndClass); |
| 200 | if (!classAtom) { |
| 201 | throw rdr::SystemException("unable to register RfbPlayer window class", |
| 202 | GetLastError()); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | RfbFrameClass::~RfbFrameClass() { |
| 207 | if (classAtom) { |
| 208 | UnregisterClass((const TCHAR*)classAtom, instance); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | RfbFrameClass frameClass; |
| 213 | |
| 214 | // |
| 215 | // -=- RfbPlayer instance implementation |
| 216 | // |
| 217 | |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 218 | RfbPlayer::RfbPlayer(char *_fileName, PlayerOptions *_options) |
| 219 | : RfbProto(_fileName), fileName(_fileName), buffer(0), client_size(0, 0, 32, 32), |
| 220 | window_size(0, 0, 32, 32), cutText(0), seekMode(false), lastPos(0), |
| 221 | timeStatic(0), speedEdit(0), posTrackBar(0), speedUpDown(0), |
george82 | 3104aec | 2005-02-21 13:20:56 +0000 | [diff] [blame] | 222 | rfbReader(0), sessionTimeMs(0), sliderDraging(false), sliderStepMs(0), |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 223 | imageDataStartTime(0), rewindFlag(false), stopped(false) { |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 224 | |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 225 | // Save the player options |
| 226 | memcpy(&options, _options, sizeof(options)); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 227 | |
george82 | 3c8fbbf | 2005-01-24 11:09:08 +0000 | [diff] [blame] | 228 | // Reset the full session time |
| 229 | strcpy(fullSessionTime, "00m:00s"); |
| 230 | |
george82 | 0981b34 | 2005-03-19 11:19:00 +0000 | [diff] [blame] | 231 | // Load the user defined pixel formats from the registry |
| 232 | supportedPF.readUserDefinedPF(HKEY_CURRENT_USER, UPF_REGISTRY_PATH); |
| 233 | |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 234 | // Create the main window |
| 235 | const TCHAR* name = _T("RfbPlayer"); |
george82 | 2ff7a61 | 2005-02-19 17:05:24 +0000 | [diff] [blame] | 236 | int x = max(0, (GetSystemMetrics(SM_CXSCREEN) - DEFAULT_PLAYER_WIDTH) / 2); |
| 237 | int y = max(0, (GetSystemMetrics(SM_CYSCREEN) - DEFAULT_PLAYER_HEIGHT) / 2); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 238 | mainHwnd = CreateWindow((const TCHAR*)baseClass.classAtom, name, WS_OVERLAPPEDWINDOW, |
george82 | 2ff7a61 | 2005-02-19 17:05:24 +0000 | [diff] [blame] | 239 | x, y, DEFAULT_PLAYER_WIDTH, DEFAULT_PLAYER_HEIGHT, 0, 0, baseClass.instance, this); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 240 | if (!mainHwnd) { |
| 241 | throw rdr::SystemException("unable to create WMNotifier window instance", GetLastError()); |
| 242 | } |
| 243 | vlog.debug("created window \"%s\" (%x)", (const char*)CStr(name), getMainHandle()); |
| 244 | |
| 245 | // Create the backing buffer |
| 246 | buffer = new win32::DIBSectionBuffer(getFrameHandle()); |
george82 | 1031310 | 2005-01-17 13:11:40 +0000 | [diff] [blame] | 247 | setVisible(true); |
george82 | 5beb62a | 2005-02-09 13:04:32 +0000 | [diff] [blame] | 248 | |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 249 | // If run with command-line parameters, |
| 250 | // open the session file with default settings, otherwise |
| 251 | // restore player settings from the registry |
george82 | 17e92cb | 2005-01-31 16:01:02 +0000 | [diff] [blame] | 252 | if (fileName) { |
| 253 | openSessionFile(fileName); |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 254 | if (options.initTime > 0) setPos(options.initTime); |
| 255 | setSpeed(options.playbackSpeed); |
george82 | 63ebbcc | 2005-02-12 12:09:13 +0000 | [diff] [blame] | 256 | } else { |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 257 | options.readFromRegistry(); |
george82 | 63ebbcc | 2005-02-12 12:09:13 +0000 | [diff] [blame] | 258 | disableTBandMenuItems(); |
george82 | f530276 | 2005-02-13 12:31:03 +0000 | [diff] [blame] | 259 | setTitle("None"); |
george82 | 17e92cb | 2005-01-31 16:01:02 +0000 | [diff] [blame] | 260 | } |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | RfbPlayer::~RfbPlayer() { |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 264 | options.writeToRegistry(); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 265 | vlog.debug("~RfbPlayer"); |
george82 | ce8dc3a | 2005-01-31 13:06:54 +0000 | [diff] [blame] | 266 | if (rfbReader) { |
george82 | ce8dc3a | 2005-01-31 13:06:54 +0000 | [diff] [blame] | 267 | delete rfbReader->join(); |
| 268 | rfbReader = 0; |
| 269 | } |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 270 | if (mainHwnd) { |
| 271 | setVisible(false); |
| 272 | DestroyWindow(mainHwnd); |
| 273 | mainHwnd = 0; |
| 274 | } |
george82 | 5beb62a | 2005-02-09 13:04:32 +0000 | [diff] [blame] | 275 | if (buffer) delete buffer; |
| 276 | if (cutText) delete [] cutText; |
george82 | 7009c89 | 2005-02-19 12:49:42 +0000 | [diff] [blame] | 277 | if (fileName) delete [] fileName; |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 278 | vlog.debug("~RfbPlayer done"); |
| 279 | } |
| 280 | |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 281 | LRESULT |
| 282 | RfbPlayer::processMainMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { |
| 283 | switch (msg) { |
| 284 | |
| 285 | // -=- Process standard window messages |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 286 | |
| 287 | case WM_CREATE: |
| 288 | { |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 289 | // Create the frame window |
| 290 | frameHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, (const TCHAR*)frameClass.classAtom, |
| 291 | 0, WS_CHILD | WS_VISIBLE, 0, CTRL_BAR_HEIGHT, 10, CTRL_BAR_HEIGHT + 10, |
| 292 | hwnd, 0, frameClass.instance, this); |
| 293 | |
george82 | d070c69 | 2005-01-19 16:44:04 +0000 | [diff] [blame] | 294 | createToolBar(hwnd); |
| 295 | |
george82 | 006f279 | 2005-02-05 07:40:47 +0000 | [diff] [blame] | 296 | hMenu = GetMenu(hwnd); |
george82 | 5c13c66 | 2005-01-27 14:48:23 +0000 | [diff] [blame] | 297 | |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 298 | return 0; |
| 299 | } |
| 300 | |
george82 | 7214b82 | 2004-12-12 07:02:51 +0000 | [diff] [blame] | 301 | // Process the main menu and toolbar's messages |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 302 | |
| 303 | case WM_COMMAND: |
george82 | 5c13c66 | 2005-01-27 14:48:23 +0000 | [diff] [blame] | 304 | switch (LOWORD(wParam)) { |
george82 | 6e51fcc | 2005-02-06 13:30:49 +0000 | [diff] [blame] | 305 | case ID_OPENFILE: |
| 306 | { |
| 307 | char curDir[_MAX_DIR]; |
| 308 | static char filename[_MAX_PATH]; |
| 309 | OPENFILENAME ofn; |
| 310 | memset((void *) &ofn, 0, sizeof(OPENFILENAME)); |
| 311 | GetCurrentDirectory(sizeof(curDir), curDir); |
| 312 | |
| 313 | ofn.lStructSize = sizeof(OPENFILENAME); |
| 314 | ofn.hwndOwner = getMainHandle(); |
| 315 | ofn.lpstrFile = filename; |
| 316 | ofn.nMaxFile = sizeof(filename); |
| 317 | ofn.lpstrInitialDir = curDir; |
| 318 | ofn.lpstrFilter = "Rfb Session files (*.rfb)\0*.rfb\0" \ |
| 319 | "All files (*.*)\0*.*\0"; |
| 320 | ofn.lpstrDefExt = "rfb"; |
| 321 | ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; |
george82 | 9d5129a | 2005-02-21 13:32:39 +0000 | [diff] [blame] | 322 | if (GetOpenFileName(&ofn)) { |
george82 | 6e51fcc | 2005-02-06 13:30:49 +0000 | [diff] [blame] | 323 | openSessionFile(filename); |
george82 | 9d5129a | 2005-02-21 13:32:39 +0000 | [diff] [blame] | 324 | } |
george82 | 6e51fcc | 2005-02-06 13:30:49 +0000 | [diff] [blame] | 325 | } |
| 326 | break; |
george82 | 71ca177 | 2005-02-13 10:50:46 +0000 | [diff] [blame] | 327 | case ID_CLOSEFILE: |
| 328 | closeSessionFile(); |
| 329 | break; |
george82 | 5c13c66 | 2005-01-27 14:48:23 +0000 | [diff] [blame] | 330 | case ID_PLAY: |
| 331 | setPaused(false); |
george82 | 5c13c66 | 2005-01-27 14:48:23 +0000 | [diff] [blame] | 332 | break; |
| 333 | case ID_PAUSE: |
| 334 | setPaused(true); |
george82 | 5c13c66 | 2005-01-27 14:48:23 +0000 | [diff] [blame] | 335 | break; |
| 336 | case ID_STOP: |
| 337 | if (getTimeOffset() != 0) { |
george82 | 006f279 | 2005-02-05 07:40:47 +0000 | [diff] [blame] | 338 | stopPlayback(); |
george82 | 5c13c66 | 2005-01-27 14:48:23 +0000 | [diff] [blame] | 339 | } |
george82 | 5c13c66 | 2005-01-27 14:48:23 +0000 | [diff] [blame] | 340 | break; |
| 341 | case ID_PLAYPAUSE: |
george82 | bc999f4 | 2005-03-19 11:48:19 +0000 | [diff] [blame^] | 342 | if (rfbReader) { |
| 343 | if (isPaused()) { |
| 344 | setPaused(false); |
| 345 | } else { |
| 346 | setPaused(true); |
| 347 | } |
george82 | 5c13c66 | 2005-01-27 14:48:23 +0000 | [diff] [blame] | 348 | } |
george82 | 5c13c66 | 2005-01-27 14:48:23 +0000 | [diff] [blame] | 349 | break; |
george82 | 7549df4 | 2005-02-08 16:31:02 +0000 | [diff] [blame] | 350 | case ID_GOTO: |
| 351 | { |
| 352 | GotoPosDialog gotoPosDlg; |
george82 | d9957b7 | 2005-03-11 14:22:14 +0000 | [diff] [blame] | 353 | if (gotoPosDlg.showDialog(getMainHandle())) { |
george82 | 1d5d40d | 2005-02-20 03:25:47 +0000 | [diff] [blame] | 354 | long gotoTime = min(gotoPosDlg.getPos(), sessionTimeMs); |
| 355 | setPos(gotoTime); |
| 356 | updatePos(gotoTime); |
george82 | a6900d7 | 2005-02-21 17:24:26 +0000 | [diff] [blame] | 357 | setPaused(isPaused());; |
george82 | 7549df4 | 2005-02-08 16:31:02 +0000 | [diff] [blame] | 358 | } |
| 359 | } |
| 360 | break; |
george82 | 5c13c66 | 2005-01-27 14:48:23 +0000 | [diff] [blame] | 361 | case ID_FULLSCREEN: |
| 362 | MessageBox(getMainHandle(), "It is not working yet!", "RfbPlayer", MB_OK); |
| 363 | break; |
george82 | 31a3633 | 2005-02-06 17:27:34 +0000 | [diff] [blame] | 364 | case ID_LOOP: |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 365 | options.loopPlayback = !options.loopPlayback; |
| 366 | if (options.loopPlayback) CheckMenuItem(hMenu, ID_LOOP, MF_CHECKED); |
george82 | 31a3633 | 2005-02-06 17:27:34 +0000 | [diff] [blame] | 367 | else CheckMenuItem(hMenu, ID_LOOP, MF_UNCHECKED); |
| 368 | break; |
george82 | 4ea27f6 | 2005-01-29 15:03:06 +0000 | [diff] [blame] | 369 | case ID_RETURN: |
| 370 | // Update the speed if return pressed in speedEdit |
| 371 | if (speedEdit == GetFocus()) { |
| 372 | char speedStr[20], *stopStr; |
| 373 | GetWindowText(speedEdit, speedStr, sizeof(speedStr)); |
| 374 | double speed = strtod(speedStr, &stopStr); |
| 375 | if (speed > 0) { |
| 376 | speed = min(MAX_SPEED, speed); |
george82 | 4ea27f6 | 2005-01-29 15:03:06 +0000 | [diff] [blame] | 377 | } else { |
| 378 | speed = getSpeed(); |
| 379 | } |
| 380 | setSpeed(speed); |
george82 | 4ea27f6 | 2005-01-29 15:03:06 +0000 | [diff] [blame] | 381 | } |
| 382 | break; |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 383 | case ID_OPTIONS: |
| 384 | { |
| 385 | OptionsDialog optionsDialog(&options); |
george82 | d9957b7 | 2005-03-11 14:22:14 +0000 | [diff] [blame] | 386 | optionsDialog.showDialog(getMainHandle()); |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 387 | } |
| 388 | break; |
george82 | 01aa673 | 2005-02-06 17:13:03 +0000 | [diff] [blame] | 389 | case ID_EXIT: |
george82 | 01aa673 | 2005-02-06 17:13:03 +0000 | [diff] [blame] | 390 | PostQuitMessage(0); |
| 391 | break; |
george82 | ef5f726 | 2005-02-08 15:09:26 +0000 | [diff] [blame] | 392 | case ID_HELP_COMMANDLINESWITCHES: |
george82 | 59f8453 | 2005-02-08 15:01:39 +0000 | [diff] [blame] | 393 | MessageBox(getMainHandle(), |
| 394 | usage_msg, "RfbPlayer", MB_OK | MB_ICONINFORMATION); |
| 395 | break; |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 396 | } |
| 397 | break; |
| 398 | |
| 399 | // Update frame's window size and add scrollbars if required |
| 400 | |
| 401 | case WM_SIZE: |
| 402 | { |
george82 | d070c69 | 2005-01-19 16:44:04 +0000 | [diff] [blame] | 403 | |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 404 | Point old_offset = bufferToClient(Point(0, 0)); |
| 405 | |
| 406 | // Update the cached sizing information |
| 407 | RECT r; |
| 408 | GetClientRect(getMainHandle(), &r); |
| 409 | MoveWindow(getFrameHandle(), 0, CTRL_BAR_HEIGHT, r.right - r.left, |
| 410 | r.bottom - r.top - CTRL_BAR_HEIGHT, TRUE); |
| 411 | |
| 412 | GetWindowRect(getFrameHandle(), &r); |
| 413 | window_size = Rect(r.left, r.top, r.right, r.bottom); |
| 414 | GetClientRect(getFrameHandle(), &r); |
| 415 | client_size = Rect(r.left, r.top, r.right, r.bottom); |
| 416 | |
| 417 | // Determine whether scrollbars are required |
| 418 | calculateScrollBars(); |
george82 | d070c69 | 2005-01-19 16:44:04 +0000 | [diff] [blame] | 419 | |
| 420 | // Resize the ToolBar |
| 421 | tb.autoSize(); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 422 | |
| 423 | // Redraw if required |
| 424 | if (!old_offset.equals(bufferToClient(Point(0, 0)))) |
| 425 | InvalidateRect(getFrameHandle(), 0, TRUE); |
| 426 | } |
| 427 | break; |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 428 | |
| 429 | // Process messages from posTrackBar |
| 430 | |
| 431 | case WM_HSCROLL: |
| 432 | { |
| 433 | long Pos = SendMessage(posTrackBar, TBM_GETPOS, 0, 0); |
| 434 | Pos *= sliderStepMs; |
| 435 | |
| 436 | switch (LOWORD(wParam)) { |
| 437 | case TB_PAGEUP: |
| 438 | case TB_PAGEDOWN: |
| 439 | case TB_LINEUP: |
| 440 | case TB_LINEDOWN: |
| 441 | case TB_THUMBTRACK: |
| 442 | sliderDraging = true; |
| 443 | updatePos(Pos); |
| 444 | return 0; |
george82 | bcc129b | 2005-03-15 17:11:40 +0000 | [diff] [blame] | 445 | case TB_THUMBPOSITION: |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 446 | case TB_ENDTRACK: |
| 447 | setPos(Pos); |
george82 | a6900d7 | 2005-02-21 17:24:26 +0000 | [diff] [blame] | 448 | setPaused(isPaused());; |
george82 | bcc129b | 2005-03-15 17:11:40 +0000 | [diff] [blame] | 449 | updatePos(Pos); |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 450 | sliderDraging = false; |
| 451 | return 0; |
| 452 | default: |
| 453 | break; |
| 454 | } |
| 455 | } |
| 456 | break; |
george82 | 9e6e6cc | 2005-01-29 13:12:05 +0000 | [diff] [blame] | 457 | |
| 458 | case WM_NOTIFY: |
| 459 | switch (((NMHDR*)lParam)->code) { |
| 460 | case UDN_DELTAPOS: |
| 461 | if ((int)wParam == ID_SPEED_UPDOWN) { |
george82 | 4ea27f6 | 2005-01-29 15:03:06 +0000 | [diff] [blame] | 462 | BOOL lResult = FALSE; |
george82 | 9e6e6cc | 2005-01-29 13:12:05 +0000 | [diff] [blame] | 463 | char speedStr[20] = "\0"; |
| 464 | DWORD speedRange = SendMessage(speedUpDown, UDM_GETRANGE, 0, 0); |
| 465 | LPNM_UPDOWN upDown = (LPNM_UPDOWN)lParam; |
| 466 | double speed; |
| 467 | |
george82 | 4ea27f6 | 2005-01-29 15:03:06 +0000 | [diff] [blame] | 468 | // The out of range checking |
george82 | 9e6e6cc | 2005-01-29 13:12:05 +0000 | [diff] [blame] | 469 | if (upDown->iDelta > 0) { |
| 470 | speed = min(upDown->iPos + upDown->iDelta, LOWORD(speedRange)) * 0.5; |
| 471 | } else { |
george82 | 4ea27f6 | 2005-01-29 15:03:06 +0000 | [diff] [blame] | 472 | // It's need to round the UpDown position |
| 473 | if ((upDown->iPos * 0.5) != getSpeed()) { |
| 474 | upDown->iDelta = 0; |
| 475 | lResult = TRUE; |
| 476 | } |
george82 | 9e6e6cc | 2005-01-29 13:12:05 +0000 | [diff] [blame] | 477 | speed = max(upDown->iPos + upDown->iDelta, HIWORD(speedRange)) * 0.5; |
| 478 | } |
george82 | 9e6e6cc | 2005-01-29 13:12:05 +0000 | [diff] [blame] | 479 | sprintf(speedStr, "%.2f", speed); |
| 480 | SetWindowText(speedEdit, speedStr); |
george82 | 5f326fe | 2005-02-20 08:01:01 +0000 | [diff] [blame] | 481 | is->setSpeed(speed); |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 482 | options.playbackSpeed = speed; |
george82 | 4ea27f6 | 2005-01-29 15:03:06 +0000 | [diff] [blame] | 483 | return lResult; |
george82 | 9e6e6cc | 2005-01-29 13:12:05 +0000 | [diff] [blame] | 484 | } |
george82 | 4ea27f6 | 2005-01-29 15:03:06 +0000 | [diff] [blame] | 485 | } |
george82 | 9e6e6cc | 2005-01-29 13:12:05 +0000 | [diff] [blame] | 486 | return 0; |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 487 | |
| 488 | case WM_CLOSE: |
| 489 | vlog.debug("WM_CLOSE %x", getMainHandle()); |
| 490 | PostQuitMessage(0); |
| 491 | break; |
| 492 | } |
| 493 | |
| 494 | return rfb::win32::SafeDefWindowProc(getMainHandle(), msg, wParam, lParam); |
| 495 | } |
| 496 | |
| 497 | LRESULT RfbPlayer::processFrameMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { |
| 498 | switch (msg) { |
| 499 | |
| 500 | case WM_PAINT: |
| 501 | { |
george82 | 1e846ff | 2005-02-24 13:13:33 +0000 | [diff] [blame] | 502 | if (isSeeking() || rewindFlag) { |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 503 | seekMode = true; |
| 504 | return 0; |
| 505 | } else { |
| 506 | if (seekMode) { |
| 507 | seekMode = false; |
| 508 | InvalidateRect(getFrameHandle(), 0, true); |
| 509 | UpdateWindow(getFrameHandle()); |
| 510 | return 0; |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | PAINTSTRUCT ps; |
| 515 | HDC paintDC = BeginPaint(getFrameHandle(), &ps); |
| 516 | if (!paintDC) |
| 517 | throw SystemException("unable to BeginPaint", GetLastError()); |
| 518 | Rect pr = Rect(ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom); |
| 519 | |
| 520 | if (!pr.is_empty()) { |
| 521 | |
| 522 | if (buffer->bitmap) { |
| 523 | |
| 524 | // Get device context |
| 525 | BitmapDC bitmapDC(paintDC, buffer->bitmap); |
| 526 | |
| 527 | // Blit the border if required |
| 528 | Rect bufpos = bufferToClient(buffer->getRect()); |
| 529 | if (!pr.enclosed_by(bufpos)) { |
| 530 | vlog.debug("draw border"); |
| 531 | HBRUSH black = (HBRUSH) GetStockObject(BLACK_BRUSH); |
| 532 | RECT r; |
| 533 | SetRect(&r, 0, 0, bufpos.tl.x, client_size.height()); FillRect(paintDC, &r, black); |
| 534 | SetRect(&r, bufpos.tl.x, 0, bufpos.br.x, bufpos.tl.y); FillRect(paintDC, &r, black); |
| 535 | SetRect(&r, bufpos.br.x, 0, client_size.width(), client_size.height()); FillRect(paintDC, &r, black); |
| 536 | SetRect(&r, bufpos.tl.x, bufpos.br.y, bufpos.br.x, client_size.height()); FillRect(paintDC, &r, black); |
| 537 | } |
| 538 | |
| 539 | // Do the blit |
| 540 | Point buf_pos = clientToBuffer(pr.tl); |
| 541 | if (!BitBlt(paintDC, pr.tl.x, pr.tl.y, pr.width(), pr.height(), |
| 542 | bitmapDC, buf_pos.x, buf_pos.y, SRCCOPY)) |
| 543 | throw SystemException("unable to BitBlt to window", GetLastError()); |
| 544 | |
| 545 | } else { |
| 546 | // Blit a load of black |
| 547 | if (!BitBlt(paintDC, pr.tl.x, pr.tl.y, pr.width(), pr.height(), |
| 548 | 0, 0, 0, BLACKNESS)) |
| 549 | throw SystemException("unable to BitBlt to blank window", GetLastError()); |
| 550 | } |
| 551 | } |
| 552 | EndPaint(getFrameHandle(), &ps); |
| 553 | } |
| 554 | return 0; |
george82 | 03c01da | 2005-03-16 12:36:53 +0000 | [diff] [blame] | 555 | |
george82 | aff63ab | 2005-03-16 13:48:59 +0000 | [diff] [blame] | 556 | // Process play/pause by the left mouse button |
| 557 | case WM_LBUTTONDOWN: |
george82 | 03c01da | 2005-03-16 12:36:53 +0000 | [diff] [blame] | 558 | SendMessage(getMainHandle(), WM_COMMAND, ID_PLAYPAUSE, 0); |
| 559 | return 0; |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 560 | |
| 561 | case WM_VSCROLL: |
| 562 | case WM_HSCROLL: |
| 563 | { |
| 564 | Point delta; |
| 565 | int newpos = (msg == WM_VSCROLL) ? scrolloffset.y : scrolloffset.x; |
| 566 | |
| 567 | switch (LOWORD(wParam)) { |
| 568 | case SB_PAGEUP: newpos -= 50; break; |
| 569 | case SB_PAGEDOWN: newpos += 50; break; |
| 570 | case SB_LINEUP: newpos -= 5; break; |
| 571 | case SB_LINEDOWN: newpos += 5; break; |
| 572 | case SB_THUMBTRACK: |
| 573 | case SB_THUMBPOSITION: newpos = HIWORD(wParam); break; |
| 574 | default: vlog.info("received unknown scroll message"); |
| 575 | }; |
| 576 | |
| 577 | if (msg == WM_HSCROLL) |
| 578 | setViewportOffset(Point(newpos, scrolloffset.y)); |
| 579 | else |
| 580 | setViewportOffset(Point(scrolloffset.x, newpos)); |
| 581 | |
| 582 | SCROLLINFO si; |
| 583 | si.cbSize = sizeof(si); |
| 584 | si.fMask = SIF_POS; |
| 585 | si.nPos = newpos; |
| 586 | SetScrollInfo(getFrameHandle(), (msg == WM_VSCROLL) ? SB_VERT : SB_HORZ, &si, TRUE); |
| 587 | } |
| 588 | break; |
| 589 | } |
| 590 | |
| 591 | return DefWindowProc(hwnd, msg, wParam, lParam); |
| 592 | } |
| 593 | |
george82 | d070c69 | 2005-01-19 16:44:04 +0000 | [diff] [blame] | 594 | void RfbPlayer::createToolBar(HWND parentHwnd) { |
| 595 | RECT tRect; |
| 596 | InitCommonControls(); |
| 597 | |
| 598 | tb.create(ID_TOOLBAR, parentHwnd); |
| 599 | tb.addBitmap(4, IDB_TOOLBAR); |
| 600 | |
| 601 | // Create the control buttons |
| 602 | tb.addButton(0, ID_PLAY); |
| 603 | tb.addButton(1, ID_PAUSE); |
| 604 | tb.addButton(2, ID_STOP); |
| 605 | tb.addButton(0, 0, TBSTATE_ENABLED, TBSTYLE_SEP); |
| 606 | tb.addButton(3, ID_FULLSCREEN); |
| 607 | tb.addButton(0, 0, TBSTATE_ENABLED, TBSTYLE_SEP); |
| 608 | |
| 609 | // Create the static control for the time output |
| 610 | tb.addButton(125, 0, TBSTATE_ENABLED, TBSTYLE_SEP); |
| 611 | tb.getButtonRect(6, &tRect); |
| 612 | timeStatic = CreateWindowEx(0, "Static", "00m:00s (00m:00s)", |
| 613 | WS_CHILD | WS_VISIBLE, tRect.left, tRect.top+2, tRect.right-tRect.left, |
| 614 | tRect.bottom-tRect.top, tb.getHandle(), (HMENU)ID_TIME_STATIC, |
| 615 | GetModuleHandle(0), 0); |
| 616 | tb.addButton(0, 10, TBSTATE_ENABLED, TBSTYLE_SEP); |
| 617 | |
| 618 | // Create the trackbar control for the time position |
| 619 | tb.addButton(200, 0, TBSTATE_ENABLED, TBSTYLE_SEP); |
| 620 | tb.getButtonRect(8, &tRect); |
george82 | d4d69e6 | 2005-02-05 09:23:18 +0000 | [diff] [blame] | 621 | posTrackBar = CreateWindowEx(0, TRACKBAR_CLASS, "Trackbar Control", |
george82 | d070c69 | 2005-01-19 16:44:04 +0000 | [diff] [blame] | 622 | WS_CHILD | WS_VISIBLE | TBS_AUTOTICKS | TBS_ENABLESELRANGE, |
| 623 | tRect.left, tRect.top, tRect.right-tRect.left, tRect.bottom-tRect.top, |
| 624 | parentHwnd, (HMENU)ID_POS_TRACKBAR, GetModuleHandle(0), 0); |
| 625 | // It's need to send notify messages to toolbar parent window |
george82 | d4d69e6 | 2005-02-05 09:23:18 +0000 | [diff] [blame] | 626 | SetParent(posTrackBar, tb.getHandle()); |
george82 | d070c69 | 2005-01-19 16:44:04 +0000 | [diff] [blame] | 627 | tb.addButton(0, 10, TBSTATE_ENABLED, TBSTYLE_SEP); |
| 628 | |
| 629 | // Create the label with "Speed:" caption |
| 630 | tb.addButton(50, 0, TBSTATE_ENABLED, TBSTYLE_SEP); |
| 631 | tb.getButtonRect(10, &tRect); |
| 632 | CreateWindowEx(0, "Static", "Speed:", WS_CHILD | WS_VISIBLE, |
| 633 | tRect.left, tRect.top+2, tRect.right-tRect.left, tRect.bottom-tRect.top, |
| 634 | tb.getHandle(), (HMENU)ID_SPEED_STATIC, GetModuleHandle(0), 0); |
| 635 | |
| 636 | // Create the edit control and the spin for the speed managing |
| 637 | tb.addButton(60, 0, TBSTATE_ENABLED, TBSTYLE_SEP); |
| 638 | tb.getButtonRect(11, &tRect); |
| 639 | speedEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", "1.00", |
| 640 | WS_CHILD | WS_VISIBLE | ES_RIGHT, tRect.left, tRect.top, |
| 641 | tRect.right-tRect.left, tRect.bottom-tRect.top, parentHwnd, |
| 642 | (HMENU)ID_SPEED_EDIT, GetModuleHandle(0), 0); |
| 643 | // It's need to send notify messages to toolbar parent window |
| 644 | SetParent(speedEdit, tb.getHandle()); |
| 645 | |
| 646 | speedUpDown = CreateUpDownControl(WS_CHILD | WS_VISIBLE |
| 647 | | WS_BORDER | UDS_ALIGNRIGHT, 0, 0, 0, 0, tb.getHandle(), |
george82 | 9e6e6cc | 2005-01-29 13:12:05 +0000 | [diff] [blame] | 648 | ID_SPEED_UPDOWN, GetModuleHandle(0), speedEdit, 20, 1, 2); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 649 | } |
| 650 | |
george82 | a21d295 | 2005-02-12 11:30:03 +0000 | [diff] [blame] | 651 | void RfbPlayer::disableTBandMenuItems() { |
| 652 | // Disable the menu items |
| 653 | EnableMenuItem(hMenu, ID_CLOSEFILE, MF_GRAYED | MF_BYCOMMAND); |
| 654 | EnableMenuItem(hMenu, ID_FULLSCREEN, MF_GRAYED | MF_BYCOMMAND); |
| 655 | EnableMenuItem(GetSubMenu(hMenu, 1), 1, MF_GRAYED | MF_BYPOSITION); |
| 656 | EnableMenuItem(hMenu, ID_PLAYPAUSE, MF_GRAYED | MF_BYCOMMAND); |
| 657 | EnableMenuItem(hMenu, ID_STOP, MF_GRAYED | MF_BYCOMMAND); |
| 658 | EnableMenuItem(hMenu, ID_GOTO, MF_GRAYED | MF_BYCOMMAND); |
| 659 | EnableMenuItem(hMenu, ID_LOOP, MF_GRAYED | MF_BYCOMMAND); |
| 660 | EnableMenuItem(hMenu, ID_COPYTOCLIPBOARD, MF_GRAYED | MF_BYCOMMAND); |
| 661 | EnableMenuItem(hMenu, ID_FRAMEEXTRACT, MF_GRAYED | MF_BYCOMMAND); |
| 662 | |
| 663 | // Disable the toolbar buttons and child controls |
| 664 | tb.enableButton(ID_PLAY, false); |
| 665 | tb.enableButton(ID_PAUSE, false); |
| 666 | tb.enableButton(ID_STOP, false); |
| 667 | tb.enableButton(ID_FULLSCREEN, false); |
| 668 | EnableWindow(posTrackBar, false); |
| 669 | EnableWindow(speedEdit, false); |
george82 | e0a28ab | 2005-02-19 06:54:47 +0000 | [diff] [blame] | 670 | EnableWindow(speedUpDown, false); |
george82 | a21d295 | 2005-02-12 11:30:03 +0000 | [diff] [blame] | 671 | } |
| 672 | |
george82 | f504316 | 2005-02-12 11:37:18 +0000 | [diff] [blame] | 673 | void RfbPlayer::enableTBandMenuItems() { |
| 674 | // Enable the menu items |
| 675 | EnableMenuItem(hMenu, ID_CLOSEFILE, MF_ENABLED | MF_BYCOMMAND); |
| 676 | EnableMenuItem(hMenu, ID_FULLSCREEN, MF_ENABLED | MF_BYCOMMAND); |
| 677 | EnableMenuItem(GetSubMenu(hMenu, 1), 1, MF_ENABLED | MF_BYPOSITION); |
| 678 | EnableMenuItem(hMenu, ID_PLAYPAUSE, MF_ENABLED | MF_BYCOMMAND); |
| 679 | EnableMenuItem(hMenu, ID_STOP, MF_ENABLED | MF_BYCOMMAND); |
| 680 | EnableMenuItem(hMenu, ID_GOTO, MF_ENABLED | MF_BYCOMMAND); |
| 681 | EnableMenuItem(hMenu, ID_LOOP, MF_ENABLED | MF_BYCOMMAND); |
| 682 | EnableMenuItem(hMenu, ID_COPYTOCLIPBOARD, MF_ENABLED | MF_BYCOMMAND); |
| 683 | EnableMenuItem(hMenu, ID_FRAMEEXTRACT, MF_ENABLED | MF_BYCOMMAND); |
| 684 | |
| 685 | // Enable the toolbar buttons and child controls |
| 686 | tb.enableButton(ID_PLAY, true); |
| 687 | tb.enableButton(ID_PAUSE, true); |
| 688 | tb.enableButton(ID_STOP, true); |
| 689 | tb.enableButton(ID_FULLSCREEN, true); |
| 690 | EnableWindow(posTrackBar, true); |
| 691 | EnableWindow(speedEdit, true); |
george82 | e0a28ab | 2005-02-19 06:54:47 +0000 | [diff] [blame] | 692 | EnableWindow(speedUpDown, true); |
george82 | f504316 | 2005-02-12 11:37:18 +0000 | [diff] [blame] | 693 | } |
| 694 | |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 695 | void RfbPlayer::setVisible(bool visible) { |
| 696 | ShowWindow(getMainHandle(), visible ? SW_SHOW : SW_HIDE); |
| 697 | if (visible) { |
| 698 | // When the window becomes visible, make it active |
| 699 | SetForegroundWindow(getMainHandle()); |
| 700 | SetActiveWindow(getMainHandle()); |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | void RfbPlayer::setTitle(const char *title) { |
| 705 | char _title[256]; |
| 706 | strcpy(_title, AppName); |
| 707 | strcat(_title, " - "); |
| 708 | strcat(_title, title); |
| 709 | SetWindowText(getMainHandle(), _title); |
| 710 | } |
| 711 | |
| 712 | void RfbPlayer::setFrameSize(int width, int height) { |
| 713 | // Calculate and set required size for main window |
| 714 | RECT r = {0, 0, width, height}; |
george82 | e1169a1 | 2005-02-19 13:54:38 +0000 | [diff] [blame] | 715 | AdjustWindowRectEx(&r, GetWindowLong(getFrameHandle(), GWL_STYLE), TRUE, |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 716 | GetWindowLong(getFrameHandle(), GWL_EXSTYLE)); |
| 717 | r.bottom += CTRL_BAR_HEIGHT; // Include RfbPlayr's controls area |
| 718 | AdjustWindowRect(&r, GetWindowLong(getMainHandle(), GWL_STYLE), FALSE); |
george82 | 2ff7a61 | 2005-02-19 17:05:24 +0000 | [diff] [blame] | 719 | int x = max(0, (GetSystemMetrics(SM_CXSCREEN) - (r.right - r.left)) / 2); |
| 720 | int y = max(0, (GetSystemMetrics(SM_CYSCREEN) - (r.bottom - r.top)) / 2); |
| 721 | SetWindowPos(getMainHandle(), 0, x, y, r.right-r.left, r.bottom-r.top, |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 722 | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER); |
| 723 | |
| 724 | // Enable/disable scrollbars as appropriate |
| 725 | calculateScrollBars(); |
| 726 | } |
| 727 | |
| 728 | void RfbPlayer::calculateScrollBars() { |
| 729 | // Calculate the required size of window |
| 730 | DWORD current_style = GetWindowLong(getFrameHandle(), GWL_STYLE); |
| 731 | DWORD style = current_style & ~(WS_VSCROLL | WS_HSCROLL); |
| 732 | DWORD old_style; |
| 733 | RECT r; |
| 734 | SetRect(&r, 0, 0, buffer->width(), buffer->height()); |
| 735 | AdjustWindowRectEx(&r, style, FALSE, GetWindowLong(getFrameHandle(), GWL_EXSTYLE)); |
| 736 | Rect reqd_size = Rect(r.left, r.top, r.right, r.bottom); |
| 737 | |
| 738 | // Work out whether scroll bars are required |
| 739 | do { |
| 740 | old_style = style; |
| 741 | |
| 742 | if (!(style & WS_HSCROLL) && (reqd_size.width() > window_size.width())) { |
| 743 | style |= WS_HSCROLL; |
| 744 | reqd_size.br.y += GetSystemMetrics(SM_CXHSCROLL); |
| 745 | } |
| 746 | if (!(style & WS_VSCROLL) && (reqd_size.height() > window_size.height())) { |
| 747 | style |= WS_VSCROLL; |
| 748 | reqd_size.br.x += GetSystemMetrics(SM_CXVSCROLL); |
| 749 | } |
| 750 | } while (style != old_style); |
| 751 | |
| 752 | // Tell Windows to update the window style & cached settings |
| 753 | if (style != current_style) { |
| 754 | SetWindowLong(getFrameHandle(), GWL_STYLE, style); |
| 755 | SetWindowPos(getFrameHandle(), NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); |
| 756 | } |
| 757 | |
| 758 | // Update the scroll settings |
| 759 | SCROLLINFO si; |
| 760 | if (style & WS_VSCROLL) { |
| 761 | si.cbSize = sizeof(si); |
| 762 | si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS; |
| 763 | si.nMin = 0; |
| 764 | si.nMax = buffer->height(); |
| 765 | si.nPage = buffer->height() - (reqd_size.height() - window_size.height()); |
| 766 | maxscrolloffset.y = max(0, si.nMax-si.nPage); |
| 767 | scrolloffset.y = min(maxscrolloffset.y, scrolloffset.y); |
| 768 | si.nPos = scrolloffset.y; |
| 769 | SetScrollInfo(getFrameHandle(), SB_VERT, &si, TRUE); |
| 770 | } |
| 771 | if (style & WS_HSCROLL) { |
| 772 | si.cbSize = sizeof(si); |
| 773 | si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS; |
| 774 | si.nMin = 0; |
| 775 | si.nMax = buffer->width(); |
| 776 | si.nPage = buffer->width() - (reqd_size.width() - window_size.width()); |
| 777 | maxscrolloffset.x = max(0, si.nMax-si.nPage); |
| 778 | scrolloffset.x = min(maxscrolloffset.x, scrolloffset.x); |
| 779 | si.nPos = scrolloffset.x; |
| 780 | SetScrollInfo(getFrameHandle(), SB_HORZ, &si, TRUE); |
| 781 | } |
george82 | a758a7a | 2005-03-15 16:34:57 +0000 | [diff] [blame] | 782 | |
| 783 | // Update the cached client size |
| 784 | GetClientRect(getFrameHandle(), &r); |
| 785 | client_size = Rect(r.left, r.top, r.right, r.bottom); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 786 | } |
| 787 | |
| 788 | bool RfbPlayer::setViewportOffset(const Point& tl) { |
| 789 | /* *** |
| 790 | Point np = Point(max(0, min(maxscrolloffset.x, tl.x)), |
| 791 | max(0, min(maxscrolloffset.y, tl.y))); |
| 792 | */ |
| 793 | Point np = Point(max(0, min(tl.x, buffer->width()-client_size.width())), |
| 794 | max(0, min(tl.y, buffer->height()-client_size.height()))); |
| 795 | Point delta = np.translate(scrolloffset.negate()); |
| 796 | if (!np.equals(scrolloffset)) { |
| 797 | scrolloffset = np; |
| 798 | ScrollWindowEx(getFrameHandle(), -delta.x, -delta.y, 0, 0, 0, 0, SW_INVALIDATE); |
| 799 | UpdateWindow(getFrameHandle()); |
| 800 | return true; |
| 801 | } |
| 802 | return false; |
| 803 | } |
| 804 | |
| 805 | void RfbPlayer::close(const char* reason) { |
| 806 | setVisible(false); |
| 807 | if (reason) { |
| 808 | vlog.info("closing - %s", reason); |
| 809 | MessageBox(NULL, TStr(reason), "RfbPlayer", MB_ICONINFORMATION | MB_OK); |
| 810 | } |
| 811 | SendMessage(getFrameHandle(), WM_CLOSE, 0, 0); |
| 812 | } |
| 813 | |
| 814 | void RfbPlayer::blankBuffer() { |
| 815 | fillRect(buffer->getRect(), 0); |
| 816 | } |
| 817 | |
| 818 | void RfbPlayer::rewind() { |
george82 | 23e0856 | 2005-01-31 15:16:42 +0000 | [diff] [blame] | 819 | bool paused = isPaused(); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 820 | blankBuffer(); |
| 821 | newSession(fileName); |
| 822 | skipHandshaking(); |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 823 | is->setSpeed(options.playbackSpeed); |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 824 | if (paused) is->pausePlayback(); |
| 825 | else is->resumePlayback(); |
george82 | 23e0856 | 2005-01-31 15:16:42 +0000 | [diff] [blame] | 826 | } |
| 827 | |
| 828 | void RfbPlayer::processMsg() { |
george82 | 0d2e19d | 2005-03-03 15:47:55 +0000 | [diff] [blame] | 829 | // Perform return if waitWhilePaused processed because |
| 830 | // rfbReader thread could receive the signal to close |
| 831 | if (waitWhilePaused()) return; |
| 832 | |
george82 | 23e0856 | 2005-01-31 15:16:42 +0000 | [diff] [blame] | 833 | static long update_time = GetTickCount(); |
| 834 | try { |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 835 | if ((!isSeeking()) && ((GetTickCount() - update_time) > 250) |
| 836 | && (!sliderDraging)) { |
george82 | 23e0856 | 2005-01-31 15:16:42 +0000 | [diff] [blame] | 837 | // Update pos in the toolbar 4 times in 1 second |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 838 | updatePos(getTimeOffset()); |
george82 | 23e0856 | 2005-01-31 15:16:42 +0000 | [diff] [blame] | 839 | update_time = GetTickCount(); |
| 840 | } |
| 841 | RfbProto::processMsg(); |
| 842 | } catch (rdr::Exception e) { |
| 843 | if (strcmp(e.str(), "[End Of File]") == 0) { |
| 844 | rewind(); |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 845 | setPaused(!options.loopPlayback); |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 846 | updatePos(getTimeOffset()); |
george82 | 9403bee | 2005-02-06 11:14:39 +0000 | [diff] [blame] | 847 | SendMessage(posTrackBar, TBM_SETPOS, TRUE, 0); |
george82 | 23e0856 | 2005-01-31 15:16:42 +0000 | [diff] [blame] | 848 | return; |
| 849 | } |
| 850 | // It's a special exception to perform backward seeking. |
| 851 | // We only rewind the stream and seek the offset |
| 852 | if (strcmp(e.str(), "[REWIND]") == 0) { |
george82 | 1e846ff | 2005-02-24 13:13:33 +0000 | [diff] [blame] | 853 | rewindFlag = true; |
george82 | b95503e | 2005-02-21 17:02:34 +0000 | [diff] [blame] | 854 | long seekOffset = max(getSeekOffset(), imageDataStartTime); |
george82 | 23e0856 | 2005-01-31 15:16:42 +0000 | [diff] [blame] | 855 | rewind(); |
george82 | 0d2e19d | 2005-03-03 15:47:55 +0000 | [diff] [blame] | 856 | if (!stopped) setPos(seekOffset); |
| 857 | else stopped = false; |
george82 | 3104aec | 2005-02-21 13:20:56 +0000 | [diff] [blame] | 858 | updatePos(seekOffset); |
george82 | 1e846ff | 2005-02-24 13:13:33 +0000 | [diff] [blame] | 859 | rewindFlag = false; |
george82 | 2c7634b | 2005-03-10 18:03:27 +0000 | [diff] [blame] | 860 | return; |
| 861 | } |
| 862 | // It's a special exception which is used to terminate the playback |
| 863 | if (strcmp(e.str(), "[TERMINATE]") == 0) { |
| 864 | sessionTerminateThread *terminate = new sessionTerminateThread(this); |
| 865 | terminate->start(); |
george82 | 23e0856 | 2005-01-31 15:16:42 +0000 | [diff] [blame] | 866 | } else { |
george82 | 0e980cc | 2005-03-10 18:18:34 +0000 | [diff] [blame] | 867 | // Show the exception message and close the session playback |
| 868 | is->pausePlayback(); |
| 869 | char message[256] = "\0"; |
| 870 | strcat(message, e.str()); |
| 871 | strcat(message, "\nMaybe you force wrong the pixel format for this session"); |
| 872 | MessageBox(getMainHandle(), message, e.type(), MB_OK | MB_ICONERROR); |
| 873 | sessionTerminateThread *terminate = new sessionTerminateThread(this); |
| 874 | terminate->start(); |
george82 | 23e0856 | 2005-01-31 15:16:42 +0000 | [diff] [blame] | 875 | return; |
| 876 | } |
| 877 | } |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 878 | } |
| 879 | |
| 880 | void RfbPlayer::serverInit() { |
| 881 | RfbProto::serverInit(); |
| 882 | |
george82 | b95503e | 2005-02-21 17:02:34 +0000 | [diff] [blame] | 883 | // Save the image data start time |
| 884 | imageDataStartTime = is->getTimeOffset(); |
| 885 | |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 886 | // Resize the backing buffer |
| 887 | buffer->setSize(cp.width, cp.height); |
| 888 | |
| 889 | // Check on the true colour mode |
| 890 | if (!(cp.pf()).trueColour) |
Peter Ã…strand | c81a652 | 2004-12-30 11:32:08 +0000 | [diff] [blame] | 891 | throw rdr::Exception("This version plays only true color session!"); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 892 | |
| 893 | // Set the session pixel format |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 894 | static long pixelFormat = PF_AUTO; |
| 895 | if (options.askPixelFormat) { |
| 896 | ChoosePixelFormatDialog choosePixelFormatDialog(pixelFormat); |
george82 | d9957b7 | 2005-03-11 14:22:14 +0000 | [diff] [blame] | 897 | if (choosePixelFormatDialog.showDialog(getMainHandle())) { |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 898 | pixelFormat = choosePixelFormatDialog.getPF(); |
george82 | 2c7634b | 2005-03-10 18:03:27 +0000 | [diff] [blame] | 899 | } else { |
| 900 | is->pausePlayback(); |
| 901 | throw rdr::Exception("[TERMINATE]"); |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 902 | } |
| 903 | } else { |
george82 | 0981b34 | 2005-03-19 11:19:00 +0000 | [diff] [blame] | 904 | pixelFormat = options.pixelFormatIndex; |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 905 | } |
george82 | 5caee41 | 2005-03-09 09:52:10 +0000 | [diff] [blame] | 906 | switch (pixelFormat) { |
| 907 | case PF_AUTO: |
george82 | 193d8e4 | 2005-02-20 16:47:01 +0000 | [diff] [blame] | 908 | break; |
george82 | 5caee41 | 2005-03-09 09:52:10 +0000 | [diff] [blame] | 909 | case PF_D8_RGB332: |
george82 | 193d8e4 | 2005-02-20 16:47:01 +0000 | [diff] [blame] | 910 | cp.setPF(PixelFormat(8,8,0,1,7,7,3,0,3,6)); |
| 911 | break; |
george82 | 5caee41 | 2005-03-09 09:52:10 +0000 | [diff] [blame] | 912 | case PF_D16_RGB655: |
george82 | 193d8e4 | 2005-02-20 16:47:01 +0000 | [diff] [blame] | 913 | cp.setPF(PixelFormat(16,16,0,1,63,31,31,0,6,11)); |
| 914 | break; |
george82 | 5caee41 | 2005-03-09 09:52:10 +0000 | [diff] [blame] | 915 | case PF_D24_RGB888: |
george82 | 193d8e4 | 2005-02-20 16:47:01 +0000 | [diff] [blame] | 916 | cp.setPF(PixelFormat(32,24,0,1,255,255,255,16,8,0)); |
| 917 | break; |
| 918 | default: |
| 919 | throw rdr::Exception("This color depth is not supported!"); |
| 920 | } |
| 921 | buffer->setPF(cp.pf()); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 922 | |
| 923 | // If the window is not maximised then resize it |
| 924 | if (!(GetWindowLong(getMainHandle(), GWL_STYLE) & WS_MAXIMIZE)) |
| 925 | setFrameSize(cp.width, cp.height); |
| 926 | |
| 927 | // Set the window title and show it |
| 928 | setTitle(cp.name()); |
george82 | 006f279 | 2005-02-05 07:40:47 +0000 | [diff] [blame] | 929 | |
george82 | d4d69e6 | 2005-02-05 09:23:18 +0000 | [diff] [blame] | 930 | // Calculate the full session time and update posTrackBar control |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 931 | sessionTimeMs = calculateSessionTime(fileName); |
| 932 | sprintf(fullSessionTime, "%.2um:%.2us", |
| 933 | sessionTimeMs / 1000 / 60, sessionTimeMs / 1000 % 60); |
george82 | d4d69e6 | 2005-02-05 09:23:18 +0000 | [diff] [blame] | 934 | SendMessage(posTrackBar, TBM_SETRANGE, |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 935 | TRUE, MAKELONG(0, min(sessionTimeMs / 1000, MAX_POS_TRACKBAR_RANGE))); |
| 936 | sliderStepMs = sessionTimeMs / SendMessage(posTrackBar, TBM_GETRANGEMAX, 0, 0); |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 937 | updatePos(getTimeOffset()); |
george82 | d4d69e6 | 2005-02-05 09:23:18 +0000 | [diff] [blame] | 938 | |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 939 | setPaused(!options.autoPlay); |
| 940 | // Restore the parameters from registry, |
| 941 | // which was replaced by command-line parameters. |
| 942 | options.readFromRegistry(); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 943 | } |
| 944 | |
| 945 | void RfbPlayer::setColourMapEntries(int first, int count, U16* rgbs) { |
| 946 | vlog.debug("setColourMapEntries: first=%d, count=%d", first, count); |
| 947 | throw rdr::Exception("Can't handle SetColourMapEntries message", "RfbPlayer"); |
| 948 | /* int i; |
| 949 | for (i=0;i<count;i++) { |
| 950 | buffer->setColour(i+first, rgbs[i*3], rgbs[i*3+1], rgbs[i*3+2]); |
| 951 | } |
| 952 | // *** change to 0, 256? |
| 953 | refreshWindowPalette(first, count); |
| 954 | palette_changed = true; |
| 955 | InvalidateRect(getFrameHandle(), 0, FALSE);*/ |
| 956 | } |
| 957 | |
| 958 | void RfbPlayer::bell() { |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 959 | if (options.acceptBell) |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 960 | MessageBeep(-1); |
| 961 | } |
| 962 | |
| 963 | void RfbPlayer::serverCutText(const char* str, int len) { |
| 964 | if (cutText != NULL) |
| 965 | delete [] cutText; |
| 966 | cutText = new char[len + 1]; |
| 967 | memcpy(cutText, str, len); |
| 968 | cutText[len] = '\0'; |
| 969 | } |
| 970 | |
| 971 | void RfbPlayer::frameBufferUpdateEnd() { |
| 972 | }; |
| 973 | |
| 974 | void RfbPlayer::beginRect(const Rect& r, unsigned int encoding) { |
| 975 | } |
| 976 | |
| 977 | void RfbPlayer::endRect(const Rect& r, unsigned int encoding) { |
| 978 | } |
| 979 | |
| 980 | |
| 981 | void RfbPlayer::fillRect(const Rect& r, Pixel pix) { |
| 982 | buffer->fillRect(r, pix); |
| 983 | invalidateBufferRect(r); |
| 984 | } |
| 985 | |
| 986 | void RfbPlayer::imageRect(const Rect& r, void* pixels) { |
| 987 | buffer->imageRect(r, pixels); |
| 988 | invalidateBufferRect(r); |
| 989 | } |
| 990 | |
| 991 | void RfbPlayer::copyRect(const Rect& r, int srcX, int srcY) { |
| 992 | buffer->copyRect(r, Point(r.tl.x-srcX, r.tl.y-srcY)); |
| 993 | invalidateBufferRect(r); |
| 994 | } |
| 995 | |
| 996 | bool RfbPlayer::invalidateBufferRect(const Rect& crect) { |
| 997 | Rect rect = bufferToClient(crect); |
| 998 | if (rect.intersect(client_size).is_empty()) return false; |
| 999 | RECT invalid = {rect.tl.x, rect.tl.y, rect.br.x, rect.br.y}; |
| 1000 | InvalidateRect(getFrameHandle(), &invalid, FALSE); |
| 1001 | return true; |
| 1002 | } |
| 1003 | |
george82 | 0d2e19d | 2005-03-03 15:47:55 +0000 | [diff] [blame] | 1004 | bool RfbPlayer::waitWhilePaused() { |
| 1005 | bool result = false; |
| 1006 | while(isPaused() && !isSeeking()) { |
| 1007 | Sleep(20); |
| 1008 | result = true; |
| 1009 | } |
| 1010 | return result; |
| 1011 | } |
| 1012 | |
george82 | 57f1352 | 2005-02-05 08:48:22 +0000 | [diff] [blame] | 1013 | long RfbPlayer::calculateSessionTime(char *filename) { |
| 1014 | FbsInputStream sessionFile(filename); |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 1015 | sessionFile.setTimeOffset(100000000); |
george82 | 57f1352 | 2005-02-05 08:48:22 +0000 | [diff] [blame] | 1016 | try { |
| 1017 | while (TRUE) { |
| 1018 | sessionFile.skip(1024); |
| 1019 | } |
| 1020 | } catch (rdr::Exception e) { |
| 1021 | if (strcmp(e.str(), "[End Of File]") == 0) { |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 1022 | return sessionFile.getTimeOffset(); |
george82 | 57f1352 | 2005-02-05 08:48:22 +0000 | [diff] [blame] | 1023 | } else { |
| 1024 | MessageBox(getMainHandle(), e.str(), e.type(), MB_OK | MB_ICONERROR); |
| 1025 | return 0; |
| 1026 | } |
| 1027 | } |
| 1028 | return 0; |
| 1029 | } |
| 1030 | |
george82 | 6b87aff | 2005-02-13 10:48:21 +0000 | [diff] [blame] | 1031 | void RfbPlayer::closeSessionFile() { |
| 1032 | char speedStr[10]; |
george82 | 0bdb284 | 2005-02-19 13:17:58 +0000 | [diff] [blame] | 1033 | DWORD dwStyle; |
george82 | 6b87aff | 2005-02-13 10:48:21 +0000 | [diff] [blame] | 1034 | RECT r; |
| 1035 | |
| 1036 | // Uncheck all toolbar buttons |
| 1037 | if (tb.getHandle()) { |
| 1038 | tb.checkButton(ID_PLAY, false); |
| 1039 | tb.checkButton(ID_PAUSE, false); |
| 1040 | tb.checkButton(ID_STOP, false); |
| 1041 | } |
| 1042 | |
| 1043 | // Stop playback and update the player state |
| 1044 | disableTBandMenuItems(); |
| 1045 | if (rfbReader) { |
| 1046 | delete rfbReader->join(); |
| 1047 | rfbReader = 0; |
| 1048 | delete [] fileName; |
| 1049 | fileName = 0; |
| 1050 | } |
| 1051 | blankBuffer(); |
| 1052 | setTitle("None"); |
george82 | 7009c89 | 2005-02-19 12:49:42 +0000 | [diff] [blame] | 1053 | SetWindowText(timeStatic,"00m:00s (00m:00s)"); |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 1054 | options.playbackSpeed = 1.0; |
george82 | 6b87aff | 2005-02-13 10:48:21 +0000 | [diff] [blame] | 1055 | SendMessage(speedUpDown, UDM_SETPOS, |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 1056 | 0, MAKELONG((short)(options.playbackSpeed / 0.5), 0)); |
| 1057 | sprintf(speedStr, "%.2f", options.playbackSpeed); |
george82 | 6b87aff | 2005-02-13 10:48:21 +0000 | [diff] [blame] | 1058 | SetWindowText(speedEdit, speedStr); |
| 1059 | SendMessage(posTrackBar, TBM_SETRANGE, TRUE, MAKELONG(0, 0)); |
| 1060 | |
| 1061 | // Change the player window size and frame size to default |
george82 | 0bdb284 | 2005-02-19 13:17:58 +0000 | [diff] [blame] | 1062 | if ((dwStyle = GetWindowLong(getMainHandle(), GWL_STYLE)) & WS_MAXIMIZE) { |
| 1063 | dwStyle &= ~WS_MAXIMIZE; |
| 1064 | SetWindowLong(getMainHandle(), GWL_STYLE, dwStyle); |
| 1065 | } |
george82 | 2ff7a61 | 2005-02-19 17:05:24 +0000 | [diff] [blame] | 1066 | int x = max(0, (GetSystemMetrics(SM_CXSCREEN) - DEFAULT_PLAYER_WIDTH) / 2); |
| 1067 | int y = max(0, (GetSystemMetrics(SM_CYSCREEN) - DEFAULT_PLAYER_HEIGHT) / 2); |
| 1068 | SetWindowPos(getMainHandle(), 0, x, y, |
george82 | 6b87aff | 2005-02-13 10:48:21 +0000 | [diff] [blame] | 1069 | DEFAULT_PLAYER_WIDTH, DEFAULT_PLAYER_HEIGHT, |
george82 | 2ff7a61 | 2005-02-19 17:05:24 +0000 | [diff] [blame] | 1070 | SWP_NOZORDER | SWP_FRAMECHANGED); |
george82 | 6b87aff | 2005-02-13 10:48:21 +0000 | [diff] [blame] | 1071 | buffer->setSize(32, 32); |
| 1072 | calculateScrollBars(); |
| 1073 | |
| 1074 | // Update the cached sizing information and repaint the frame window |
| 1075 | GetWindowRect(getFrameHandle(), &r); |
| 1076 | window_size = Rect(r.left, r.top, r.right, r.bottom); |
| 1077 | GetClientRect(getFrameHandle(), &r); |
| 1078 | client_size = Rect(r.left, r.top, r.right, r.bottom); |
| 1079 | InvalidateRect(getFrameHandle(), 0, TRUE); |
| 1080 | UpdateWindow(getFrameHandle()); |
| 1081 | } |
| 1082 | |
george82 | 17e92cb | 2005-01-31 16:01:02 +0000 | [diff] [blame] | 1083 | void RfbPlayer::openSessionFile(char *_fileName) { |
| 1084 | fileName = strDup(_fileName); |
| 1085 | |
| 1086 | // Close the previous reading thread |
| 1087 | if (rfbReader) { |
george82 | 17e92cb | 2005-01-31 16:01:02 +0000 | [diff] [blame] | 1088 | delete rfbReader->join(); |
george82 | b4f969b | 2005-02-09 16:34:51 +0000 | [diff] [blame] | 1089 | rfbReader = 0; |
george82 | 17e92cb | 2005-01-31 16:01:02 +0000 | [diff] [blame] | 1090 | } |
| 1091 | blankBuffer(); |
| 1092 | newSession(fileName); |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 1093 | setSpeed(options.playbackSpeed); |
george82 | 17e92cb | 2005-01-31 16:01:02 +0000 | [diff] [blame] | 1094 | rfbReader = new rfbSessionReader(this); |
| 1095 | rfbReader->start(); |
george82 | 6e51fcc | 2005-02-06 13:30:49 +0000 | [diff] [blame] | 1096 | SendMessage(posTrackBar, TBM_SETPOS, TRUE, 0); |
george82 | 63ebbcc | 2005-02-12 12:09:13 +0000 | [diff] [blame] | 1097 | enableTBandMenuItems(); |
george82 | 17e92cb | 2005-01-31 16:01:02 +0000 | [diff] [blame] | 1098 | } |
| 1099 | |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1100 | void RfbPlayer::setPaused(bool paused) { |
| 1101 | if (paused) { |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1102 | is->pausePlayback(); |
george82 | 006f279 | 2005-02-05 07:40:47 +0000 | [diff] [blame] | 1103 | tb.checkButton(ID_PAUSE, true); |
| 1104 | tb.checkButton(ID_PLAY, false); |
| 1105 | tb.checkButton(ID_STOP, false); |
| 1106 | CheckMenuItem(hMenu, ID_PLAYPAUSE, MF_CHECKED); |
| 1107 | CheckMenuItem(hMenu, ID_STOP, MF_UNCHECKED); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1108 | } else { |
george82 | 5beb62a | 2005-02-09 13:04:32 +0000 | [diff] [blame] | 1109 | if (is) is->resumePlayback(); |
george82 | 006f279 | 2005-02-05 07:40:47 +0000 | [diff] [blame] | 1110 | tb.checkButton(ID_PLAY, true); |
| 1111 | tb.checkButton(ID_STOP, false); |
| 1112 | tb.checkButton(ID_PAUSE, false); |
| 1113 | CheckMenuItem(hMenu, ID_PLAYPAUSE, MF_CHECKED); |
| 1114 | CheckMenuItem(hMenu, ID_STOP, MF_UNCHECKED); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1115 | } |
| 1116 | } |
| 1117 | |
george82 | 006f279 | 2005-02-05 07:40:47 +0000 | [diff] [blame] | 1118 | void RfbPlayer::stopPlayback() { |
george82 | 0d2e19d | 2005-03-03 15:47:55 +0000 | [diff] [blame] | 1119 | stopped = true; |
george82 | 0d2e19d | 2005-03-03 15:47:55 +0000 | [diff] [blame] | 1120 | setPos(0); |
george82 | 8edfb7a | 2005-03-03 16:36:10 +0000 | [diff] [blame] | 1121 | if (is) { |
| 1122 | is->pausePlayback(); |
| 1123 | is->interruptFrameDelay(); |
| 1124 | } |
george82 | 006f279 | 2005-02-05 07:40:47 +0000 | [diff] [blame] | 1125 | tb.checkButton(ID_STOP, true); |
| 1126 | tb.checkButton(ID_PLAY, false); |
| 1127 | tb.checkButton(ID_PAUSE, false); |
| 1128 | CheckMenuItem(hMenu, ID_STOP, MF_CHECKED); |
| 1129 | CheckMenuItem(hMenu, ID_PLAYPAUSE, MF_UNCHECKED); |
george82 | 6da02d7 | 2005-02-06 17:02:34 +0000 | [diff] [blame] | 1130 | SendMessage(posTrackBar, TBM_SETPOS, TRUE, 0); |
george82 | 006f279 | 2005-02-05 07:40:47 +0000 | [diff] [blame] | 1131 | } |
| 1132 | |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1133 | void RfbPlayer::setSpeed(double speed) { |
george82 | 5f326fe | 2005-02-20 08:01:01 +0000 | [diff] [blame] | 1134 | if (speed > 0) { |
| 1135 | char speedStr[20] = "\0"; |
| 1136 | double newSpeed = min(speed, MAX_SPEED); |
george82 | 5f326fe | 2005-02-20 08:01:01 +0000 | [diff] [blame] | 1137 | is->setSpeed(newSpeed); |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 1138 | options.playbackSpeed = newSpeed; |
george82 | 5f326fe | 2005-02-20 08:01:01 +0000 | [diff] [blame] | 1139 | SendMessage(speedUpDown, UDM_SETPOS, |
| 1140 | 0, MAKELONG((short)(newSpeed / 0.5), 0)); |
| 1141 | sprintf(speedStr, "%.2f", newSpeed); |
| 1142 | SetWindowText(speedEdit, speedStr); |
| 1143 | } |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1144 | } |
| 1145 | |
| 1146 | double RfbPlayer::getSpeed() { |
| 1147 | return is->getSpeed(); |
| 1148 | } |
| 1149 | |
| 1150 | void RfbPlayer::setPos(long pos) { |
george82 | b95503e | 2005-02-21 17:02:34 +0000 | [diff] [blame] | 1151 | is->setTimeOffset(max(pos, imageDataStartTime)); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1152 | } |
| 1153 | |
| 1154 | long RfbPlayer::getSeekOffset() { |
| 1155 | return is->getSeekOffset(); |
| 1156 | } |
| 1157 | |
| 1158 | bool RfbPlayer::isSeeking() { |
george82 | 5beb62a | 2005-02-09 13:04:32 +0000 | [diff] [blame] | 1159 | if (is) return is->isSeeking(); |
| 1160 | else return false; |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1161 | } |
| 1162 | |
| 1163 | bool RfbPlayer::isSeekMode() { |
| 1164 | return seekMode; |
| 1165 | } |
| 1166 | |
| 1167 | bool RfbPlayer::isPaused() { |
| 1168 | return is->isPaused(); |
| 1169 | } |
| 1170 | |
| 1171 | long RfbPlayer::getTimeOffset() { |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 1172 | return max(is->getTimeOffset(), is->getSeekOffset()); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1173 | } |
| 1174 | |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 1175 | void RfbPlayer::updatePos(long newPos) { |
| 1176 | // Update time pos in static control |
george82 | 3c8fbbf | 2005-01-24 11:09:08 +0000 | [diff] [blame] | 1177 | char timePos[30] = "\0"; |
george82 | 5457d41 | 2005-02-19 06:43:09 +0000 | [diff] [blame] | 1178 | long time = newPos / 1000; |
| 1179 | sprintf(timePos, "%.2um:%.2us (%s)", time/60, time%60, fullSessionTime); |
george82 | 3c8fbbf | 2005-01-24 11:09:08 +0000 | [diff] [blame] | 1180 | SetWindowText(timeStatic, timePos); |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 1181 | |
| 1182 | // Update the position of slider |
| 1183 | if (!sliderDraging) { |
george82 | 5457d41 | 2005-02-19 06:43:09 +0000 | [diff] [blame] | 1184 | double error = SendMessage(posTrackBar, TBM_GETPOS, 0, 0) * |
| 1185 | sliderStepMs / double(newPos); |
| 1186 | if (!((error > 1 - CALCULATION_ERROR) && (error <= 1 + CALCULATION_ERROR))) { |
| 1187 | SendMessage(posTrackBar, TBM_SETPOS, TRUE, newPos / sliderStepMs); |
| 1188 | } |
george82 | 8a47148 | 2005-02-06 07:15:53 +0000 | [diff] [blame] | 1189 | } |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1190 | } |
| 1191 | |
| 1192 | void RfbPlayer::skipHandshaking() { |
| 1193 | int skipBytes = 12 + 4 + 24 + strlen(cp.name()); |
| 1194 | is->skip(skipBytes); |
| 1195 | state_ = RFBSTATE_NORMAL; |
| 1196 | } |
| 1197 | |
| 1198 | void programInfo() { |
| 1199 | win32::FileVersionInfo inf; |
| 1200 | _tprintf(_T("%s - %s, Version %s\n"), |
| 1201 | inf.getVerString(_T("ProductName")), |
| 1202 | inf.getVerString(_T("FileDescription")), |
| 1203 | inf.getVerString(_T("FileVersion"))); |
| 1204 | printf("%s\n", buildTime); |
| 1205 | _tprintf(_T("%s\n\n"), inf.getVerString(_T("LegalCopyright"))); |
| 1206 | } |
| 1207 | |
| 1208 | void programUsage() { |
george82 | e6883de | 2005-02-08 14:42:12 +0000 | [diff] [blame] | 1209 | MessageBox(0, usage_msg, "RfbPlayer", MB_OK | MB_ICONINFORMATION); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1210 | } |
| 1211 | |
george82 | 5beb62a | 2005-02-09 13:04:32 +0000 | [diff] [blame] | 1212 | char *fileName = 0; |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 1213 | |
| 1214 | // playerOptions is the player options with default parameters values, |
| 1215 | // it is used only for run the player with command-line parameters |
| 1216 | PlayerOptions playerOptions; |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1217 | bool print_usage = false; |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1218 | |
| 1219 | bool processParams(int argc, char* argv[]) { |
| 1220 | for (int i = 1; i < argc; i++) { |
| 1221 | if ((strcasecmp(argv[i], "-help") == 0) || |
| 1222 | (strcasecmp(argv[i], "--help") == 0) || |
| 1223 | (strcasecmp(argv[i], "/help") == 0) || |
| 1224 | (strcasecmp(argv[i], "-h") == 0) || |
| 1225 | (strcasecmp(argv[i], "/h") == 0) || |
george82 | e6883de | 2005-02-08 14:42:12 +0000 | [diff] [blame] | 1226 | (strcasecmp(argv[i], "/?") == 0) || |
| 1227 | (strcasecmp(argv[i], "-?") == 0)) { |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1228 | print_usage = true; |
| 1229 | return true; |
| 1230 | } |
| 1231 | |
george82 | 5caee41 | 2005-03-09 09:52:10 +0000 | [diff] [blame] | 1232 | if ((strcasecmp(argv[i], "-pf") == 0) || |
| 1233 | (strcasecmp(argv[i], "/pf") == 0) && (i < argc-1)) { |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 1234 | long pf = atoi(argv[++i]); |
george82 | 5caee41 | 2005-03-09 09:52:10 +0000 | [diff] [blame] | 1235 | if ((pf < 0) || (pf > PF_MODES)) { |
george82 | 193d8e4 | 2005-02-20 16:47:01 +0000 | [diff] [blame] | 1236 | return false; |
| 1237 | } |
george82 | 0981b34 | 2005-03-19 11:19:00 +0000 | [diff] [blame] | 1238 | playerOptions.pixelFormatIndex = pf; |
george82 | 193d8e4 | 2005-02-20 16:47:01 +0000 | [diff] [blame] | 1239 | continue; |
| 1240 | } |
| 1241 | |
| 1242 | |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1243 | if ((strcasecmp(argv[i], "-speed") == 0) || |
| 1244 | (strcasecmp(argv[i], "/speed") == 0) && (i < argc-1)) { |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 1245 | double playbackSpeed = atof(argv[++i]); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1246 | if (playbackSpeed <= 0) { |
| 1247 | return false; |
| 1248 | } |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 1249 | playerOptions.playbackSpeed = playbackSpeed; |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1250 | continue; |
| 1251 | } |
| 1252 | |
| 1253 | if ((strcasecmp(argv[i], "-pos") == 0) || |
| 1254 | (strcasecmp(argv[i], "/pos") == 0) && (i < argc-1)) { |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 1255 | long initTime = atol(argv[++i]); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1256 | if (initTime <= 0) |
| 1257 | return false; |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 1258 | playerOptions.initTime = initTime; |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1259 | continue; |
| 1260 | } |
| 1261 | |
| 1262 | if ((strcasecmp(argv[i], "-autoplay") == 0) || |
| 1263 | (strcasecmp(argv[i], "/autoplay") == 0) && (i < argc-1)) { |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 1264 | playerOptions.autoPlay = true; |
george82 | e6883de | 2005-02-08 14:42:12 +0000 | [diff] [blame] | 1265 | continue; |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1266 | } |
| 1267 | |
| 1268 | if (i != argc - 1) |
| 1269 | return false; |
| 1270 | } |
| 1271 | |
| 1272 | fileName = strDup(argv[argc-1]); |
| 1273 | return true; |
| 1274 | } |
| 1275 | |
| 1276 | // |
| 1277 | // -=- WinMain |
| 1278 | // |
| 1279 | |
| 1280 | int WINAPI WinMain(HINSTANCE inst, HINSTANCE prevInst, char* cmdLine, int cmdShow) { |
| 1281 | |
| 1282 | // - Process the command-line |
| 1283 | |
| 1284 | int argc = __argc; |
| 1285 | char** argv = __argv; |
george82 | e6883de | 2005-02-08 14:42:12 +0000 | [diff] [blame] | 1286 | if ((argc > 1) && (!processParams(argc, argv))) { |
| 1287 | MessageBox(0, wrong_cmd_msg, "RfbPlayer", MB_OK | MB_ICONWARNING); |
| 1288 | return 0; |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1289 | } |
george82 | e6883de | 2005-02-08 14:42:12 +0000 | [diff] [blame] | 1290 | |
| 1291 | if (print_usage) { |
| 1292 | programUsage(); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1293 | return 0; |
george82 | 67cbcd0 | 2005-01-16 15:39:56 +0000 | [diff] [blame] | 1294 | } |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1295 | |
george82 | e6883de | 2005-02-08 14:42:12 +0000 | [diff] [blame] | 1296 | // Create the player |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1297 | RfbPlayer *player = NULL; |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1298 | try { |
george82 | 5e7af74 | 2005-03-10 14:26:00 +0000 | [diff] [blame] | 1299 | player = new RfbPlayer(fileName, &playerOptions); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1300 | } catch (rdr::Exception e) { |
| 1301 | MessageBox(NULL, e.str(), e.type(), MB_OK | MB_ICONERROR); |
| 1302 | delete player; |
| 1303 | return 0; |
| 1304 | } |
| 1305 | |
| 1306 | // Run the player |
george82 | 5bbd61b | 2004-12-09 17:47:37 +0000 | [diff] [blame] | 1307 | HACCEL hAccel = LoadAccelerators(inst, MAKEINTRESOURCE(IDR_ACCELERATOR)); |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1308 | MSG msg; |
| 1309 | while (GetMessage(&msg, NULL, 0, 0) > 0) { |
george82 | 5bbd61b | 2004-12-09 17:47:37 +0000 | [diff] [blame] | 1310 | if(!TranslateAccelerator(player->getMainHandle(), hAccel, &msg)) { |
| 1311 | TranslateMessage(&msg); |
| 1312 | DispatchMessage(&msg); |
| 1313 | } |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1314 | } |
| 1315 | |
george82 | e6883de | 2005-02-08 14:42:12 +0000 | [diff] [blame] | 1316 | // Destroy the player |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1317 | try{ |
Constantin Kaplinsky | fbfbb92 | 2004-11-14 18:28:51 +0000 | [diff] [blame] | 1318 | if (player) delete player; |
| 1319 | } catch (rdr::Exception e) { |
| 1320 | MessageBox(NULL, e.str(), e.type(), MB_OK | MB_ICONERROR); |
| 1321 | } |
| 1322 | |
| 1323 | return 0; |
| 1324 | }; |