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