FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Possible, to replace a BMP in BTNBMP at Runtime ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Possible, to replace a BMP in BTNBMP at Runtime ?
Posted: Sun May 10, 2009 03:12 PM
Hello,

Is it possible to replace / change a Bitmap for a Button ( BTNBMP ) at runtime ?
Inside my Setup-section, I want to display a new selected Bitmap for a defined Button.
It works with REDEFINE BITMAP but using BTNBMP, the Button is not repainted.
Code (fw): Select all Collapse
// 1. Button
// --------------
REDEFINE BTNBMP oBtn81 ID 901 OF oDlg10 2007 ;
FILENAME c_path + "\system\Button.bmp" ;
PROMPT "Button 1" ;
FONT oFont1 ;
LEFT ;
ACTION ( cFilter := "BMP (*.bmp)|*.bmp|", ;
   cNewBITM := cGetFile32( cFilter,"Select a Picture" ,,  "\" + CurDir()+ "\project" ), ;
   IIF( empty( cNewBITM ), MsgAlert( "No file selected !","ATTENTION" ), NIL ), ;
        D_BUTTON1 := cFileNoPath( cNewBITM ), oButton1:Refresh(), ; 
        oBMP15:Refresh() )
oBtn81:cTooltip := "1. Button"

// That works, but it is not transparent.
// --------------------------------------------
REDEFINE BITMAP oBMP15  ID 411  ADJUST  RESOURCE "Blanc"  OF oDlg10 TRANSPARENT
oBMP15:bPainted := {|hDC| DRAW_IMG( oBMP15, D_BUTTON1) }

// With BTNBMP it doesn' work
// ---------------------------------
// REDEFINE BTNBMP oBMP15 ID 411 OF oDlg10 Adjust ;
// FILENAME c_path + "\project\" + D_BUTTON1 
// oBMP15:lTransparent = .t.




Is there any solution for it ?

Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Possible, to replace a BMP in BTNBMP at Runtime ?
Posted: Sun May 10, 2009 04:55 PM

You may try to put both and alternatively show one and hide the other. I don't think you can change the class of an object on the fly.

EMG

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Possible, to replace a BMP in BTNBMP at Runtime ?
Posted: Sun May 10, 2009 05:53 PM
Enrico, thank You very much for the reply.

I finished the Setup-part for the Buttontools and the user can select any Button-BMP's
to display them in the 4 different Dialogs in the Main-Window with defined Backgrounds.
The Bitmap-selection works perfect, the only thing that doesn't look nice, is the black
( Alpha-Blended ) Background of the 3 Control-Button-BMP's ( Preview ).
I think the < REDEFINE BITMAP > doesn't support Alpha-Blends.



Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Possible, to replace a BMP in BTNBMP at Runtime ?
Posted: Sun May 10, 2009 08:22 PM

>
I want to display a new selected Bitmap for a defined Button.
>

oBtn:SetFile( nil, nil, <cNewBmpFileName> )

Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Possible, to replace a BMP in BTNBMP at Runtime ?
Posted: Sun May 10, 2009 10:32 PM
Thank You very much for the information.

It works perfect now.
Only the information of a new file was needed.
oBMP1:SetFile( c_path + "\project\" + D_BUTTON1 ) )


Code (fw): Select all Collapse
// 1. Button
// --------------
REDEFINE BTNBMP oBtn1 ID 100 OF oDlg1 2007 ;
FILENAME c_path + "\system\Button.bmp" ;
PROMPT "Btn 1-4" ;
FONT oFont1 ;
LEFT ;
ACTION ( cFilter := "BMP (*.bmp)|*.bmp|", ;
      cNewBITM := cGetFile32( cFilter,"Select a Picture" ,,  "\" + CurDir()+ "\project" ), ;
      IIF( empty( cNewBITM ), MsgAlert( "No file selected !","ATTENTION" ), NIL ), ;
          D_BUTTON1 := cFileNoPath( cNewBITM ), oButton1:Refresh(), ; 
          oBMP1:SetFile( c_path + "\project\" + D_BUTTON1 ) )
oBtn1:cTooltip := "Button 1-4"

REDEFINE GET oButton1   VAR D_BUTTON1  ID 110 OF oDlg10 PICTURE "!!!!!!!!!!!!!!!" UPDATE

// Testbutton 1
// ----------------------
REDEFINE BTNBMP oBMP1 ID 120 OF oDlg1 ;
FILENAME c_path + "\project\" + D_BUTTON1 ;
LEFT
oBMP1:lTransparent = .t.


Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Possible, to replace a BMP in BTNBMP at Runtime ?
Posted: Mon May 11, 2009 07:56 AM

Sorry, I misunderstood your question.

EMG

Continue the discussion