- m_messageBitmap = bitmap;
- SetName(name);
- if (parent) parent->AddChild(this);
-
- m_backgroundColour = parent->GetDefaultBackgroundColour() ;
- m_foregroundColour = parent->GetDefaultForegroundColour() ;
-
- if ( id == -1 )
- m_windowId = (int)NewControlId();
- else
- m_windowId = id;
-
- int x = pos.x;
- int y = pos.y;
- int width = size.x;
- int height = size.y;
-
- if ( width < 0 && bitmap.Ok() )
- width = bitmap.GetWidth();
- if ( height < 0 && bitmap.Ok() )
- height = bitmap.GetHeight();
-
- m_windowStyle = style;
-
- // Use an ownerdraw button to produce a static bitmap, since there's
- // no ownerdraw static.
- // TODO: perhaps this should be a static item, with style SS_BITMAP.
- HWND static_item =
- CreateWindowEx(0, "BUTTON", "", BS_OWNERDRAW | WS_TABSTOP | WS_CHILD,
- 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
- wxGetInstance(), NULL);
- m_hWnd = (WXHWND) static_item;
-
- // Subclass again for purposes of dialog editing mode
- SubclassWin((WXHWND) static_item);
- SetSize(x, y, width, height);
- return TRUE;
+ if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
+ return FALSE;
+
+ // we may have either bitmap or icon: if a bitmap with mask is passed, we
+ // will transform it to an icon ourselves because otherwise the mask will
+ // be ignored by Windows
+ wxGDIImage *image = (wxGDIImage *)NULL;
+ m_isIcon = bitmap.IsKindOf(CLASSINFO(wxIcon));
+
+#ifdef __WIN16__
+ wxASSERT_MSG( !m_isIcon, "Icons are not supported in wxStaticBitmap under WIN16." );
+ image = &bitmap;
+#else // Win32
+ image = ConvertImage( bitmap );
+ m_isIcon = image->IsKindOf( CLASSINFO(wxIcon) );
+#endif // Win16/32
+
+ // create the native control
+ if ( !MSWCreateControl(
+#ifdef __WIN32__
+ _T("STATIC"),
+#else // Win16
+ _T("BUTTON"),
+#endif // Win32/16
+ _T(""), pos, size) )
+ {
+ // control creation failed
+ return FALSE;
+ }
+
+ // no need to delete the new image
+ SetImageNoCopy(image);
+
+ return TRUE;