question about background pictures?

Is there any way to have a picture as the "background" and be able to put buttons on it? I have tried using a Static Bitmap and if I put the buttons on the panel after the bitmap, you can see them, but can't click on them, but if I put them on before the bitmap, they are able to be clicked, but you can't see them.

Thanks.

···

---------------------------------
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway - Enter today

Nat <natp13@yahoo.com> writes:

Is there any way to have a picture as the "background" and be able
to put buttons on it? I have tried using a Static Bitmap and if I
put the buttons on the panel after the bitmap, you can see them, but
can't click on them, but if I put them on before the bitmap, they
are able to be clicked, but you can't see them.

The simplest approach I've found to this sort of thing is to draw the
background bitmap yourself by handling the ERASE_BACKGROUND event, and
then drawing the background yourself as a bitmap. I didn't really
find a satisfactory way to do it with controls, in terms of
maintaining proper Z order, any tab traversal and so on.

For example, one of my frames with a custom background does this
(load_bitmap just loads the bitmap as a wxImage and uses
ConvertToBitmap() on it):

          - - - - - - - - - - - - - - - - - - - - - - - - -

class RegistrationPane(wxPanel):

    def __init__(self, options, parent, *args, **kwargs):
        wxPanel.__init__(self, parent, -1)

        self.bitmap = load_bitmap('registration.jpg')
        self.width = self.bitmap.GetWidth()
        self.height = self.bitmap.GetHeight()

        (...)
        EVT_SIZE(self, self.OnSize)
        EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)

    def OnSize(self, event):
        width, height = event.GetSize()
        self.x_offset = (width - self.width) // 2
        self.y_offset = (height - self.height) // 2
        event.Skip()
        
    def OnEraseBackground(self, event):
        dc = event.GetDC()
        if not dc:
            dc = wxClientDC(self)
        dc.SetBackground(wxWHITE_BRUSH)
        dc.Clear()
        dc.DrawBitmap(self.bitmap, self.x_offset, self.y_offset)

    (...)

          - - - - - - - - - - - - - - - - - - - - - - - - -

-- David