Possible, to replace a BMP in BTNBMP at Runtime ?

Possible, to replace a BMP in BTNBMP at Runtime ?

Postby ukoenig » Sun May 10, 2009 3: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: Select all  Expand view

// 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.


Image

Is there any solution for it ?

Regards
Uwe :lol:
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Possible, to replace a BMP in BTNBMP at Runtime ?

Postby Enrico Maria Giordano » Sun May 10, 2009 4: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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Possible, to replace a BMP in BTNBMP at Runtime ?

Postby ukoenig » Sun May 10, 2009 5: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.

Image

Regards
Uwe :lol:
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Possible, to replace a BMP in BTNBMP at Runtime ?

Postby nageswaragunupudi » Sun May 10, 2009 8: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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Possible, to replace a BMP in BTNBMP at Runtime ?

Postby ukoenig » 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 ) )

Image
Code: Select all  Expand view

// 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 :lol:
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany



Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 111 guests