]> source.dussan.org Git - tigervnc.git/commitdiff
Added button images operations to the ToolBar class:
authorgeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Tue, 11 Jan 2005 14:47:14 +0000 (14:47 +0000)
committergeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Tue, 11 Jan 2005 14:47:14 +0000 (14:47 +0000)
addBitmap(), addSysBitmap(), setBitmapSize().

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@92 3789f03b-4d11-0410-bbf8-ca57d06f2519

rfbplayer/ToolBar.cxx
rfbplayer/ToolBar.h

index b9cd7bb575a548544fc286e748c8c2e405bd8ac2..12c6aa01a5742d4d571738c62e51583f4f94f172 100644 (file)
@@ -48,3 +48,24 @@ bool ToolBar::create(int _tbID, HWND parentHwnd, DWORD dwStyle) {
   }
   return (hwndToolBar ? true : false);
 };
+
+int ToolBar::addBitmap(int nButtons, UINT bitmapID) {
+  assert(nButtons > 0);
+  TBADDBITMAP resBitmap;
+  resBitmap.hInst = GetModuleHandle(0);
+  resBitmap.nID = bitmapID;
+  return SendMessage(getHandle(), TB_ADDBITMAP, nButtons, (LPARAM)&resBitmap);
+}
+
+int ToolBar::addSystemBitmap(UINT stdBitmapID) {
+  TBADDBITMAP resBitmap;
+  resBitmap.hInst = HINST_COMMCTRL;
+  resBitmap.nID = stdBitmapID;
+  return SendMessage(getHandle(), TB_ADDBITMAP, 0, (LPARAM)&resBitmap);
+}
+
+bool ToolBar::setBitmapSize(int width, int height) {
+  int result = SendMessage(getHandle(), TB_SETBITMAPSIZE, 
+    0, MAKELONG(width, height));
+  return (result ? true : false);
+}
index e08bd0bcee9f602092f1959454f4a24568598c38..aed4214a5d2e7afe54cfe1a24fc85e812b004861 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <windows.h>
 #include <commctrl.h>
+#include <assert.h>
 
 class ToolBar {
 public:
@@ -31,6 +32,23 @@ public:
   // or FALSE otherwise.
   bool create(int tbID, HWND parentHwnd, DWORD dwStyle = WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT);
 
+  // -=- Button images operations
+
+  // addBitmap() adds one or more images from resources to the list of button
+  // images available for a toolbar. Returns the index of the first new image 
+  // if successful, or -1 otherwise.
+  int addBitmap(int nButtons, UINT bitmapID);
+
+  // addSystemBitmap() adds the system-defined button bitmaps to the list
+  // of the toolbar button specifying by stdBitmapID. Returns the index of 
+  // the first new image if successful, or -1 otherwise.
+  int addSystemBitmap(UINT stdBitmapID);
+
+  // setBitmapSize() sets the size of the bitmapped images to be added
+  // to a toolbar. It returns TRUE if successful, or FALSE otherwise.
+  // You must call it before addBitmap().
+  bool setBitmapSize(int width, int height);
+
   // getHandle() returns handle to a toolbar window.
   HWND getHandle() { return hwndToolBar; }