summaryrefslogtreecommitdiffstats
path: root/vncviewer/ConnectingDialog.h
diff options
context:
space:
mode:
authorConstantin Kaplinsky <const@tightvnc.com>2004-10-08 09:43:57 +0000
committerConstantin Kaplinsky <const@tightvnc.com>2004-10-08 09:43:57 +0000
commit47ed8d321c32c6b741cff1f4ff686165c4f269f4 (patch)
treeda413648adbff4ff10c8ee26124673f8e7cf238a /vncviewer/ConnectingDialog.h
parent266bb36cd47555280fffd3aab1ed86683e26d748 (diff)
downloadtigervnc-47ed8d321c32c6b741cff1f4ff686165c4f269f4.tar.gz
tigervnc-47ed8d321c32c6b741cff1f4ff686165c4f269f4.zip
Initial revision
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'vncviewer/ConnectingDialog.h')
-rw-r--r--vncviewer/ConnectingDialog.h95
1 files changed, 95 insertions, 0 deletions
diff --git a/vncviewer/ConnectingDialog.h b/vncviewer/ConnectingDialog.h
new file mode 100644
index 00000000..b146ced6
--- /dev/null
+++ b/vncviewer/ConnectingDialog.h
@@ -0,0 +1,95 @@
+/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
+ *
+ * This 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 software 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 software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+// -=- ConnectingDialog.h
+
+// Dialog to indicate to the user that the viewer is attempting to make an
+// outgoing connection.
+
+#ifndef __RFB_WIN32_CONNECTING_DLG_H__
+#define __RFB_WIN32_CONNECTING_DLG_H__
+
+#include <rfb_win32/Dialog.h>
+#include <rfb/Threading.h>
+#include <vncviewer/resource.h>
+
+namespace rfb {
+
+ namespace win32 {
+
+ BOOL CALLBACK ConnectingDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) {
+ switch (uMsg) {
+ case WM_INITDIALOG:
+ {
+ SetWindowLong(hwnd, GWL_USERDATA, lParam);
+ return TRUE;
+ }
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDCANCEL:
+ network::Socket* sock = (network::Socket*) GetWindowLong(hwnd, GWL_USERDATA);
+ sock->shutdown();
+ EndDialog(hwnd, FALSE);
+ return TRUE;
+ }
+ break;
+ case WM_DESTROY:
+ EndDialog(hwnd, TRUE);
+ return TRUE;
+ }
+ return 0;
+ }
+
+ // *** hacky bit - should use async connect so dialog behaves properly
+ class ConnectingDialog : public Thread {
+ public:
+ ConnectingDialog() : Thread("ConnectingDialog") {
+ dialog = 0;
+ active = true;
+ start();
+ }
+ virtual ~ConnectingDialog() {
+ // *** join() required here because otherwise ~Thread calls Thread::join()
+ join();
+ }
+ virtual void run() {
+ dialog = CreateDialogParam(GetModuleHandle(0),
+ MAKEINTRESOURCE(IDD_CONNECTING_DLG), 0, &ConnectingDlgProc, 0);
+ ShowWindow(dialog, SW_SHOW);
+ MSG msg;
+ while (active && GetMessage(&msg, dialog, 0, 0)) {
+ DispatchMessage(&msg);
+ }
+ DestroyWindow(dialog);
+ }
+ virtual Thread* join() {
+ active = false;
+ if (dialog)
+ PostMessage(dialog, WM_QUIT, 0, 0);
+ return Thread::join();
+ }
+ protected:
+ HWND dialog;
+ bool active;
+ };
+
+ };
+
+};
+
+#endif \ No newline at end of file