From: george82 Date: Tue, 11 Jan 2005 14:47:14 +0000 (+0000) Subject: Added button images operations to the ToolBar class: X-Git-Tag: v0.0.90~384^2~743 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c7039163edebceea269027342555408808c94371;p=tigervnc.git Added button images operations to the ToolBar class: addBitmap(), addSysBitmap(), setBitmapSize(). git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@92 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/rfbplayer/ToolBar.cxx b/rfbplayer/ToolBar.cxx index b9cd7bb5..12c6aa01 100644 --- a/rfbplayer/ToolBar.cxx +++ b/rfbplayer/ToolBar.cxx @@ -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); +} diff --git a/rfbplayer/ToolBar.h b/rfbplayer/ToolBar.h index e08bd0bc..aed4214a 100644 --- a/rfbplayer/ToolBar.h +++ b/rfbplayer/ToolBar.h @@ -20,6 +20,7 @@ #include #include +#include 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; }