Page 1 of 2

xBrowse-background can be stretched ? => SOLVED

Posted: Tue Dec 02, 2008 8:17 pm
by ukoenig
Hello,

some month ago, we have been talking about xBrowse-backgrounds.
xBrowse shows the used bitmaps TILED.

Is this problem solved in the new FWH-release ?

Regards
Uwe :lol:

Posted: Tue Dec 02, 2008 10:54 pm
by Silvio
with sbrowse 6 we can

Posted: Thu Dec 04, 2008 6:23 am
by Daniel Garcia-Gil
ukoenig...

i did a little trick...

modify xbrowse class

1-. put in define place..

Code: Select all | Expand

#define SRCCOPY      0x00CC0020 


2-. put at end_of_file but before #pragma BEGINDUMP

Code: Select all | Expand

DLL32 FUNCTION CreateCompatibleBitmap( hDC AS LONG, nWidth AS LONG, nHeight AS LONG ) AS LONG ;
      PASCAL FROM "CreateCompatibleBitmap" LIB "gdi32.dll"


3.- 2 new data

Code: Select all | Expand

DATA cBmpAdjBrush     // BMP file/resource
DATA lBrushed      AS LOGICAL INIT .F. // used internally for check brush


4.- and last step... the trick!
method paint put after variable declare this line

Code: Select all | Expand

local hBmpDC, hDCComp, hOldBitMap, hBmp, hBmpNew

if ::cBmpAdjBrush != NIL .and. !::lBrushed
  ::lBrushed := .t.   
  ::lTransparent := .t.    
  if valtype( ::cBmpAdjBrush ) == "C"
    if '.' $ ::cBmpAdjBrush
      if upper( right( ::cBmpAdjBrush, 3 ) ) == "BMP"
        if file( ::cBmpAdjBrush )
          hBmp := ReadBitmap( 0, ::cBmpAdjBrush )
        else
          msgstop( "File " + ::cBmpAdjBrush + " not Found","Fivewin: Class TXBrowse" )
          return( 0 )
        endif
      else
        msgstop( "Bad BMP File format","Fivewin: Class TXBrowse" )
        return( 0 )
      endif
    else
      if ( hBmp := LoadBitmap( GetResources(), ::cBmpAdjBrush ) ) == 0
        msgstop( "Resource " + ::cBmpAdjBrush + " No Found", "Fivewin: Class TXBrowse" )
        return( 0 )
      endif
    endif
  else
    msgstop( "Only BMP File or Resource","Fivewin: Class TXBrowse" )
    return( 0 )
  endif
  PalBmpDraw( ::hDC, 0, 0, hBmp,, (::nRight - ::nLeft), ( ::nBottom - ::nTop ) )
  ::lBrushed    := .t.
  hDCComp       := CreateCDC( ::hDC )
  hBmpNew         := CreateCompatibleBitMap( ::hDC, ::oWnd:nWidth, ::oWnd:nHeight )
  holdBitMap    := selectobject( hdccomp, hBmpNew )
  BitBlt( hDCComp, 0, 0, ::oWnd:nWidth, ::oWnd:nHeight, ::hDC, 0, 0, SRCCOPY )
  selectobject( hBmpNew, hOldBitMap )
  ::lTransparent := .t.
  ::Refresh()
  ::oBrush:hBrush:=CreatePatternBrush( hBmpNew )
  DeleteObject( hBmp )
endif



example
oBrw:cBmpAdjBrush := "C:\FWH\BITMAPS\back.bmp"
oBrw:SetBackGround("C:\FWH\BITMAPS\back.bmp" )

always write both lines oBrw:cBmpAdjBrush and oBrw:SetBackGround() remember you can use resources too

Posted: Thu Dec 04, 2008 9:07 am
by Silvio
Application
===========
Path and name: C:\work\LIB_32\xbrowse\xbrowse.Exe (32 bits)
Size: 1,641,472 bytes
Time from start: 0 hours 0 mins 21 secs
Error occurred at: 12/04/08, 10:08:26
Error description: Error BASE/1004 Message not found: TXBROWSE:SETBACKGROUND

Stack Calls
===========
Called from: tobject.prg => TXBROWSE:ERROR(172)
Called from: tobject.prg => TXBROWSE:MSGNOTFOUND(205)
Called from: tobject.prg => TXBROWSE:SETBACKGROUND(0)
Called from: testxbr2.prg => AUTOEDIT(66)
Called from: testxbr2.prg => (b)BUILDMENU(39)
Called from: MENU.PRG => TMENU:COMMAND(0)
Called from: WINDOW.PRG => TWINDOW:COMMAND(0)
Called from: MDIFRAME.PRG => TMDIFRAME:COMMAND(0)
Called from: => TMDIFRAME:HANDLEEVENT(0)
Called from: WINDOW.PRG => _FWH(0)
Called from: => WINRUN(0)
Called from: WINDOW.PRG => TMDIFRAME:ACTIVATE(0)
Called from: testxbr2.prg => MAIN(24)

Posted: Thu Dec 04, 2008 9:13 am
by Silvio
Image


I 'm using only
oBrw:cBmpAdjBrush :="BACK.bmp"

New Function ?

Posted: Thu Dec 04, 2008 10:07 am
by ukoenig
Hello Silvio,

I think, < oLbx:cBmpAdjBrush > is added ( new ) in FWH-version 8.10
I work with FWH 8.09 and get a error ?

oLbx:cBmpAdjBrush :="BLUESTONE.bmp"

Regards
Uwe :lol:

Posted: Thu Dec 04, 2008 2:46 pm
by Daniel Garcia-Gil
if you use oBrw:cBmpAdjBrush :="BACK.bmp" without oBrw:SetBackGround() i think will have trouble with paint...
please, stay alert with it

New => cBmpAdjBrush ?

Posted: Thu Dec 04, 2008 7:21 pm
by ukoenig
Hello,

It is a compile-error not function-error.
< cBmpAdjBrush > doesn't exist.

oLbx:cBmpAdjBrush

I think it is new.

Regards
Uwe :lol:

Posted: Thu Dec 04, 2008 7:28 pm
by Daniel Garcia-Gil
yes is new data, made for me... you need modify class txbroswe
please review my post

Stretch BMP to xBrowse Data-area

Posted: Thu Dec 04, 2008 8:54 pm
by ukoenig
Hello,

I added the lines to xBrowse.prg. The compile runs without error.

With the extra lines :
oLbx1:cBmpAdjBrush := "view.bmp"
oLbx1:SetBackGround("view.bmp" )
I get a black background inside the browser.

I tested without < oLbx1:SetBackGround >.
The BMP-background is shown, but not adjusted to the
Data-area of the browser.

I changed Your line :

* PalBmpDraw( ::hDC, 0, 0, hBmp,, (::nRight - ::nLeft), ( ::nBottom - ::nTop ) )

in :

PalBmpDraw( ::hDC, 0, 0, hBmp,, ::BrwWidth(), ::BrwHeight() )

That works perfect now !
If You change this, the BMP is adjusted to the xbrowse data-area.

Regards
Uwe :lol:

Posted: Thu Dec 04, 2008 9:41 pm
by Daniel Garcia-Gil
thank a lot... little detail
the idea is good... i happy it work for you.... i did burn my brain :wink:

change too...
hBmpNew := CreateCompatibleBitMap( ::hDC, ::BrwWidth(), ::BrwHeight() )
BitBlt( hDCComp, 0, 0, ::BrwWidth(),::BrwHeight(), ::hDC, 0, 0, SRCCOPY )

xBrowse-background

Posted: Thu Dec 04, 2008 9:58 pm
by ukoenig
Hello MC,

Thanks a lot.

The Testfiles : EXE, RC, TESTFOLDER.prg
http://www.pflegeplus.com/fw_downloads/testbrowse.zip

A sample :

Image

Like You can see, the balls are adjusted to the browser.

Another sample :
I used the Background-tools, created a gradient and saved it as bitmap.

Image

Now it is very simple :

Adjusted background :
oLbx1:cBmpAdjBrush := "3D.bmp" // It is 24-Bit

Tiled Background :
oLbx1:SetBackGround("view.bmp" )

A small thing I noticed after some tests :

Two Browsers in Folder-page 1
oLbx1:cBmpAdjBrush := "Gradient1.bmp"
oLbx2:cBmpAdjBrush := "3Dball.bmp"
oLbx1 shows < 3Dball.bmp > background as well.

Inside the second folder-page
oLbx3:cBmpAdjBrush := "Gradient1.bmp"

I open the dialog.
Folder-page one shows < 3Dball.bmp >
I change to folder-page 2
The browser shows < Gradient1.bmp >

Going back to folder-page 1
oLbx1 and oLbx2 changed from < 3Dball.bmp > to < Gradient1.bmp >
It seems, allways the last selected BMP is activated.

Regards
Uwe :lol:

Bitmap-size

Posted: Fri Dec 05, 2008 6:07 pm
by ukoenig
Hello Daniel,
A fine adjustment, to fit the bitmap to the xbrowse-data-area.
( Adjustment to the record-selector-width, header and footer )
I noticed it, because the ball wasn't centered.

Complete adjustment :
Image

Code: Select all | Expand

PalBmpDraw(::hDC,::HeaderHeight(),RECORDSELECTOR_WIDTH, hBmp,, ;
::BrwWidth()- RECORDSELECTOR_WIDTH,::BrwHeight() -::FooterHeight() )
::lBrushed := .t.
hDCComp := CreateCDC(::hDC )
hBmpNew := CreateCompatibleBitMap(::hDC,::BrwWidth(),::BrwHeight()-::FooterHeight())
holdBitMap := selectobject(hdccomp,hBmpNew)
BitBlt( hDCComp,::HeaderHeight(),RECORDSELECTOR_WIDTH,::BrwWidth(), ;
::BrwHeight(),::hDC,::HeaderHeight(),RECORDSELECTOR_WIDTH, SRCCOPY )


Regards
Uwe :lol:

Posted: Fri Dec 05, 2008 6:16 pm
by Daniel Garcia-Gil
good idea...
for more easy reader dont use "25" use RECORDSELECTOR_WIDTH

Adjustment

Posted: Fri Dec 05, 2008 6:48 pm
by ukoenig
Hello Daniel,
some more adjustments.

Code: Select all | Expand

PalBmpDraw(::hDC,::HeaderHeight(),RECORDSELECTOR_WIDTH, hBmp,, ;
::BrwWidth()- RECORDSELECTOR_WIDTH,::BrwHeight() -::FooterHeight() )
::lBrushed := .t.
hDCComp := CreateCDC(::hDC )
hBmpNew := CreateCompatibleBitMap(::hDC,::BrwWidth(),::BrwHeight()-::FooterHeight())
holdBitMap := selectobject(hdccomp,hBmpNew)
BitBlt( hDCComp,::HeaderHeight(),RECORDSELECTOR_WIDTH,::BrwWidth(), ;
::BrwHeight(),::hDC,::HeaderHeight(),RECORDSELECTOR_WIDTH, SRCCOPY )


Regards
Uwe :lol: