]> git.saurik.com Git - wxWidgets.git/blob - src/msw/tbar95.cpp
Added $(NEW_WXLIBNAME) to allow changing the library or DLL name
[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 wxFAIL_MSG("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 wxFAIL_MSG("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 const wxString& help = tool->m_shortHelpString;
374
375 if ( !help.IsEmpty() )
376 {
377 if ( hdr->code == TTN_NEEDTEXTA )
378 {
379 ttText->lpszText = (char *)help.c_str();
380 }
381 #if (_WIN32_IE >= 0x0300)
382 else
383 {
384 // FIXME this is a temp hack only until I understand better what
385 // must be done in both ANSI and Unicode builds
386
387 size_t lenAnsi = help.Len();
388 #ifdef __MWERKS__
389 // MetroWerks doesn't like calling mbstowcs with NULL argument
390 size_t lenUnicode = 2*lenAnsi;
391 #else
392 size_t lenUnicode = mbstowcs(NULL, help, lenAnsi);
393 #endif
394
395 // using the pointer of right type avoids us doing all sorts of
396 // pointer arithmetics ourselves
397 wchar_t *dst = (wchar_t *)ttText->szText,
398 *pwz = new wchar_t[lenUnicode + 1];
399 mbstowcs(pwz, help, lenAnsi + 1);
400 memcpy(dst, pwz, lenUnicode*sizeof(wchar_t));
401
402 // put the terminating _wide_ NUL
403 dst[lenUnicode] = 0;
404
405 delete [] pwz;
406 }
407 #endif // _WIN32_IE >= 0x0300
408 }
409
410 // For backward compatibility...
411 OnMouseEnter(tool->m_index);
412
413 return TRUE;
414 }
415
416 void wxToolBar95::SetToolBitmapSize(const wxSize& size)
417 {
418 m_defaultWidth = size.x;
419 m_defaultHeight = size.y;
420 ::SendMessage((HWND) GetHWND(), TB_SETBITMAPSIZE, 0, (LPARAM) MAKELONG ((int)size.x, (int)size.y));
421 }
422
423 void wxToolBar95::SetRows(int nRows)
424 {
425 RECT rect;
426 ::SendMessage((HWND) GetHWND(), TB_SETROWS, MAKEWPARAM(nRows, TRUE), (LPARAM) & rect);
427 m_maxWidth = (rect.right - rect.left + 2);
428 m_maxHeight = (rect.bottom - rect.top + 2);
429 }
430
431 wxSize wxToolBar95::GetMaxSize() const
432 {
433 if ((m_maxWidth == -1) || (m_maxHeight == -1))
434 {
435 RECT rect;
436 ::SendMessage((HWND) GetHWND(), TB_SETROWS, MAKEWPARAM(m_maxRows, TRUE), (LPARAM) & rect);
437 ((wxToolBar95 *)this)->m_maxWidth = (rect.right - rect.left + 2); // ???
438 ((wxToolBar95 *)this)->m_maxHeight = (rect.bottom - rect.top + 2); // ???
439 }
440 return wxSize(m_maxWidth, m_maxHeight);
441 }
442
443 void wxToolBar95::GetSize(int *w, int *h) const
444 {
445 wxWindow::GetSize(w, h);
446 // For some reason, the returned height is several pixels bigger than that
447 // displayed!
448 // Taking this fudge factor out now, it seems fine without it.
449 // *h -= 2;
450 }
451
452 // The button size is bigger than the bitmap size
453 wxSize wxToolBar95::GetToolSize() const
454 {
455 return wxSize(m_defaultWidth + 8, m_defaultHeight + 7);
456 }
457
458 void wxToolBar95::EnableTool(int toolIndex, bool enable)
459 {
460 wxNode *node = m_tools.Find((long)toolIndex);
461 if (node)
462 {
463 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
464 tool->m_enabled = enable;
465 ::SendMessage((HWND) GetHWND(), TB_ENABLEBUTTON, (WPARAM)toolIndex, (LPARAM)MAKELONG(enable, 0));
466 }
467 }
468
469 void wxToolBar95::ToggleTool(int toolIndex, bool toggle)
470 {
471 wxNode *node = m_tools.Find((long)toolIndex);
472 if (node)
473 {
474 wxToolBarTool *tool = (wxToolBarTool *)node->Data();
475 if (tool->m_isToggle)
476 {
477 tool->m_toggleState = toggle;
478 ::SendMessage((HWND) GetHWND(), TB_CHECKBUTTON, (WPARAM)toolIndex, (LPARAM)MAKELONG(toggle, 0));
479 }
480 }
481 }
482
483 bool wxToolBar95::GetToolState(int toolIndex) const
484 {
485 return (::SendMessage((HWND) GetHWND(), TB_ISBUTTONCHECKED, (WPARAM)toolIndex, (LPARAM)0) != 0);
486 }
487
488 void wxToolBar95::ClearTools()
489 {
490 // TODO: Don't know how to reset the toolbar bitmap, as yet.
491 // But adding tools and calling CreateTools should probably
492 // recreate a buttonbar OK.
493 wxToolBarBase::ClearTools();
494 }
495
496 // If pushedBitmap is NULL, a reversed version of bitmap is
497 // created and used as the pushed/toggled image.
498 // If toggle is TRUE, the button toggles between the two states.
499 wxToolBarTool *wxToolBar95::AddTool(int index, const wxBitmap& bitmap, const wxBitmap& pushedBitmap,
500 bool toggle, long xPos, long yPos, wxObject *clientData, const wxString& helpString1, const wxString& helpString2)
501 {
502 wxToolBarTool *tool = new wxToolBarTool(index, bitmap, wxNullBitmap, toggle, xPos, yPos, helpString1, helpString2);
503 tool->m_clientData = clientData;
504
505 if (xPos > -1)
506 tool->m_x = xPos;
507 else
508 tool->m_x = m_xMargin;
509
510 if (yPos > -1)
511 tool->m_y = yPos;
512 else
513 tool->m_y = m_yMargin;
514
515 tool->SetSize(GetToolSize().x, GetToolSize().y);
516
517 m_tools.Append((long)index, tool);
518 return tool;
519 }
520
521 // Responds to colour changes, and passes event on to children.
522 void wxToolBar95::OnSysColourChanged(wxSysColourChangedEvent& event)
523 {
524 m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
525 GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
526
527 // Remap the buttons
528 CreateTools();
529
530 Default();
531
532 Refresh();
533
534 // Propagate the event to the non-top-level children
535 wxWindow::OnSysColourChanged(event);
536 }
537
538 void wxToolBar95::OnMouseEvent(wxMouseEvent& event)
539 {
540 if (event.RightDown())
541 {
542 // For now, we don't have an id. Later we could
543 // try finding the tool.
544 OnRightClick((int)-1, event.GetX(), event.GetY());
545 }
546 else
547 {
548 Default();
549 }
550 }
551
552 // These are the default colors used to map the bitmap colors
553 // to the current system colors
554
555 #define BGR_BUTTONTEXT (RGB(000,000,000)) // black
556 #define BGR_BUTTONSHADOW (RGB(128,128,128)) // dark grey
557 #define BGR_BUTTONFACE (RGB(192,192,192)) // bright grey
558 #define BGR_BUTTONHILIGHT (RGB(255,255,255)) // white
559 #define BGR_BACKGROUNDSEL (RGB(255,000,000)) // blue
560 #define BGR_BACKGROUND (RGB(255,000,255)) // magenta
561
562 void wxMapBitmap(HBITMAP hBitmap, int width, int height)
563 {
564 COLORMAP ColorMap[] = {
565 {BGR_BUTTONTEXT, COLOR_BTNTEXT}, // black
566 {BGR_BUTTONSHADOW, COLOR_BTNSHADOW}, // dark grey
567 {BGR_BUTTONFACE, COLOR_BTNFACE}, // bright grey
568 {BGR_BUTTONHILIGHT, COLOR_BTNHIGHLIGHT},// white
569 {BGR_BACKGROUNDSEL, COLOR_HIGHLIGHT}, // blue
570 {BGR_BACKGROUND, COLOR_WINDOW} // magenta
571 };
572
573 int NUM_MAPS = (sizeof(ColorMap)/sizeof(COLORMAP));
574 int n;
575 for ( n = 0; n < NUM_MAPS; n++)
576 {
577 ColorMap[n].to = ::GetSysColor(ColorMap[n].to);
578 }
579
580 HBITMAP hbmOld;
581 HDC hdcMem = CreateCompatibleDC(NULL);
582
583 if (hdcMem)
584 {
585 hbmOld = (HBITMAP) SelectObject(hdcMem, hBitmap);
586
587 int i, j, k;
588 for ( i = 0; i < width; i++)
589 {
590 for ( j = 0; j < height; j++)
591 {
592 COLORREF pixel = ::GetPixel(hdcMem, i, j);
593 /*
594 BYTE red = GetRValue(pixel);
595 BYTE green = GetGValue(pixel);
596 BYTE blue = GetBValue(pixel);
597 */
598
599 for ( k = 0; k < NUM_MAPS; k ++)
600 {
601 if ( ColorMap[k].from == pixel )
602 {
603 /* COLORREF actualPixel = */ ::SetPixel(hdcMem, i, j, ColorMap[k].to);
604 break;
605 }
606 }
607 }
608 }
609
610
611 SelectObject(hdcMem, hbmOld);
612 DeleteObject(hdcMem);
613 }
614
615 }
616
617 // Some experiments...
618 #if 0
619 // What we want to do is create another bitmap which has a depth of 4,
620 // and set the bits. So probably we want to convert this HBITMAP into a
621 // DIB, then call SetDIBits.
622 // AAAGH. The stupid thing is that if newBitmap has a depth of 4 (less than that of
623 // the screen), then SetDIBits fails.
624 HBITMAP newBitmap = ::CreateBitmap(totalBitmapWidth, totalBitmapHeight, 1, 4, NULL);
625 HANDLE newDIB = ::BitmapToDIB((HBITMAP) m_hBitmap, NULL);
626 LPBITMAPINFOHEADER lpbmi = (LPBITMAPINFOHEADER) GlobalLock(newDIB);
627
628 dc = ::GetDC(NULL);
629 // LPBITMAPINFOHEADER lpbmi = (LPBITMAPINFOHEADER) newDIB;
630
631 int result = ::SetDIBits(dc, newBitmap, 0, lpbmi->biHeight, FindDIBBits((LPSTR)lpbmi), (LPBITMAPINFO)lpbmi,
632 DIB_PAL_COLORS);
633 DWORD err = GetLastError();
634
635 ::ReleaseDC(NULL, dc);
636
637 // Delete the DIB
638 GlobalUnlock (newDIB);
639 GlobalFree (newDIB);
640
641 // WXHBITMAP hBitmap2 = wxCreateMappedBitmap((WXHINSTANCE) wxGetInstance(), (WXHBITMAP) m_hBitmap);
642 // Substitute our new bitmap for the old one
643 ::DeleteObject((HBITMAP) m_hBitmap);
644 m_hBitmap = (WXHBITMAP) newBitmap;
645 #endif
646
647
648 #endif