]> git.saurik.com Git - wxWidgets.git/blob - src/msw/tbar95.cpp
Doc mods; fixed return non-processing problem; fixed toolbar sizing problems
[wxWidgets.git] / src / msw / tbar95.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: tbar95.cpp
3 // Purpose: wxToolBar95
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "tbar95.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/wx.h"
25 #endif
26
27 #if wxUSE_BUTTONBAR && wxUSE_TOOLBAR && defined(__WIN95__)
28
29 #if !defined(__GNUWIN32__) && !defined(__SALFORDC__)
30 #include "malloc.h"
31 #endif
32
33 #include <windows.h>
34
35 #if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__)
36 #include <commctrl.h>
37 #endif
38
39 #ifndef __TWIN32__
40 #ifdef __GNUWIN32__
41 #include "wx/msw/gnuwin32/extra.h"
42 #endif
43 #endif
44
45 #include "wx/msw/dib.h"
46 #include "wx/tbar95.h"
47 #include "wx/app.h"
48 #include "wx/msw/private.h"
49
50 // Styles
51 #ifndef TBSTYLE_FLAT
52 #define TBSTYLE_LIST 0x1000
53 #define TBSTYLE_FLAT 0x0800
54 #define TBSTYLE_TRANSPARENT 0x8000
55 #endif
56 // use TBSTYLE_TRANSPARENT if you use TBSTYLE_FLAT
57
58 // Messages
59 #ifndef TB_GETSTYLE
60 #define TB_GETSTYLE (WM_USER + 57)
61 #define TB_SETSTYLE (WM_USER + 56)
62 #endif
63
64 /* Hint from a newsgroup for custom flatbar drawing:
65 Set the TBSTYLE_CUSTOMERASE style, then handle the
66 NM_CUSTOMDRAW message and do your custom drawing.
67 */
68
69 #define DEFAULTBITMAPX 16
70 #define DEFAULTBITMAPY 15
71 #define DEFAULTBUTTONX 24
72 #define DEFAULTBUTTONY 24
73 #define DEFAULTBARHEIGHT 27
74
75 #if !USE_SHARED_LIBRARY
76 IMPLEMENT_DYNAMIC_CLASS(wxToolBar95, wxToolBarBase)
77 #endif
78
79 BEGIN_EVENT_TABLE(wxToolBar95, wxToolBarBase)
80 EVT_SIZE(wxToolBar95::OnSize)
81 EVT_PAINT(wxToolBar95::OnPaint)
82 EVT_MOUSE_EVENTS(wxToolBar95::OnMouseEvent)
83 EVT_KILL_FOCUS(wxToolBar95::OnKillFocus)
84 EVT_SYS_COLOUR_CHANGED(wxToolBar95::OnSysColourChanged)
85 END_EVENT_TABLE()
86
87 static void wxMapBitmap(HBITMAP hBitmap, int width, int height);
88
89 wxToolBar95::wxToolBar95()
90 {
91 m_maxWidth = -1;
92 m_maxHeight = -1;
93 m_hBitmap = 0;
94 m_defaultWidth = DEFAULTBITMAPX;
95 m_defaultHeight = DEFAULTBITMAPY;
96 }
97
98 bool wxToolBar95::Create(wxWindow *parent,
99 wxWindowID id,
100 const wxPoint& pos,
101 const wxSize& size,
102 long style,
103 const wxString& name)
104 {
105 m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
106 GetGValue(GetSysColor(COLOR_BTNFACE)),
107 GetBValue(GetSysColor(COLOR_BTNFACE)));
108 m_foregroundColour = *wxBLACK ;
109
110 wxASSERT_MSG( (style & wxTB_VERTICAL) == 0,
111 "Sorry, wxToolBar95 under Windows 95 only "
112 "supports horizontal orientation." );
113
114 m_maxWidth = -1;
115 m_maxHeight = -1;
116
117 m_hBitmap = 0;
118
119 m_defaultWidth = DEFAULTBITMAPX;
120 m_defaultHeight = DEFAULTBITMAPY;
121 SetName(name);
122
123 m_windowStyle = style;
124
125 SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
126 SetParent(parent);
127
128 int x = pos.x;
129 int y = pos.y;
130 int width = size.x;
131 int height = size.y;
132
133 if (width <= 0)
134 width = 100;
135 if (height <= 0)
136 height = 30;
137 if (x < 0)
138 x = 0;
139 if (y < 0)
140 y = 0;
141
142 m_windowId = (id < 0 ? NewControlId() : id);
143 DWORD msflags = 0;
144 if (style & wxBORDER)
145 msflags |= WS_BORDER;
146 msflags |= WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS;
147
148 if (style & wxTB_FLAT)
149 {
150 if (wxTheApp->GetComCtl32Version() > 400)
151 msflags |= TBSTYLE_FLAT;
152 }
153
154 bool want3D;
155 WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
156
157 // Even with extended styles, need to combine with WS_BORDER
158 // for them to look right.
159 if ( want3D || wxStyleHasBorder(m_windowStyle) )
160 msflags |= WS_BORDER;
161
162 // Create the toolbar control.
163 HWND hWndToolbar = CreateWindowEx
164 (
165 exStyle, // Extended styles.
166 TOOLBARCLASSNAME, // Class name for the toolbar.
167 "", // No default text.
168 msflags, // Styles
169 x, y, width, height, // Standard toolbar size and position.
170 (HWND) parent->GetHWND(), // Parent window of the toolbar.
171 (HMENU)m_windowId, // Toolbar ID.
172 wxGetInstance(), // Current instance.
173 NULL // No class data.
174 );
175
176 wxCHECK_MSG( hWndToolbar, FALSE, "Toolbar creation failed" );
177
178 // Toolbar-specific initialisation
179 ::SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE,
180 (WPARAM)sizeof(TBBUTTON), (LPARAM)0);
181
182 m_hWnd = (WXHWND) hWndToolbar;
183 if (parent)
184 parent->AddChild(this);
185
186 SubclassWin((WXHWND)hWndToolbar);
187
188 return TRUE;
189 }
190
191 wxToolBar95::~wxToolBar95()
192 {
193 UnsubclassWin();
194
195 if (m_hBitmap)
196 {
197 ::DeleteObject((HBITMAP) m_hBitmap);
198 m_hBitmap = 0;
199 }
200 }
201
202 bool wxToolBar95::CreateTools()
203 {
204 if (m_tools.Number() == 0)
205 return FALSE;
206
207 HBITMAP oldToolBarBitmap = (HBITMAP) m_hBitmap;
208
209 int totalBitmapWidth = (int)(m_defaultWidth * m_tools.Number());
210 int totalBitmapHeight = (int)m_defaultHeight;
211
212 // Create a bitmap for all the tool bitmaps
213 HDC dc = ::GetDC(NULL);
214 m_hBitmap = (WXHBITMAP) ::CreateCompatibleBitmap(dc, totalBitmapWidth, totalBitmapHeight);
215 ::ReleaseDC(NULL, dc);
216
217 // Now blit all the tools onto this bitmap
218 HDC memoryDC = ::CreateCompatibleDC(NULL);
219 HBITMAP oldBitmap = (HBITMAP) ::SelectObject(memoryDC, (HBITMAP) m_hBitmap);
220
221 HDC memoryDC2 = ::CreateCompatibleDC(NULL);
222 int x = 0;
223 wxNode *node = m_tools.First();
224 int noButtons = 0;
225 while (node)
226 {
227 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
228 if ((tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR) && tool->m_bitmap1.Ok() && tool->m_bitmap1.GetHBITMAP())
229 {
230 // wxPalette *palette = tool->m_bitmap1->GetPalette();
231
232 HBITMAP oldBitmap2 = (HBITMAP) ::SelectObject(memoryDC2, (HBITMAP) tool->m_bitmap1.GetHBITMAP());
233 /* int bltResult = */
234 BitBlt(memoryDC, x, 0, (int) m_defaultWidth, (int) m_defaultHeight, memoryDC2,
235 0, 0, SRCCOPY);
236 ::SelectObject(memoryDC2, oldBitmap2);
237 x += (int)m_defaultWidth;
238 noButtons ++;
239 }
240 node = node->Next();
241 }
242 ::SelectObject(memoryDC, oldBitmap);
243 ::DeleteDC(memoryDC);
244 ::DeleteDC(memoryDC2);
245
246 // Map to system colours
247 wxMapBitmap((HBITMAP) m_hBitmap, totalBitmapWidth, totalBitmapHeight);
248
249 if ( oldToolBarBitmap )
250 {
251 TBREPLACEBITMAP replaceBitmap;
252 replaceBitmap.hInstOld = NULL;
253 replaceBitmap.hInstNew = NULL;
254 replaceBitmap.nIDOld = (UINT) oldToolBarBitmap;
255 replaceBitmap.nIDNew = (UINT) (HBITMAP) m_hBitmap;
256 replaceBitmap.nButtons = noButtons;
257 if (::SendMessage((HWND) GetHWND(), TB_REPLACEBITMAP, (WPARAM) 0, (LPARAM) &replaceBitmap) == -1)
258 wxMessageBox("Could not add bitmap to toolbar");
259
260 ::DeleteObject((HBITMAP) oldToolBarBitmap);
261
262 // Now delete all the buttons
263 int i = 0;
264 while ( TRUE )
265 {
266 // TODO: What about separators???? They don't have an id!
267 if ( ! ::SendMessage( (HWND) GetHWND(), TB_DELETEBUTTON, i, 0 ) )
268 break;
269 }
270 }
271 else
272 {
273 TBADDBITMAP addBitmap;
274 addBitmap.hInst = 0;
275 addBitmap.nID = (UINT)m_hBitmap;
276 if (::SendMessage((HWND) GetHWND(), TB_ADDBITMAP, (WPARAM) noButtons, (LPARAM) &addBitmap) == -1)
277 wxMessageBox("Could not add bitmap to toolbar");
278 }
279
280 // Now add the buttons.
281 TBBUTTON buttons[50];
282
283 node = m_tools.First();
284 int i = 0;
285 int bitmapId = 0;
286 while (node)
287 {
288 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
289 if (tool->m_toolStyle == wxTOOL_STYLE_SEPARATOR)
290 {
291 buttons[i].iBitmap = 0;
292 buttons[i].idCommand = 0;
293
294 buttons[i].fsState = TBSTATE_ENABLED;
295 buttons[i].fsStyle = TBSTYLE_SEP;
296 buttons[i].dwData = 0L;
297 buttons[i].iString = 0;
298 }
299 else
300 {
301 buttons[i].iBitmap = bitmapId;
302 buttons[i].idCommand = tool->m_index;
303
304 buttons[i].fsState = 0;
305 if (tool->m_enabled)
306 buttons[i].fsState |= TBSTATE_ENABLED;
307 if (tool->m_toggleState)
308 buttons[i].fsState |= TBSTATE_CHECKED;
309 buttons[i].fsStyle = tool->m_isToggle ? TBSTYLE_CHECK : TBSTYLE_BUTTON;
310 buttons[i].dwData = 0L;
311 buttons[i].iString = 0;
312
313 bitmapId ++;
314 }
315
316 i ++;
317 node = node->Next();
318 }
319
320 long rc = ::SendMessage((HWND) GetHWND(), TB_ADDBUTTONS, (WPARAM)i, (LPARAM)& buttons);
321
322 wxCHECK_MSG( rc, FALSE, "failed to add buttons to the toolbar" );
323
324 (void)::SendMessage((HWND) GetHWND(), TB_AUTOSIZE, (WPARAM)0, (LPARAM) 0);
325
326 SetRows(m_maxRows);
327
328 return TRUE;
329 }
330
331 bool wxToolBar95::MSWCommand(WXUINT cmd, WXWORD id)
332 {
333 wxNode *node = m_tools.Find((long)id);
334 if (!node)
335 return FALSE;
336 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
337 if (tool->m_isToggle)
338 tool->m_toggleState = (1 == (1 & (int)::SendMessage((HWND) GetHWND(), TB_GETSTATE, (WPARAM) id, (LPARAM) 0)));
339
340 BOOL ret = OnLeftClick((int)id, tool->m_toggleState);
341 if (ret == FALSE && tool->m_isToggle)
342 {
343 tool->m_toggleState = !tool->m_toggleState;
344 ::SendMessage((HWND) GetHWND(), TB_CHECKBUTTON, (WPARAM)id, (LPARAM)MAKELONG(tool->m_toggleState, 0));
345 }
346 return TRUE;
347 }
348
349 bool wxToolBar95::MSWNotify(WXWPARAM WXUNUSED(wParam),
350 WXLPARAM lParam,
351 WXLPARAM *result)
352 {
353 // First check if this applies to us
354 NMHDR *hdr = (NMHDR *)lParam;
355
356 // the tooltips control created by the toolbar is sometimes Unicode, even in
357 // an ANSI application
358 if ( (hdr->code != TTN_NEEDTEXTA) && (hdr->code != TTN_NEEDTEXTW) )
359 return FALSE;
360
361 HWND toolTipWnd = (HWND)::SendMessage((HWND)GetHWND(), TB_GETTOOLTIPS, 0, 0);
362 if ( toolTipWnd != hdr->hwndFrom )
363 return FALSE;
364
365 LPTOOLTIPTEXT ttText = (LPTOOLTIPTEXT)lParam;
366 int id = (int)ttText->hdr.idFrom;
367 wxNode *node = m_tools.Find((long)id);
368 if (!node)
369 return FALSE;
370
371 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
372
373 if ( tool->m_shortHelpString != "" )
374 {
375 if ( hdr->code == TTN_NEEDTEXTA )
376 {
377 ttText->lpszText = (char *)(const char *)tool->m_shortHelpString;
378 }
379 #if (_WIN32_IE >= 0x0300)
380 else
381 {
382 // FIXME this is a temp hack only until I understand better what
383 // must be done in both ANSI and Unicode builds
384 size_t lenAnsi = tool->m_shortHelpString.Len();
385 #ifdef __MWERKS__
386 wchar_t *pwz = new wchar_t[lenAnsi * 2 + 1];
387 #else
388 size_t lenUnicode = mbstowcs(NULL, tool->m_shortHelpString, lenAnsi);
389 wchar_t *pwz = new wchar_t[lenUnicode + 1];
390 #endif
391 mbstowcs(pwz, tool->m_shortHelpString, lenAnsi + 1);
392 memcpy(ttText->szText, pwz,
393 (sizeof(ttText->szText) - 1)/sizeof(ttText->szText[0]));
394 ttText->szText[WXSIZEOF(ttText->szText)] = 0;
395
396 delete [] pwz;
397 }
398 #endif // _WIN32_IE >= 0x0300
399 }
400
401 // For backward compatibility...
402 OnMouseEnter(tool->m_index);
403
404 return TRUE;
405 }
406
407 void wxToolBar95::SetToolBitmapSize(const wxSize& size)
408 {
409 m_defaultWidth = size.x;
410 m_defaultHeight = size.y;
411 ::SendMessage((HWND) GetHWND(), TB_SETBITMAPSIZE, 0, (LPARAM) MAKELONG ((int)size.x, (int)size.y));
412 }
413
414 void wxToolBar95::SetRows(int nRows)
415 {
416 RECT rect;
417 ::SendMessage((HWND) GetHWND(), TB_SETROWS, MAKEWPARAM(nRows, TRUE), (LPARAM) & rect);
418 m_maxWidth = (rect.right - rect.left + 2);
419 m_maxHeight = (rect.bottom - rect.top + 2);
420 }
421
422 wxSize wxToolBar95::GetMaxSize() const
423 {
424 if ((m_maxWidth == -1) || (m_maxHeight == -1))
425 {
426 RECT rect;
427 ::SendMessage((HWND) GetHWND(), TB_SETROWS, MAKEWPARAM(m_maxRows, TRUE), (LPARAM) & rect);
428 ((wxToolBar95 *)this)->m_maxWidth = (rect.right - rect.left + 2); // ???
429 ((wxToolBar95 *)this)->m_maxHeight = (rect.bottom - rect.top + 2); // ???
430 }
431 return wxSize(m_maxWidth, m_maxHeight);
432 }
433
434 void wxToolBar95::GetSize(int *w, int *h) const
435 {
436 wxWindow::GetSize(w, h);
437 // For some reason, the returned height is several pixels bigger than that
438 // displayed!
439 // Taking this fudge factor out now, it seems fine without it.
440 // *h -= 2;
441 }
442
443 // The button size is bigger than the bitmap size
444 wxSize wxToolBar95::GetToolSize() const
445 {
446 return wxSize(m_defaultWidth + 8, m_defaultHeight + 7);
447 }
448
449 void wxToolBar95::EnableTool(int toolIndex, bool enable)
450 {
451 wxNode *node = m_tools.Find((long)toolIndex);
452 if (node)
453 {
454 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
455 tool->m_enabled = enable;
456 ::SendMessage((HWND) GetHWND(), TB_ENABLEBUTTON, (WPARAM)toolIndex, (LPARAM)MAKELONG(enable, 0));
457 }
458 }
459
460 void wxToolBar95::ToggleTool(int toolIndex, bool toggle)
461 {
462 wxNode *node = m_tools.Find((long)toolIndex);
463 if (node)
464 {
465 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
466 if (tool->m_isToggle)
467 {
468 tool->m_toggleState = toggle;
469 ::SendMessage((HWND) GetHWND(), TB_CHECKBUTTON, (WPARAM)toolIndex, (LPARAM)MAKELONG(toggle, 0));
470 }
471 }
472 }
473
474 bool wxToolBar95::GetToolState(int toolIndex) const
475 {
476 return (::SendMessage((HWND) GetHWND(), TB_ISBUTTONCHECKED, (WPARAM)toolIndex, (LPARAM)0) != 0);
477 }
478
479 void wxToolBar95::ClearTools()
480 {
481 // TODO: Don't know how to reset the toolbar bitmap, as yet.
482 // But adding tools and calling CreateTools should probably
483 // recreate a buttonbar OK.
484 wxToolBarBase::ClearTools();
485 }
486
487 // If pushedBitmap is NULL, a reversed version of bitmap is
488 // created and used as the pushed/toggled image.
489 // If toggle is TRUE, the button toggles between the two states.
490 wxToolBarTool *wxToolBar95::AddTool(int index, const wxBitmap& bitmap, const wxBitmap& pushedBitmap,
491 bool toggle, long xPos, long yPos, wxObject *clientData, const wxString& helpString1, const wxString& helpString2)
492 {
493 wxToolBarTool *tool = new wxToolBarTool(index, bitmap, wxNullBitmap, toggle, xPos, yPos, helpString1, helpString2);
494 tool->m_clientData = clientData;
495
496 if (xPos > -1)
497 tool->m_x = xPos;
498 else
499 tool->m_x = m_xMargin;
500
501 if (yPos > -1)
502 tool->m_y = yPos;
503 else
504 tool->m_y = m_yMargin;
505
506 tool->SetSize(GetToolSize().x, GetToolSize().y);
507
508 m_tools.Append((long)index, tool);
509 return tool;
510 }
511
512 // Responds to colour changes, and passes event on to children.
513 void wxToolBar95::OnSysColourChanged(wxSysColourChangedEvent& event)
514 {
515 m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
516 GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
517
518 // Remap the buttons
519 CreateTools();
520
521 Default();
522
523 Refresh();
524
525 // Propagate the event to the non-top-level children
526 wxWindow::OnSysColourChanged(event);
527 }
528
529 void wxToolBar95::OnMouseEvent(wxMouseEvent& event)
530 {
531 if (event.RightDown())
532 {
533 // For now, we don't have an id. Later we could
534 // try finding the tool.
535 OnRightClick((int)-1, event.GetX(), event.GetY());
536 }
537 else
538 {
539 Default();
540 }
541 }
542
543 // These are the default colors used to map the bitmap colors
544 // to the current system colors
545
546 #define BGR_BUTTONTEXT (RGB(000,000,000)) // black
547 #define BGR_BUTTONSHADOW (RGB(128,128,128)) // dark grey
548 #define BGR_BUTTONFACE (RGB(192,192,192)) // bright grey
549 #define BGR_BUTTONHILIGHT (RGB(255,255,255)) // white
550 #define BGR_BACKGROUNDSEL (RGB(255,000,000)) // blue
551 #define BGR_BACKGROUND (RGB(255,000,255)) // magenta
552
553 void wxMapBitmap(HBITMAP hBitmap, int width, int height)
554 {
555 COLORMAP ColorMap[] = {
556 {BGR_BUTTONTEXT, COLOR_BTNTEXT}, // black
557 {BGR_BUTTONSHADOW, COLOR_BTNSHADOW}, // dark grey
558 {BGR_BUTTONFACE, COLOR_BTNFACE}, // bright grey
559 {BGR_BUTTONHILIGHT, COLOR_BTNHIGHLIGHT},// white
560 {BGR_BACKGROUNDSEL, COLOR_HIGHLIGHT}, // blue
561 {BGR_BACKGROUND, COLOR_WINDOW} // magenta
562 };
563
564 int NUM_MAPS = (sizeof(ColorMap)/sizeof(COLORMAP));
565 int n;
566 for ( n = 0; n < NUM_MAPS; n++)
567 {
568 ColorMap[n].to = ::GetSysColor(ColorMap[n].to);
569 }
570
571 HBITMAP hbmOld;
572 HDC hdcMem = CreateCompatibleDC(NULL);
573
574 if (hdcMem)
575 {
576 hbmOld = (HBITMAP) SelectObject(hdcMem, hBitmap);
577
578 int i, j, k;
579 for ( i = 0; i < width; i++)
580 {
581 for ( j = 0; j < height; j++)
582 {
583 COLORREF pixel = ::GetPixel(hdcMem, i, j);
584 /*
585 BYTE red = GetRValue(pixel);
586 BYTE green = GetGValue(pixel);
587 BYTE blue = GetBValue(pixel);
588 */
589
590 for ( k = 0; k < NUM_MAPS; k ++)
591 {
592 if ( ColorMap[k].from == pixel )
593 {
594 /* COLORREF actualPixel = */ ::SetPixel(hdcMem, i, j, ColorMap[k].to);
595 break;
596 }
597 }
598 }
599 }
600
601
602 SelectObject(hdcMem, hbmOld);
603 DeleteObject(hdcMem);
604 }
605
606 }
607
608 // Some experiments...
609 #if 0
610 // What we want to do is create another bitmap which has a depth of 4,
611 // and set the bits. So probably we want to convert this HBITMAP into a
612 // DIB, then call SetDIBits.
613 // AAAGH. The stupid thing is that if newBitmap has a depth of 4 (less than that of
614 // the screen), then SetDIBits fails.
615 HBITMAP newBitmap = ::CreateBitmap(totalBitmapWidth, totalBitmapHeight, 1, 4, NULL);
616 HANDLE newDIB = ::BitmapToDIB((HBITMAP) m_hBitmap, NULL);
617 LPBITMAPINFOHEADER lpbmi = (LPBITMAPINFOHEADER) GlobalLock(newDIB);
618
619 dc = ::GetDC(NULL);
620 // LPBITMAPINFOHEADER lpbmi = (LPBITMAPINFOHEADER) newDIB;
621
622 int result = ::SetDIBits(dc, newBitmap, 0, lpbmi->biHeight, FindDIBBits((LPSTR)lpbmi), (LPBITMAPINFO)lpbmi,
623 DIB_PAL_COLORS);
624 DWORD err = GetLastError();
625
626 ::ReleaseDC(NULL, dc);
627
628 // Delete the DIB
629 GlobalUnlock (newDIB);
630 GlobalFree (newDIB);
631
632 // WXHBITMAP hBitmap2 = wxCreateMappedBitmap((WXHINSTANCE) wxGetInstance(), (WXHBITMAP) m_hBitmap);
633 // Substitute our new bitmap for the old one
634 ::DeleteObject((HBITMAP) m_hBitmap);
635 m_hBitmap = (WXHBITMAP) newBitmap;
636 #endif
637
638
639 #endif