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 #if !USE_SHARED_LIBRARY
99 IMPLEMENT_DYNAMIC_CLASS(wxToolBar
, wxToolBarBase
)
102 BEGIN_EVENT_TABLE(wxToolBar95
, wxToolBarBase
)
103 EVT_MOUSE_EVENTS(wxToolBar95::OnMouseEvent
)
104 EVT_SYS_COLOUR_CHANGED(wxToolBar95::OnSysColourChanged
)
107 // ============================================================================
109 // ============================================================================
111 // ----------------------------------------------------------------------------
112 // wxToolBar95 construction
113 // ----------------------------------------------------------------------------
115 void wxToolBar95::Init()
120 m_defaultWidth
= DEFAULTBITMAPX
;
121 m_defaultHeight
= DEFAULTBITMAPY
;
124 bool wxToolBar95::Create(wxWindow
*parent
,
129 const wxString
& name
)
131 wxASSERT_MSG( (style
& wxTB_VERTICAL
) == 0,
132 wxT("Sorry, wxToolBar95 under Windows 95 only "
133 "supports horizontal orientation.") );
135 // common initialisation
136 if ( !CreateControl(parent
, id
, pos
, size
, style
, name
) )
140 DWORD msflags
= 0; // WS_VISIBLE | WS_CHILD always included
141 if (style
& wxBORDER
)
142 msflags
|= WS_BORDER
;
143 msflags
|= TBSTYLE_TOOLTIPS
;
145 if (style
& wxTB_FLAT
)
147 if (wxTheApp
->GetComCtl32Version() > 400)
148 msflags
|= TBSTYLE_FLAT
;
151 // MSW-specific initialisation
152 if ( !wxControl::MSWCreateControl(TOOLBARCLASSNAME
, msflags
) )
155 // toolbar-specific post initialisation
156 ::SendMessage(GetHwnd(), TB_BUTTONSTRUCTSIZE
, sizeof(TBBUTTON
), 0);
158 // set up the colors and fonts
159 wxRGBToColour(m_backgroundColour
, GetSysColor(COLOR_BTNFACE
));
160 m_foregroundColour
= *wxBLACK
;
162 SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT
));
173 height
= m_defaultHeight
;
179 SetSize(x
, y
, width
, height
);
184 wxToolBar95::~wxToolBar95()
190 ::DeleteObject((HBITMAP
) m_hBitmap
);
194 // ----------------------------------------------------------------------------
195 // adding/removing buttons
196 // ----------------------------------------------------------------------------
198 void wxToolBar95::ClearTools()
200 // TODO: Don't know how to reset the toolbar bitmap, as yet.
201 // But adding tools and calling CreateTools should probably
202 // recreate a buttonbar OK.
203 wxToolBarBase::ClearTools();
206 bool wxToolBar95::DeleteTool(int id
)
208 int index
= GetIndexFromId(id
);
209 wxASSERT_MSG( index
!= wxNOT_FOUND
, _T("invalid toolbar button id") );
211 if ( !SendMessage(GetHwnd(), TB_DELETEBUTTON
, index
, 0) )
213 wxLogLastError("TB_DELETEBUTTON");
218 wxNode
*node
= m_tools
.Nth(index
);
219 delete (wxToolBarTool
*)node
->Data();
220 m_tools
.DeleteNode(node
);
222 m_ids
.RemoveAt(index
);
227 bool wxToolBar95::AddControl(wxControl
*control
)
229 wxCHECK_MSG( control
, FALSE
, _T("toolbar: can't insert NULL control") );
231 wxCHECK_MSG( control
->GetParent() == this, FALSE
,
232 _T("control must have toolbar as parent") );
234 wxToolBarTool
*tool
= new wxToolBarTool(control
);
236 m_tools
.Append(control
->GetId(), tool
);
237 m_ids
.Add(control
->GetId());
242 wxToolBarTool
*wxToolBar95::AddTool(int index
,
243 const wxBitmap
& bitmap
,
244 const wxBitmap
& pushedBitmap
,
246 long xPos
, long yPos
,
247 wxObject
*clientData
,
248 const wxString
& helpString1
,
249 const wxString
& helpString2
)
251 wxToolBarTool
*tool
= new wxToolBarTool(index
, bitmap
, wxNullBitmap
,
253 helpString1
, helpString2
);
254 tool
->m_clientData
= clientData
;
259 tool
->m_x
= m_xMargin
;
264 tool
->m_y
= m_yMargin
;
266 tool
->SetSize(GetToolSize().x
, GetToolSize().y
);
268 m_tools
.Append((long)index
, tool
);
274 bool wxToolBar95::CreateTools()
276 size_t nTools
= m_tools
.GetCount();
280 HBITMAP oldToolBarBitmap
= (HBITMAP
) m_hBitmap
;
282 int totalBitmapWidth
= (int)(m_defaultWidth
* nTools
);
283 int totalBitmapHeight
= (int)m_defaultHeight
;
285 // Create a bitmap for all the tool bitmaps
286 HDC dc
= ::GetDC(NULL
);
287 m_hBitmap
= (WXHBITMAP
) ::CreateCompatibleBitmap(dc
,
290 ::ReleaseDC(NULL
, dc
);
292 // Now blit all the tools onto this bitmap
293 HDC memoryDC
= ::CreateCompatibleDC(NULL
);
294 HBITMAP oldBitmap
= (HBITMAP
) ::SelectObject(memoryDC
, (HBITMAP
)m_hBitmap
);
296 HDC memoryDC2
= ::CreateCompatibleDC(NULL
);
298 // the button position
301 // the number of buttons (not separators)
304 wxNode
*node
= m_tools
.First();
307 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
308 if ( tool
->m_toolStyle
== wxTOOL_STYLE_BUTTON
&& tool
->m_bitmap1
.Ok() )
310 HBITMAP hbmp
= GetHbitmapOf(tool
->m_bitmap1
);
313 HBITMAP oldBitmap2
= (HBITMAP
)::SelectObject(memoryDC2
, hbmp
);
314 if ( !BitBlt(memoryDC
, x
, 0, m_defaultWidth
, m_defaultHeight
,
315 memoryDC2
, 0, 0, SRCCOPY
) )
317 wxLogLastError("BitBlt");
320 ::SelectObject(memoryDC2
, oldBitmap2
);
329 ::SelectObject(memoryDC
, oldBitmap
);
330 ::DeleteDC(memoryDC
);
331 ::DeleteDC(memoryDC2
);
333 // Map to system colours
334 wxMapBitmap((HBITMAP
) m_hBitmap
, totalBitmapWidth
, totalBitmapHeight
);
336 if ( oldToolBarBitmap
)
338 TBREPLACEBITMAP replaceBitmap
;
339 replaceBitmap
.hInstOld
= NULL
;
340 replaceBitmap
.hInstNew
= NULL
;
341 replaceBitmap
.nIDOld
= (UINT
) oldToolBarBitmap
;
342 replaceBitmap
.nIDNew
= (UINT
) (HBITMAP
) m_hBitmap
;
343 replaceBitmap
.nButtons
= noButtons
;
344 if ( ::SendMessage(GetHwnd(), TB_REPLACEBITMAP
,
345 0, (LPARAM
) &replaceBitmap
) == -1 )
347 wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
350 ::DeleteObject((HBITMAP
) oldToolBarBitmap
);
352 // Now delete all the buttons
356 // TODO: What about separators???? They don't have an id!
357 if ( ! ::SendMessage( GetHwnd(), TB_DELETEBUTTON
, i
, 0 ) )
363 TBADDBITMAP addBitmap
;
365 addBitmap
.nID
= (UINT
)m_hBitmap
;
366 if ( ::SendMessage(GetHwnd(), TB_ADDBITMAP
,
367 (WPARAM
) noButtons
, (LPARAM
)&addBitmap
) == -1 )
369 wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
373 // Now add the buttons.
374 TBBUTTON
*buttons
= new TBBUTTON
[nTools
];
376 // this array will holds the indices of all controls in the toolbar
377 wxArrayInt controlIds
;
382 node
= m_tools
.First();
385 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
386 TBBUTTON
& button
= buttons
[i
];
388 wxZeroMemory(button
);
390 switch ( tool
->m_toolStyle
)
392 case wxTOOL_STYLE_CONTROL
:
394 button
.idCommand
= tool
->m_index
;
395 // fall through: create just a separator too
397 case wxTOOL_STYLE_SEPARATOR
:
398 button
.fsState
= TBSTATE_ENABLED
;
399 button
.fsStyle
= TBSTYLE_SEP
;
402 case wxTOOL_STYLE_BUTTON
:
403 button
.iBitmap
= bitmapId
;
404 button
.idCommand
= tool
->m_index
;
407 button
.fsState
|= TBSTATE_ENABLED
;
408 if (tool
->m_toggleState
)
409 button
.fsState
|= TBSTATE_CHECKED
;
410 button
.fsStyle
= tool
->m_isToggle
? TBSTYLE_CHECK
421 if ( !::SendMessage(GetHwnd(), TB_ADDBUTTONS
,
422 (WPARAM
)i
, (LPARAM
)buttons
) )
424 wxLogLastError("TB_ADDBUTTONS");
429 // adjust the controls size to fit nicely in the toolbar
430 size_t nControls
= controlIds
.GetCount();
431 for ( size_t nCtrl
= 0; nCtrl
< nControls
; nCtrl
++ )
433 wxToolBarTool
*tool
= (wxToolBarTool
*)
434 m_tools
.Nth(controlIds
[nCtrl
])->Data();
435 wxControl
*control
= tool
->GetControl();
437 wxSize size
= control
->GetSize();
439 // the position of the leftmost controls corner
442 // TB_SETBUTTONINFO message is only supported by comctl32.dll 4.71+
443 #if defined(_WIN32_IE) && (_WIN32_IE >= 0x400 )
444 // available in headers, now check whether it is available now
446 if ( wxTheApp
->GetComCtl32Version() >= 471 )
448 // set the (underlying) separators width to be that of the
451 tbbi
.cbSize
= sizeof(tbbi
);
452 tbbi
.dwMask
= TBIF_SIZE
;
454 if ( !SendMessage(GetHwnd(), TB_SETBUTTONINFO
,
455 tool
->m_index
, (LPARAM
)&tbbi
) )
457 // the index is probably invalid
458 wxLogLastError("TB_SETBUTTONINFO");
463 #endif // comctl32.dll 4.71
464 // TB_SETBUTTONINFO unavailable
466 int index
= GetIndexFromId(tool
->m_index
);
467 wxASSERT_MSG( index
!= wxNOT_FOUND
,
468 _T("control wasn't added to the tbar?") );
470 // try adding several separators to fit the controls width
472 if ( !SendMessage(GetHwnd(), TB_GETRECT
,
473 tool
->m_index
, (LPARAM
)(LPRECT
)&r
) )
475 wxLogLastError("TB_GETITEMRECT");
478 int widthSep
= r
.right
- r
.left
;
484 tbb
.fsState
= TBSTATE_ENABLED
;
485 tbb
.fsStyle
= TBSTYLE_SEP
;
487 size_t nSeparators
= size
.x
/ widthSep
;
488 for ( size_t nSep
= 0; nSep
< nSeparators
; nSep
++ )
490 m_ids
.Insert(0, (size_t)index
);
492 if ( !SendMessage(GetHwnd(), TB_INSERTBUTTON
,
493 index
, (LPARAM
)&tbb
) )
495 wxLogLastError("TB_INSERTBUTTON");
499 // adjust the controls width to exactly cover the separators
500 control
->SetSize((nSeparators
+ 1)*widthSep
, -1);
503 // and position the control itself correctly vertically
505 if ( !SendMessage(GetHwnd(), TB_GETRECT
,
506 tool
->m_index
, (LPARAM
)(LPRECT
)&r
) )
508 wxLogLastError("TB_GETRECT");
511 int height
= r
.bottom
- r
.top
;
512 int diff
= height
- size
.y
;
515 // the control is too high, resize to fit
516 control
->SetSize(-1, height
- 2);
521 control
->Move(left
== -1 ? r
.left
: left
, r
.top
+ diff
/ 2);
524 (void)::SendMessage(GetHwnd(), TB_AUTOSIZE
, (WPARAM
)0, (LPARAM
) 0);
531 // ----------------------------------------------------------------------------
533 // ----------------------------------------------------------------------------
535 bool wxToolBar95::MSWCommand(WXUINT cmd
, WXWORD id
)
537 wxNode
*node
= m_tools
.Find((long)id
);
541 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
542 if (tool
->m_isToggle
)
544 LRESULT state
= ::SendMessage(GetHwnd(), TB_GETSTATE
, id
, 0);
545 tool
->m_toggleState
= state
& TBSTATE_CHECKED
;
548 BOOL ret
= OnLeftClick((int)id
, tool
->m_toggleState
);
549 if ( ret
== FALSE
&& tool
->m_isToggle
)
551 tool
->m_toggleState
= !tool
->m_toggleState
;
552 ::SendMessage(GetHwnd(), TB_CHECKBUTTON
,
553 (WPARAM
)id
, (LPARAM
)MAKELONG(tool
->m_toggleState
, 0));
559 bool wxToolBar95::MSWOnNotify(int WXUNUSED(idCtrl
),
563 // First check if this applies to us
564 NMHDR
*hdr
= (NMHDR
*)lParam
;
566 // the tooltips control created by the toolbar is sometimes Unicode, even
567 // in an ANSI application - this seems to be a bug in comctl32.dll v5
568 int code
= (int)hdr
->code
;
569 if ( (code
!= TTN_NEEDTEXTA
) && (code
!= TTN_NEEDTEXTW
) )
572 HWND toolTipWnd
= (HWND
)::SendMessage((HWND
)GetHWND(), TB_GETTOOLTIPS
, 0, 0);
573 if ( toolTipWnd
!= hdr
->hwndFrom
)
576 LPTOOLTIPTEXT ttText
= (LPTOOLTIPTEXT
)lParam
;
577 int id
= (int)ttText
->hdr
.idFrom
;
578 wxNode
*node
= m_tools
.Find((long)id
);
582 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
584 const wxString
& help
= tool
->m_shortHelpString
;
586 if ( !help
.IsEmpty() )
588 if ( code
== TTN_NEEDTEXTA
)
590 ttText
->lpszText
= (wxChar
*)help
.c_str();
592 #if (_WIN32_IE >= 0x0300)
595 // FIXME this is a temp hack only until I understand better what
596 // must be done in both ANSI and Unicode builds
598 size_t lenAnsi
= help
.Len();
600 // MetroWerks doesn't like calling mbstowcs with NULL argument
601 size_t lenUnicode
= 2*lenAnsi
;
603 size_t lenUnicode
= mbstowcs(NULL
, help
, lenAnsi
);
606 // using the pointer of right type avoids us doing all sorts of
607 // pointer arithmetics ourselves
608 wchar_t *dst
= (wchar_t *)ttText
->szText
,
609 *pwz
= new wchar_t[lenUnicode
+ 1];
610 mbstowcs(pwz
, help
, lenAnsi
+ 1);
611 memcpy(dst
, pwz
, lenUnicode
*sizeof(wchar_t));
613 // put the terminating _wide_ NUL
618 #endif // _WIN32_IE >= 0x0300
621 // For backward compatibility...
622 OnMouseEnter(tool
->m_index
);
627 // ----------------------------------------------------------------------------
629 // ----------------------------------------------------------------------------
631 void wxToolBar95::SetToolBitmapSize(const wxSize
& size
)
633 wxToolBarBase::SetToolBitmapSize(size
);
635 ::SendMessage(GetHwnd(), TB_SETBITMAPSIZE
, 0, MAKELONG(size
.x
, size
.y
));
638 void wxToolBar95::SetRows(int nRows
)
640 // TRUE in wParam means to create at least as many rows
642 ::SendMessage(GetHwnd(), TB_SETROWS
,
643 MAKEWPARAM(nRows
, TRUE
), (LPARAM
) &rect
);
645 m_maxWidth
= (rect
.right
- rect
.left
+ 2);
646 m_maxHeight
= (rect
.bottom
- rect
.top
+ 2);
651 wxSize
wxToolBar95::GetMaxSize() const
653 if ( (m_maxWidth
== -1) || (m_maxHeight
== -1) )
655 // it has a side effect of filling m_maxWidth/Height variables
656 ((wxToolBar95
*)this)->SetRows(m_maxRows
); // const_cast
659 return wxSize(m_maxWidth
, m_maxHeight
);
662 // The button size is bigger than the bitmap size
663 wxSize
wxToolBar95::GetToolSize() const
665 // FIXME: this is completely bogus (VZ)
666 return wxSize(m_defaultWidth
+ 8, m_defaultHeight
+ 7);
669 // ----------------------------------------------------------------------------
671 // ----------------------------------------------------------------------------
673 void wxToolBar95::EnableTool(int toolIndex
, bool enable
)
675 wxNode
*node
= m_tools
.Find((long)toolIndex
);
678 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
679 tool
->m_enabled
= enable
;
680 ::SendMessage(GetHwnd(), TB_ENABLEBUTTON
,
681 (WPARAM
)toolIndex
, (LPARAM
)MAKELONG(enable
, 0));
685 void wxToolBar95::ToggleTool(int toolIndex
, bool toggle
)
687 wxNode
*node
= m_tools
.Find((long)toolIndex
);
690 wxToolBarTool
*tool
= (wxToolBarTool
*)node
->Data();
691 if (tool
->m_isToggle
)
693 tool
->m_toggleState
= toggle
;
694 ::SendMessage(GetHwnd(), TB_CHECKBUTTON
,
695 (WPARAM
)toolIndex
, (LPARAM
)MAKELONG(toggle
, 0));
700 bool wxToolBar95::GetToolState(int toolIndex
) const
702 wxASSERT_MSG( GetIndexFromId(toolIndex
) != wxNOT_FOUND
,
703 _T("invalid toolbar button id") );
705 return ::SendMessage(GetHwnd(), TB_ISBUTTONCHECKED
,
706 (WPARAM
)toolIndex
, (LPARAM
)0) != 0;
709 // ----------------------------------------------------------------------------
711 // ----------------------------------------------------------------------------
713 // Responds to colour changes, and passes event on to children.
714 void wxToolBar95::OnSysColourChanged(wxSysColourChangedEvent
& event
)
716 m_backgroundColour
= wxColour(GetRValue(GetSysColor(COLOR_BTNFACE
)),
717 GetGValue(GetSysColor(COLOR_BTNFACE
)), GetBValue(GetSysColor(COLOR_BTNFACE
)));
724 // Propagate the event to the non-top-level children
725 wxWindow::OnSysColourChanged(event
);
728 void wxToolBar95::OnMouseEvent(wxMouseEvent
& event
)
730 if (event
.RightDown())
732 // For now, we don't have an id. Later we could
733 // try finding the tool.
734 OnRightClick((int)-1, event
.GetX(), event
.GetY());
743 // ----------------------------------------------------------------------------
745 // ----------------------------------------------------------------------------
747 int wxToolBar95::GetIndexFromId(int id
) const
749 size_t count
= m_ids
.GetCount();
750 for ( size_t n
= 0; n
< count
; n
++ )
752 if ( m_ids
[n
] == id
)
759 // ----------------------------------------------------------------------------
761 // ----------------------------------------------------------------------------
763 // These are the default colors used to map the bitmap colors to the current
764 // system colors. Note that they are in BGR format because this is what Windows
765 // wants (and not RGB)
767 #define BGR_BUTTONTEXT (RGB(000,000,000)) // black
768 #define BGR_BUTTONSHADOW (RGB(128,128,128)) // dark grey
769 #define BGR_BUTTONFACE (RGB(192,192,192)) // bright grey
770 #define BGR_BUTTONHILIGHT (RGB(255,255,255)) // white
771 #define BGR_BACKGROUNDSEL (RGB(255,000,000)) // blue
772 #define BGR_BACKGROUND (RGB(255,000,255)) // magenta
774 void wxMapBitmap(HBITMAP hBitmap
, int width
, int height
)
776 COLORMAP ColorMap
[] =
778 {BGR_BUTTONTEXT
, COLOR_BTNTEXT
}, // black
779 {BGR_BUTTONSHADOW
, COLOR_BTNSHADOW
}, // dark grey
780 {BGR_BUTTONFACE
, COLOR_BTNFACE
}, // bright grey
781 {BGR_BUTTONHILIGHT
, COLOR_BTNHIGHLIGHT
},// white
782 {BGR_BACKGROUNDSEL
, COLOR_HIGHLIGHT
}, // blue
783 {BGR_BACKGROUND
, COLOR_WINDOW
} // magenta
786 int NUM_MAPS
= (sizeof(ColorMap
)/sizeof(COLORMAP
));
788 for ( n
= 0; n
< NUM_MAPS
; n
++)
790 ColorMap
[n
].to
= ::GetSysColor(ColorMap
[n
].to
);
794 HDC hdcMem
= CreateCompatibleDC(NULL
);
798 hbmOld
= (HBITMAP
) SelectObject(hdcMem
, hBitmap
);
801 for ( i
= 0; i
< width
; i
++)
803 for ( j
= 0; j
< height
; j
++)
805 COLORREF pixel
= ::GetPixel(hdcMem
, i
, j
);
807 BYTE red = GetRValue(pixel);
808 BYTE green = GetGValue(pixel);
809 BYTE blue = GetBValue(pixel);
812 for ( k
= 0; k
< NUM_MAPS
; k
++)
814 if ( ColorMap
[k
].from
== pixel
)
816 /* COLORREF actualPixel = */ ::SetPixel(hdcMem
, i
, j
, ColorMap
[k
].to
);
824 SelectObject(hdcMem
, hbmOld
);
825 DeleteObject(hdcMem
);
830 // Some experiments...
832 // What we want to do is create another bitmap which has a depth of 4,
833 // and set the bits. So probably we want to convert this HBITMAP into a
834 // DIB, then call SetDIBits.
835 // AAAGH. The stupid thing is that if newBitmap has a depth of 4 (less than that of
836 // the screen), then SetDIBits fails.
837 HBITMAP newBitmap
= ::CreateBitmap(totalBitmapWidth
, totalBitmapHeight
, 1, 4, NULL
);
838 HANDLE newDIB
= ::BitmapToDIB((HBITMAP
) m_hBitmap
, NULL
);
839 LPBITMAPINFOHEADER lpbmi
= (LPBITMAPINFOHEADER
) GlobalLock(newDIB
);
842 // LPBITMAPINFOHEADER lpbmi = (LPBITMAPINFOHEADER) newDIB;
844 int result
= ::SetDIBits(dc
, newBitmap
, 0, lpbmi
->biHeight
, FindDIBBits((LPSTR
)lpbmi
), (LPBITMAPINFO
)lpbmi
,
846 DWORD err
= GetLastError();
848 ::ReleaseDC(NULL
, dc
);
851 GlobalUnlock (newDIB
);
854 // WXHBITMAP hBitmap2 = wxCreateMappedBitmap((WXHINSTANCE) wxGetInstance(), (WXHBITMAP) m_hBitmap);
855 // Substitute our new bitmap for the old one
856 ::DeleteObject((HBITMAP
) m_hBitmap
);
857 m_hBitmap
= (WXHBITMAP
) newBitmap
;
861 #endif // !(wxUSE_TOOLBAR && Win95)