1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/tbar95.cpp
3 // Purpose: wxToolBar95
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "tbar95.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
34 #include "wx/dynarray.h"
35 #include "wx/settings.h"
36 #include "wx/bitmap.h"
39 #if wxUSE_BUTTONBAR && wxUSE_TOOLBAR && defined(__WIN95__)
41 #if !defined(__GNUWIN32__) && !defined(__SALFORDC__)
45 #include "wx/msw/private.h"
49 #ifdef __GNUWIN32_OLD__
50 #include "wx/msw/gnuwin32/extra.h"
57 #include "wx/msw/dib.h"
58 #include "wx/msw/tbar95.h"
59 #include "wx/app.h" // for GetComCtl32Version
61 // ----------------------------------------------------------------------------
63 // ----------------------------------------------------------------------------
65 // these standard constants are not always defined in compilers headers
69 #define TBSTYLE_LIST 0x1000
70 #define TBSTYLE_FLAT 0x0800
71 #define TBSTYLE_TRANSPARENT 0x8000
73 // use TBSTYLE_TRANSPARENT if you use TBSTYLE_FLAT
77 #define TB_GETSTYLE (WM_USER + 57)
78 #define TB_SETSTYLE (WM_USER + 56)
81 // these values correspond to those used by comctl32.dll
82 #define DEFAULTBITMAPX 16
83 #define DEFAULTBITMAPY 15
84 #define DEFAULTBUTTONX 24
85 #define DEFAULTBUTTONY 24
86 #define DEFAULTBARHEIGHT 27
88 // ----------------------------------------------------------------------------
89 // function prototypes
90 // ----------------------------------------------------------------------------
92 static void wxMapBitmap(HBITMAP hBitmap
, int width
, int height
);
94 // ----------------------------------------------------------------------------
96 // ----------------------------------------------------------------------------
98 IMPLEMENT_DYNAMIC_CLASS(wxToolBar
, wxToolBarBase
)
100 BEGIN_EVENT_TABLE(wxToolBar95
, wxToolBarBase
)
101 EVT_MOUSE_EVENTS(wxToolBar95::OnMouseEvent
)
102 EVT_SYS_COLOUR_CHANGED(wxToolBar95::OnSysColourChanged
)
105 // ============================================================================
107 // ============================================================================
109 // ----------------------------------------------------------------------------
110 // wxToolBar95 construction
111 // ----------------------------------------------------------------------------
113 void wxToolBar95::Init()
118 m_defaultWidth
= DEFAULTBITMAPX
;
119 m_defaultHeight
= DEFAULTBITMAPY
;
122 bool wxToolBar95::Create(wxWindow
*parent
,
127 const wxString
& name
)
129 wxASSERT_MSG( (style
& wxTB_VERTICAL
) == 0,
130 wxT("Sorry, wxToolBar95 under Windows 95 only "
131 "supports horizontal orientation.") );
133 // common initialisation
134 if ( !CreateControl(parent
, id
, pos
, size
, style
, name
) )
138 DWORD msflags
= 0; // WS_VISIBLE | WS_CHILD always included
139 if (style
& wxBORDER
)
140 msflags
|= WS_BORDER
;
141 msflags
|= TBSTYLE_TOOLTIPS
;
143 if (style
& wxTB_FLAT
)
145 if (wxTheApp
->GetComCtl32Version() > 400)
146 msflags
|= TBSTYLE_FLAT
;
149 // MSW-specific initialisation
150 if ( !wxControl::MSWCreateControl(TOOLBARCLASSNAME
, msflags
) )
153 // toolbar-specific post initialisation
154 ::SendMessage(GetHwnd(), TB_BUTTONSTRUCTSIZE
, sizeof(TBBUTTON
), 0);
156 // set up the colors and fonts
157 wxRGBToColour(m_backgroundColour
, GetSysColor(COLOR_BTNFACE
));
158 m_foregroundColour
= *wxBLACK
;
160 SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
));
171 height
= m_defaultHeight
;
177 SetSize(x
, y
, width
, height
);
182 wxToolBar95::~wxToolBar95()
188 ::DeleteObject((HBITMAP
) m_hBitmap
);
192 // ----------------------------------------------------------------------------
193 // adding/removing buttons
194 // ----------------------------------------------------------------------------
196 void wxToolBar95::ClearTools()
198 // TODO: Don't know how to reset the toolbar bitmap, as yet.
199 // But adding tools and calling CreateTools should probably
200 // recreate a buttonbar OK.
201 wxToolBarBase::ClearTools();
204 bool wxToolBar95::DeleteTool(int id
)
206 int index
= GetIndexFromId(id
);
207 wxASSERT_MSG( index
!= wxNOT_FOUND
, _T("invalid toolbar button id") );
209 if ( !SendMessage(GetHwnd(), TB_DELETEBUTTON
, index
, 0) )
211 wxLogLastError("TB_DELETEBUTTON");
216 wxNode
*node
= m_tools
.Nth(index
);
217 delete (wxToolBarTool
*)node
->Data();
218 m_tools
.DeleteNode(node
);
220 m_ids
.RemoveAt(index
);
225 bool wxToolBar95::AddControl(wxControl
*control
)
227 wxCHECK_MSG( control
, FALSE
, _T("toolbar: can't insert NULL control") );
229 wxCHECK_MSG( control
->GetParent() == this, FALSE
,
230 _T("control must have toolbar as parent") );
232 wxToolBarTool
*tool
= new wxToolBarTool(control
);
234 m_tools
.Append(control
->GetId(), tool
);
235 m_ids
.Add(control
->GetId());
240 wxToolBarTool
*wxToolBar95::AddTool(int index
,
241 const wxBitmap
& bitmap
,
242 const wxBitmap
& pushedBitmap
,
244 long xPos
, long yPos
,
245 wxObject
*clientData
,
246 const wxString
& helpString1
,
247 const wxString
& helpString2
)
249 wxToolBarTool
*tool
= new wxToolBarTool(index
, bitmap
, wxNullBitmap
,
251 helpString1
, helpString2
);
252 tool
->m_clientData
= clientData
;
257 tool
->m_x
= m_xMargin
;
262 tool
->m_y
= m_yMargin
;
264 tool
->SetSize(GetToolSize().x
, GetToolSize().y
);
266 m_tools
.Append((long)index
, tool
);
272 bool wxToolBar95::CreateTools()
274 size_t nTools
= m_tools
.GetCount();
278 HBITMAP oldToolBarBitmap
= (HBITMAP
) m_hBitmap
;
280 int totalBitmapWidth
= (int)(m_defaultWidth
* nTools
);
281 int totalBitmapHeight
= (int)m_defaultHeight
;
283 // Create a bitmap for all the tool bitmaps
284 HDC dc
= ::GetDC(NULL
);
285 m_hBitmap
= (WXHBITMAP
) ::CreateCompatibleBitmap(dc
,
288 ::ReleaseDC(NULL
, dc
);
290 // Now blit all the tools onto this bitmap
291 HDC memoryDC
= ::CreateCompatibleDC(NULL
);
292 HBITMAP oldBitmap
= (HBITMAP
) ::SelectObject(memoryDC
, (HBITMAP
)m_hBitmap
);
294 HDC memoryDC2
= ::CreateCompatibleDC(NULL
);
296 // the button position
299 // the number of buttons (not separators)
302 wxNode
*node
= m_tools
.First();
305 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
306 if ( tool
->m_toolStyle
== wxTOOL_STYLE_BUTTON
&& tool
->m_bitmap1
.Ok() )
308 HBITMAP hbmp
= GetHbitmapOf(tool
->m_bitmap1
);
311 HBITMAP oldBitmap2
= (HBITMAP
)::SelectObject(memoryDC2
, hbmp
);
312 if ( !BitBlt(memoryDC
, x
, 0, m_defaultWidth
, m_defaultHeight
,
313 memoryDC2
, 0, 0, SRCCOPY
) )
315 wxLogLastError("BitBlt");
318 ::SelectObject(memoryDC2
, oldBitmap2
);
327 ::SelectObject(memoryDC
, oldBitmap
);
328 ::DeleteDC(memoryDC
);
329 ::DeleteDC(memoryDC2
);
331 // Map to system colours
332 wxMapBitmap((HBITMAP
) m_hBitmap
, totalBitmapWidth
, totalBitmapHeight
);
334 if ( oldToolBarBitmap
)
336 TBREPLACEBITMAP replaceBitmap
;
337 replaceBitmap
.hInstOld
= NULL
;
338 replaceBitmap
.hInstNew
= NULL
;
339 replaceBitmap
.nIDOld
= (UINT
) oldToolBarBitmap
;
340 replaceBitmap
.nIDNew
= (UINT
) (HBITMAP
) m_hBitmap
;
341 replaceBitmap
.nButtons
= noButtons
;
342 if ( ::SendMessage(GetHwnd(), TB_REPLACEBITMAP
,
343 0, (LPARAM
) &replaceBitmap
) == -1 )
345 wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
348 ::DeleteObject((HBITMAP
) oldToolBarBitmap
);
350 // Now delete all the buttons
354 // TODO: What about separators???? They don't have an id!
355 if ( ! ::SendMessage( GetHwnd(), TB_DELETEBUTTON
, i
, 0 ) )
361 TBADDBITMAP addBitmap
;
363 addBitmap
.nID
= (UINT
)m_hBitmap
;
364 if ( ::SendMessage(GetHwnd(), TB_ADDBITMAP
,
365 (WPARAM
) noButtons
, (LPARAM
)&addBitmap
) == -1 )
367 wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
371 // Now add the buttons.
372 TBBUTTON
*buttons
= new TBBUTTON
[nTools
];
374 // this array will holds the indices of all controls in the toolbar
375 wxArrayInt controlIds
;
380 node
= m_tools
.First();
383 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
384 TBBUTTON
& button
= buttons
[i
];
386 wxZeroMemory(button
);
388 switch ( tool
->m_toolStyle
)
390 case wxTOOL_STYLE_CONTROL
:
392 button
.idCommand
= tool
->m_index
;
393 // fall through: create just a separator too
395 case wxTOOL_STYLE_SEPARATOR
:
396 button
.fsState
= TBSTATE_ENABLED
;
397 button
.fsStyle
= TBSTYLE_SEP
;
400 case wxTOOL_STYLE_BUTTON
:
401 button
.iBitmap
= bitmapId
;
402 button
.idCommand
= tool
->m_index
;
405 button
.fsState
|= TBSTATE_ENABLED
;
406 if (tool
->m_toggleState
)
407 button
.fsState
|= TBSTATE_CHECKED
;
408 button
.fsStyle
= tool
->m_isToggle
? TBSTYLE_CHECK
419 if ( !::SendMessage(GetHwnd(), TB_ADDBUTTONS
,
420 (WPARAM
)i
, (LPARAM
)buttons
) )
422 wxLogLastError("TB_ADDBUTTONS");
427 // adjust the controls size to fit nicely in the toolbar
428 size_t nControls
= controlIds
.GetCount();
429 for ( size_t nCtrl
= 0; nCtrl
< nControls
; nCtrl
++ )
431 wxToolBarTool
*tool
= (wxToolBarTool
*)
432 m_tools
.Nth(controlIds
[nCtrl
])->Data();
433 wxControl
*control
= tool
->GetControl();
435 wxSize size
= control
->GetSize();
437 // the position of the leftmost controls corner
440 // TB_SETBUTTONINFO message is only supported by comctl32.dll 4.71+
441 #if defined(_WIN32_IE) && (_WIN32_IE >= 0x400 )
442 // available in headers, now check whether it is available now
444 if ( wxTheApp
->GetComCtl32Version() >= 471 )
446 // set the (underlying) separators width to be that of the
449 tbbi
.cbSize
= sizeof(tbbi
);
450 tbbi
.dwMask
= TBIF_SIZE
;
452 if ( !SendMessage(GetHwnd(), TB_SETBUTTONINFO
,
453 tool
->m_index
, (LPARAM
)&tbbi
) )
455 // the index is probably invalid
456 wxLogLastError("TB_SETBUTTONINFO");
461 #endif // comctl32.dll 4.71
462 // TB_SETBUTTONINFO unavailable
464 int index
= GetIndexFromId(tool
->m_index
);
465 wxASSERT_MSG( index
!= wxNOT_FOUND
,
466 _T("control wasn't added to the tbar?") );
468 // try adding several separators to fit the controls width
470 if ( !SendMessage(GetHwnd(), TB_GETRECT
,
471 tool
->m_index
, (LPARAM
)(LPRECT
)&r
) )
473 wxLogLastError("TB_GETITEMRECT");
476 int widthSep
= r
.right
- r
.left
;
482 tbb
.fsState
= TBSTATE_ENABLED
;
483 tbb
.fsStyle
= TBSTYLE_SEP
;
485 size_t nSeparators
= size
.x
/ widthSep
;
486 for ( size_t nSep
= 0; nSep
< nSeparators
; nSep
++ )
488 m_ids
.Insert(0, (size_t)index
);
490 if ( !SendMessage(GetHwnd(), TB_INSERTBUTTON
,
491 index
, (LPARAM
)&tbb
) )
493 wxLogLastError("TB_INSERTBUTTON");
497 // adjust the controls width to exactly cover the separators
498 control
->SetSize((nSeparators
+ 1)*widthSep
, -1);
501 // and position the control itself correctly vertically
503 if ( !SendMessage(GetHwnd(), TB_GETRECT
,
504 tool
->m_index
, (LPARAM
)(LPRECT
)&r
) )
506 wxLogLastError("TB_GETRECT");
509 int height
= r
.bottom
- r
.top
;
510 int diff
= height
- size
.y
;
513 // the control is too high, resize to fit
514 control
->SetSize(-1, height
- 2);
519 control
->Move(left
== -1 ? r
.left
: left
, r
.top
+ diff
/ 2);
522 (void)::SendMessage(GetHwnd(), TB_AUTOSIZE
, (WPARAM
)0, (LPARAM
) 0);
529 // ----------------------------------------------------------------------------
531 // ----------------------------------------------------------------------------
533 bool wxToolBar95::MSWCommand(WXUINT cmd
, WXWORD id
)
535 wxNode
*node
= m_tools
.Find((long)id
);
539 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
540 if (tool
->m_isToggle
)
542 LRESULT state
= ::SendMessage(GetHwnd(), TB_GETSTATE
, id
, 0);
543 tool
->m_toggleState
= state
& TBSTATE_CHECKED
;
546 BOOL ret
= OnLeftClick((int)id
, tool
->m_toggleState
);
547 if ( ret
== FALSE
&& tool
->m_isToggle
)
549 tool
->m_toggleState
= !tool
->m_toggleState
;
550 ::SendMessage(GetHwnd(), TB_CHECKBUTTON
,
551 (WPARAM
)id
, (LPARAM
)MAKELONG(tool
->m_toggleState
, 0));
557 bool wxToolBar95::MSWOnNotify(int WXUNUSED(idCtrl
),
561 // First check if this applies to us
562 NMHDR
*hdr
= (NMHDR
*)lParam
;
564 // the tooltips control created by the toolbar is sometimes Unicode, even
565 // in an ANSI application - this seems to be a bug in comctl32.dll v5
566 int code
= (int)hdr
->code
;
567 if ( (code
!= TTN_NEEDTEXTA
) && (code
!= TTN_NEEDTEXTW
) )
570 HWND toolTipWnd
= (HWND
)::SendMessage((HWND
)GetHWND(), TB_GETTOOLTIPS
, 0, 0);
571 if ( toolTipWnd
!= hdr
->hwndFrom
)
574 LPTOOLTIPTEXT ttText
= (LPTOOLTIPTEXT
)lParam
;
575 int id
= (int)ttText
->hdr
.idFrom
;
576 wxNode
*node
= m_tools
.Find((long)id
);
580 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
582 const wxString
& help
= tool
->m_shortHelpString
;
584 if ( !help
.IsEmpty() )
586 if ( code
== TTN_NEEDTEXTA
)
588 ttText
->lpszText
= (wxChar
*)help
.c_str();
590 #if (_WIN32_IE >= 0x0300)
593 // FIXME this is a temp hack only until I understand better what
594 // must be done in both ANSI and Unicode builds
596 size_t lenAnsi
= help
.Len();
598 // MetroWerks doesn't like calling mbstowcs with NULL argument
599 size_t lenUnicode
= 2*lenAnsi
;
601 size_t lenUnicode
= mbstowcs(NULL
, help
, lenAnsi
);
604 // using the pointer of right type avoids us doing all sorts of
605 // pointer arithmetics ourselves
606 wchar_t *dst
= (wchar_t *)ttText
->szText
,
607 *pwz
= new wchar_t[lenUnicode
+ 1];
608 mbstowcs(pwz
, help
, lenAnsi
+ 1);
609 memcpy(dst
, pwz
, lenUnicode
*sizeof(wchar_t));
611 // put the terminating _wide_ NUL
616 #endif // _WIN32_IE >= 0x0300
619 // For backward compatibility...
620 OnMouseEnter(tool
->m_index
);
625 // ----------------------------------------------------------------------------
627 // ----------------------------------------------------------------------------
629 void wxToolBar95::SetToolBitmapSize(const wxSize
& size
)
631 wxToolBarBase::SetToolBitmapSize(size
);
633 ::SendMessage(GetHwnd(), TB_SETBITMAPSIZE
, 0, MAKELONG(size
.x
, size
.y
));
636 void wxToolBar95::SetRows(int nRows
)
638 // TRUE in wParam means to create at least as many rows
640 ::SendMessage(GetHwnd(), TB_SETROWS
,
641 MAKEWPARAM(nRows
, TRUE
), (LPARAM
) &rect
);
643 m_maxWidth
= (rect
.right
- rect
.left
+ 2);
644 m_maxHeight
= (rect
.bottom
- rect
.top
+ 2);
649 wxSize
wxToolBar95::GetMaxSize() const
651 if ( (m_maxWidth
== -1) || (m_maxHeight
== -1) )
653 // it has a side effect of filling m_maxWidth/Height variables
654 ((wxToolBar95
*)this)->SetRows(m_maxRows
); // const_cast
657 return wxSize(m_maxWidth
, m_maxHeight
);
660 // The button size is bigger than the bitmap size
661 wxSize
wxToolBar95::GetToolSize() const
663 // FIXME: this is completely bogus (VZ)
664 return wxSize(m_defaultWidth
+ 8, m_defaultHeight
+ 7);
667 // ----------------------------------------------------------------------------
669 // ----------------------------------------------------------------------------
671 void wxToolBar95::EnableTool(int toolIndex
, bool enable
)
673 wxNode
*node
= m_tools
.Find((long)toolIndex
);
676 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
677 tool
->m_enabled
= enable
;
678 ::SendMessage(GetHwnd(), TB_ENABLEBUTTON
,
679 (WPARAM
)toolIndex
, (LPARAM
)MAKELONG(enable
, 0));
683 void wxToolBar95::ToggleTool(int toolIndex
, bool toggle
)
685 wxNode
*node
= m_tools
.Find((long)toolIndex
);
688 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
689 if (tool
->m_isToggle
)
691 tool
->m_toggleState
= toggle
;
692 ::SendMessage(GetHwnd(), TB_CHECKBUTTON
,
693 (WPARAM
)toolIndex
, (LPARAM
)MAKELONG(toggle
, 0));
698 bool wxToolBar95::GetToolState(int toolIndex
) const
700 wxASSERT_MSG( GetIndexFromId(toolIndex
) != wxNOT_FOUND
,
701 _T("invalid toolbar button id") );
703 return ::SendMessage(GetHwnd(), TB_ISBUTTONCHECKED
,
704 (WPARAM
)toolIndex
, (LPARAM
)0) != 0;
707 // ----------------------------------------------------------------------------
709 // ----------------------------------------------------------------------------
711 // Responds to colour changes, and passes event on to children.
712 void wxToolBar95::OnSysColourChanged(wxSysColourChangedEvent
& event
)
714 m_backgroundColour
= wxColour(GetRValue(GetSysColor(COLOR_BTNFACE
)),
715 GetGValue(GetSysColor(COLOR_BTNFACE
)), GetBValue(GetSysColor(COLOR_BTNFACE
)));
722 // Propagate the event to the non-top-level children
723 wxWindow::OnSysColourChanged(event
);
726 void wxToolBar95::OnMouseEvent(wxMouseEvent
& event
)
728 if (event
.RightDown())
730 // For now, we don't have an id. Later we could
731 // try finding the tool.
732 OnRightClick((int)-1, event
.GetX(), event
.GetY());
741 // ----------------------------------------------------------------------------
743 // ----------------------------------------------------------------------------
745 int wxToolBar95::GetIndexFromId(int id
) const
747 size_t count
= m_ids
.GetCount();
748 for ( size_t n
= 0; n
< count
; n
++ )
750 if ( m_ids
[n
] == id
)
757 // ----------------------------------------------------------------------------
759 // ----------------------------------------------------------------------------
761 // These are the default colors used to map the bitmap colors to the current
762 // system colors. Note that they are in BGR format because this is what Windows
763 // wants (and not RGB)
765 #define BGR_BUTTONTEXT (RGB(000,000,000)) // black
766 #define BGR_BUTTONSHADOW (RGB(128,128,128)) // dark grey
767 #define BGR_BUTTONFACE (RGB(192,192,192)) // bright grey
768 #define BGR_BUTTONHILIGHT (RGB(255,255,255)) // white
769 #define BGR_BACKGROUNDSEL (RGB(000,000,255)) // blue
770 #define BGR_BACKGROUND (RGB(255,000,255)) // magenta
772 void wxMapBitmap(HBITMAP hBitmap
, int width
, int height
)
774 COLORMAP ColorMap
[] =
776 {BGR_BUTTONTEXT
, COLOR_BTNTEXT
}, // black
777 {BGR_BUTTONSHADOW
, COLOR_BTNSHADOW
}, // dark grey
778 {BGR_BUTTONFACE
, COLOR_BTNFACE
}, // bright grey
779 {BGR_BUTTONHILIGHT
, COLOR_BTNHIGHLIGHT
},// white
780 {BGR_BACKGROUNDSEL
, COLOR_HIGHLIGHT
}, // blue
781 {BGR_BACKGROUND
, COLOR_WINDOW
} // magenta
784 int NUM_MAPS
= (sizeof(ColorMap
)/sizeof(COLORMAP
));
786 for ( n
= 0; n
< NUM_MAPS
; n
++)
788 ColorMap
[n
].to
= ::GetSysColor(ColorMap
[n
].to
);
792 HDC hdcMem
= CreateCompatibleDC(NULL
);
796 hbmOld
= (HBITMAP
) SelectObject(hdcMem
, hBitmap
);
799 for ( i
= 0; i
< width
; i
++)
801 for ( j
= 0; j
< height
; j
++)
803 COLORREF pixel
= ::GetPixel(hdcMem
, i
, j
);
805 BYTE red = GetRValue(pixel);
806 BYTE green = GetGValue(pixel);
807 BYTE blue = GetBValue(pixel);
810 for ( k
= 0; k
< NUM_MAPS
; k
++)
812 if ( ColorMap
[k
].from
== pixel
)
814 /* COLORREF actualPixel = */ ::SetPixel(hdcMem
, i
, j
, ColorMap
[k
].to
);
822 SelectObject(hdcMem
, hbmOld
);
823 DeleteObject(hdcMem
);
828 // Some experiments...
830 // What we want to do is create another bitmap which has a depth of 4,
831 // and set the bits. So probably we want to convert this HBITMAP into a
832 // DIB, then call SetDIBits.
833 // AAAGH. The stupid thing is that if newBitmap has a depth of 4 (less than that of
834 // the screen), then SetDIBits fails.
835 HBITMAP newBitmap
= ::CreateBitmap(totalBitmapWidth
, totalBitmapHeight
, 1, 4, NULL
);
836 HANDLE newDIB
= ::BitmapToDIB((HBITMAP
) m_hBitmap
, NULL
);
837 LPBITMAPINFOHEADER lpbmi
= (LPBITMAPINFOHEADER
) GlobalLock(newDIB
);
840 // LPBITMAPINFOHEADER lpbmi = (LPBITMAPINFOHEADER) newDIB;
842 int result
= ::SetDIBits(dc
, newBitmap
, 0, lpbmi
->biHeight
, FindDIBBits((LPSTR
)lpbmi
), (LPBITMAPINFO
)lpbmi
,
844 DWORD err
= GetLastError();
846 ::ReleaseDC(NULL
, dc
);
849 GlobalUnlock (newDIB
);
852 // WXHBITMAP hBitmap2 = wxCreateMappedBitmap((WXHINSTANCE) wxGetInstance(), (WXHBITMAP) m_hBitmap);
853 // Substitute our new bitmap for the old one
854 ::DeleteObject((HBITMAP
) m_hBitmap
);
855 m_hBitmap
= (WXHBITMAP
) newBitmap
;
859 #endif // !(wxUSE_TOOLBAR && Win95)