Added possibility to show/hide the toolbar over the system menu.
Added the system menu point "Show toolbar".


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@417 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/vncviewer/ViewerToolBar.cxx b/vncviewer/ViewerToolBar.cxx
index 9846262..543acea 100644
--- a/vncviewer/ViewerToolBar.cxx
+++ b/vncviewer/ViewerToolBar.cxx
@@ -23,7 +23,7 @@
 
 void ViewerToolBar::create(HWND parentHwnd) {
   // Create the toolbar panel
-  ToolBar::create(ID_TOOLBAR, parentHwnd, WS_CHILD | WS_VISIBLE | 
+  ToolBar::create(ID_TOOLBAR, parentHwnd, WS_CHILD | 
     TBSTYLE_FLAT | CCS_NORESIZE);
   addBitmap(4, IDB_TOOLBAR);
 
diff --git a/vncviewer/cview.cxx b/vncviewer/cview.cxx
index 66dd501..413d1a7 100644
--- a/vncviewer/cview.cxx
+++ b/vncviewer/cview.cxx
@@ -222,7 +222,7 @@
     hwnd(0), frameHwnd(0), requestUpdate(false), has_focus(false), 
     palette_changed(false), sameMachine(false), encodingChange(false), 
     formatChange(false), lastUsedEncoding_(encodingRaw), fullScreenActive(false),
-    bumpScroll(false), manager(0) {
+    bumpScroll(false), manager(0), toolbar(true) {
 
   // Create the main window
   const TCHAR* name = _T("VNC Viewer 4.0b");
@@ -263,6 +263,9 @@
 
   // Create the backing buffer
   buffer = new win32::DIBSectionBuffer(getFrameHandle());
+  
+  // Show the toolbar if needed
+  if (toolbar) tb.show();
 }
 
 CView::~CView() {
@@ -282,6 +285,8 @@
   HMENU wndmenu = GetSystemMenu(hwnd, FALSE);
   AppendMenu(wndmenu, MF_SEPARATOR, 0, 0);
   AppendMenu(wndmenu, MF_STRING, IDM_FULLSCREEN, _T("&Full screen"));
+  AppendMenu(wndmenu, (toolbar ? MF_STRING | MF_CHECKED : MF_STRING), 
+    IDM_SHOW_TOOLBAR, _T("Show tool&bar"));
   AppendMenu(wndmenu, MF_SEPARATOR, 0, 0);
   AppendMenu(wndmenu, MF_STRING, IDM_CTRL_KEY, _T("Ctr&l"));
   AppendMenu(wndmenu, MF_STRING, IDM_ALT_KEY, _T("Al&t"));
@@ -400,6 +405,11 @@
   CheckMenuItem(GetSystemMenu(getHandle(), FALSE), IDM_FULLSCREEN,
     (options.fullScreen ? MF_CHECKED : 0) | MF_BYCOMMAND);
 
+  // If the fullscreen mode is active then disable the menu point 
+  // "Show toolbar", otherwise enable the menu point.
+  EnableMenuItem(GetSystemMenu(getHandle(), FALSE), IDM_SHOW_TOOLBAR,
+    (options.fullScreen ? MF_GRAYED : MF_ENABLED) | MF_BYCOMMAND);
+
   // If the window is not visible then we ignore the request.
   // setVisible() will call us to correct the full-screen state when
   // the window is visible, to keep things consistent.
@@ -427,7 +437,7 @@
     flags = flags & ~(WS_CAPTION | WS_THICKFRAME | WS_MAXIMIZE | WS_MINIMIZE);
     vlog.debug("flags=%x", flags);
 
-    tb.hide();
+    if (toolbar) tb.hide();
     SetWindowLong(getFrameHandle(), GWL_EXSTYLE, 0);
     SetWindowLong(getHandle(), GWL_STYLE, flags);
     SetWindowPos(getHandle(), HWND_TOP, mi.rcMonitor.left, mi.rcMonitor.top,
@@ -438,7 +448,7 @@
     fullScreenActive = bumpScroll = false;
 
     // Set the window non-fullscreen
-    tb.show();
+    if (toolbar) tb.show();
     SetWindowLong(getFrameHandle(), GWL_EXSTYLE, WS_EX_CLIENTEDGE);
     SetWindowLong(getHandle(), GWL_STYLE, fullScreenOldFlags);
     SetWindowPos(getHandle(), HWND_NOTOPMOST,
@@ -640,6 +650,13 @@
       options.fullScreen = !options.fullScreen;
       setFullscreen(options.fullScreen);
       return 0;
+    case IDM_SHOW_TOOLBAR:
+      toolbar = !toolbar;
+      CheckMenuItem(GetSystemMenu(getHandle(), FALSE), IDM_SHOW_TOOLBAR,
+        (toolbar ? MF_CHECKED : MF_UNCHECKED) | MF_BYCOMMAND);
+      if (toolbar) tb.show();
+      else tb.hide();
+      return 0;
     case IDM_CTRL_KEY:
       writeKeyEvent(VK_CONTROL, 0, !kbd.keyPressed(VK_CONTROL));
       return 0;
diff --git a/vncviewer/cview.h b/vncviewer/cview.h
index d0b3268..0dc0066 100644
--- a/vncviewer/cview.h
+++ b/vncviewer/cview.h
@@ -283,6 +283,7 @@
 
       // ToolBar handling
       ViewerToolBar tb;
+      bool toolbar;
 
       // Local window state
       win32::DIBSectionBuffer* buffer;
diff --git a/vncviewer/resource.h b/vncviewer/resource.h
index 66a4a75..3dfe8e5 100644
--- a/vncviewer/resource.h
+++ b/vncviewer/resource.h
@@ -127,13 +127,14 @@
 #define IDM_FTDELETE                    40024
 #define IDM_FTCANCEL                    40025
 #define IDM_FTCREATEFOLDER              40026
+#define IDM_SHOW_TOOLBAR                40027
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        131
-#define _APS_NEXT_COMMAND_VALUE         40027
+#define _APS_NEXT_COMMAND_VALUE         40028
 #define _APS_NEXT_CONTROL_VALUE         1083
 #define _APS_NEXT_SYMED_VALUE           101
 #endif