- if (m_tools.Number() == 0)
- return FALSE;
-
- HBITMAP oldToolBarBitmap = (HBITMAP) m_hBitmap;
-
- int totalBitmapWidth = (int)(m_defaultWidth * m_tools.Number());
- int totalBitmapHeight = (int)m_defaultHeight;
-
-// TODO:
-/*
- // Create a bitmap for all the tool bitmaps
- HDC dc = ::GetDC(NULL);
- m_hBitmap = (WXHBITMAP) ::CreateCompatibleBitmap(dc, totalBitmapWidth, totalBitmapHeight);
- ::ReleaseDC(NULL, dc);
-
- // Now blit all the tools onto this bitmap
- HDC memoryDC = ::CreateCompatibleDC(NULL);
- HBITMAP oldBitmap = (HBITMAP) ::SelectObject(memoryDC, (HBITMAP) m_hBitmap);
-
- HDC memoryDC2 = ::CreateCompatibleDC(NULL);
- int x = 0;
- wxNode *node = m_tools.First();
- int noButtons = 0;
- while (node)
- {
- wxToolBarTool *tool = (wxToolBarTool *)node->Data();
- if ((tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR) && tool->m_bitmap1.Ok() && tool->m_bitmap1.GetHBITMAP())
- {
-// wxPalette *palette = tool->m_bitmap1->GetPalette();
-
- HBITMAP oldBitmap2 = (HBITMAP) ::SelectObject(memoryDC2, (HBITMAP) tool->m_bitmap1.GetHBITMAP());
- // int bltResult =
- BitBlt(memoryDC, x, 0, (int) m_defaultWidth, (int) m_defaultHeight, memoryDC2,
- 0, 0, SRCCOPY);
- ::SelectObject(memoryDC2, oldBitmap2);
- x += (int)m_defaultWidth;
- noButtons ++;
- }
- node = node->Next();
- }
- ::SelectObject(memoryDC, oldBitmap);
- ::DeleteDC(memoryDC);
- ::DeleteDC(memoryDC2);
-
- // Map to system colours
- wxMapBitmap((HBITMAP) m_hBitmap, totalBitmapWidth, totalBitmapHeight);
-
- if ( oldToolBarBitmap )
- {
- TBREPLACEBITMAP replaceBitmap;
- replaceBitmap.hInstOld = NULL;
- replaceBitmap.hInstNew = NULL;
- replaceBitmap.nIDOld = (UINT) oldToolBarBitmap;
- replaceBitmap.nIDNew = (UINT) (HBITMAP) m_hBitmap;
- replaceBitmap.nButtons = noButtons;
- if (::SendMessage((HWND) GetHWND(), TB_REPLACEBITMAP, (WPARAM) 0, (LPARAM) &replaceBitmap) == -1)
- {
- wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
- }
-
- ::DeleteObject((HBITMAP) oldToolBarBitmap);
-
- // Now delete all the buttons
- int i = 0;
- while ( TRUE )
- {
- // TODO: What about separators???? They don't have an id!
- if ( ! ::SendMessage( (HWND) GetHWND(), TB_DELETEBUTTON, i, 0 ) )
- break;
- }
- }
- else
- {
- TBADDBITMAP addBitmap;
- addBitmap.hInst = 0;
- addBitmap.nID = (UINT)m_hBitmap;
- if (::SendMessage((HWND) GetHWND(), TB_ADDBITMAP, (WPARAM) noButtons, (LPARAM) &addBitmap) == -1)
- {
- wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
- }
- }
-
- // Now add the buttons.
- TBBUTTON buttons[50];
-
- node = m_tools.First();
- int i = 0;
- int bitmapId = 0;
- while (node)
- {
- wxToolBarTool *tool = (wxToolBarTool *)node->Data();
- if (tool->m_toolStyle == wxTOOL_STYLE_SEPARATOR)
- {
- buttons[i].iBitmap = 0;
- buttons[i].idCommand = 0;
-
- buttons[i].fsState = TBSTATE_ENABLED;
- buttons[i].fsStyle = TBSTYLE_SEP;
- buttons[i].dwData = 0L;
- buttons[i].iString = 0;