Changing BtnBmp Icon on demand

Changing BtnBmp Icon on demand

Postby Rick Lipkin » Sat Jul 27, 2013 1:16 pm

To All

I have a BtnBmp that uses icons from resources ( enabled and disabled ) and I would like to be able to change the Enabled Bitmap that shows on the button based on a programmatical logical value which needs to be changed and re-evaluated on the value of the variable.

In clearer terms .. I need to change the Bitmap at runtime based on the value of a logical variable.

Any Ideas ??

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Changing BtnBmp Icon on demand

Postby Enrico Maria Giordano » Sat Jul 27, 2013 2:26 pm

Rick,

Rick Lipkin wrote:To All

I have a BtnBmp that uses icons from resources ( enabled and disabled ) and I would like to be able to change the Enabled Bitmap that shows on the button based on a programmatical logical value which needs to be changed and re-evaluated on the value of the variable.

In clearer terms .. I need to change the Bitmap at runtime based on the value of a logical variable.

Any Ideas ??

Thanks
Rick Lipkin


Did you try using WHEN clause?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Changing BtnBmp Icon on demand

Postby Rick Lipkin » Sat Jul 27, 2013 2:44 pm

Enrico

Here is a typical BtnBmp button code with Icons from resource .. I want to be able to change the Enabled Icon at runtine .. "Ok" to maybe "Finished" ( resource icons ).

Where would I use the 'when' clause ?

Thanks
Rick Lipkin

Code: Select all  Expand view

REDEFINE BTNBMP oBtn1 ID 111 OF oDlg   ;
         RESOURCE "OK", "DOK", "DOK" ;
         PROMPT "  &Ok    " LEFT 2007;
         ACTION nil
 
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Changing BtnBmp Icon on demand

Postby Enrico Maria Giordano » Sat Jul 27, 2013 2:47 pm

Rick,

Rick Lipkin wrote:Enrico

Here is a typical BtnBmp button code with Icons from resource .. I want to be able to change the Enabled Icon at runtine .. "Ok" to maybe "Finished" ( resource icons ).

Where would I use the 'when' clause ?

Thanks
Rick Lipkin

Code: Select all  Expand view

REDEFINE BTNBMP oBtn1 ID 111 OF oDlg   ;
         RESOURCE "OK", "DOK", "DOK" ;
         PROMPT "  &Ok    " LEFT 2007;
         ACTION nil
 


Ok, so try using oBtn:SetFile() method.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Changing BtnBmp Icon on demand

Postby dutch » Sun Jul 28, 2013 9:37 am

Dear Rick,

I test with BmpFile and it works well. I'm not quite sure, is it what you want.
Code: Select all  Expand view
function Main()
#include 'Fivewin.ch'

   local oBru, oDlg, oBtn
   local lYes := .T.

   DEFINE BRUSH oBru FILENAME "../bitmaps/Backgrnd/beach.bmp"

   DEFINE DIALOG oDlg SIZE 400, 200 BRUSH oBru TRANSPARENT

   @ 2, 2 SAY "Hello" OF oDlg
   oDlg:aControls[ 1 ]:lTransparent = .t.

   @ 70, 80 BTNBMP oBtn FILENAME "../bitmaps/yes.bmp" ;
      SIZE 50, 30 OF oDlg NOBORDER ACTION ChangeBmp( oBtn, @lYes) // MsgInfo( "click" )
     
   oBtn:lTransparent = .T.  
     
   ACTIVATE DIALOG oDlg CENTERED

return nil

//----------------------------------------------------------------------------//


Function ChangeBmp( oBtn, lYes )
lYes := !lYes

if lYes
   oBtn:LoadBitmaps( ,, "../bitmaps/yes.bmp" )
else
   oBtn:LoadBitmaps( ,, "../bitmaps/no.bmp" )

end

   oBtn:Refresh()
return nil
 
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Changing BtnBmp Icon on demand

Postby Rick Lipkin » Sun Jul 28, 2013 3:12 pm

Dutch

Thank you ... I will test your suggestion when I get to work Monday!

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Changing BtnBmp Icon on demand

Postby FranciscoA » Mon Jul 29, 2013 4:18 am

Hi, Ricky, you can try this, also:
Code: Select all  Expand view
if cVar=="A"
   oBtn:LoadBitmaps("A")
elseif cVar =="B"
   oBtn:LoadBitmaps("B")
else
   oBtn:LoadBitmaps("X")
endif
oBtn:Refresh()
 

Regards.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2158
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 110 guests