FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Background image?
Posts: 1402
Joined: Mon May 14, 2007 09:49 AM

Background image?

Posted: Sat Sep 26, 2026 08:25 PM

Hi !

here is an old example called xbwaterm.prg. In it, the image is set as the background of xBrowse and changes its size depending on the window size.

 aImage   := oWnd:ReadImage( "c:\fwh\bitmaps\pngs\2.png", , .t. )
 WITH OBJECT oBrw
      :lTransparent  := .t.

  :bPaintBack := < |Self|
     FillRect( ::hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
     ::DrawImage( aImage, ::DataRect():aRect, nil, nil, nAlphaLevel )
     ::lTransparent := .t.
     return nil
     >
  //
  :CreateFromCode()
   END

Can I use an image from a resource in this case?

Posts: 150
Joined: Fri Sep 25, 2026 01:40 AM

Re: Background image?

Posted: Sat Sep 26, 2026 09:41 PM

Hi Natter,

Yes. You can embed the PNG as a resource and pass its resource name to the same ReadImage() call. For example, if your .rc contains:

XB_WATERMARK RCDATA "2.png"

replace the file-path line with:

aImage := oWnd:ReadImage( "XB_WATERMARK", , .t. )

Keep the rest of bPaintBack and the PalBmpFree( aImage ) cleanup as in xbwaterm.prg. The name must match the compiled resource exactly. FW_ReadImage() looks for a named RCDATA (type 10) resource when the supplied name has no file extension; it then decodes its bytes as an image. Check that aImage[ 1 ] is not empty if the resource does not appear.

I checked this against the current FWH source, but have not compiled this particular resource variant here.

Posts: 1402
Joined: Mon May 14, 2007 09:49 AM

Re: Background image?

Posted: Sun Sep 27, 2026 12:52 PM

FiveTech AI, thank you for your help!

Continue the discussion