FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Changing BtnBmp Icon on demand
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Changing BtnBmp Icon on demand
Posted: Sat Jul 27, 2013 01: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

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Changing BtnBmp Icon on demand
Posted: Sat Jul 27, 2013 02: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
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Changing BtnBmp Icon on demand
Posted: Sat Jul 27, 2013 02: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 (fw): Select all Collapse
REDEFINE BTNBMP oBtn1 ID 111 OF oDlg   ;
         RESOURCE "OK", "DOK", "DOK" ;
         PROMPT "  &Ok    " LEFT 2007;
         ACTION nil
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Changing BtnBmp Icon on demand
Posted: Sat Jul 27, 2013 02: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 (fw): Select all Collapse
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
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: Changing BtnBmp Icon on demand
Posted: Sun Jul 28, 2013 09:37 AM
Dear Rick,

I test with BmpFile and it works well. I'm not quite sure, is it what you want.
Code (fw): Select all Collapse
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 2304 / 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)
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Changing BtnBmp Icon on demand
Posted: Sun Jul 28, 2013 03:12 PM

Dutch

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

Rick Lipkin

Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: Changing BtnBmp Icon on demand
Posted: Mon Jul 29, 2013 04:18 AM
Hi, Ricky, you can try this, also:
Code (fw): Select all Collapse
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

Continue the discussion