15.02 BUTTONBARs
Posted: Mon Feb 23, 2015 9:01 pm
It is possible to specify almost any image file as a bitmap for btnbmp and so buttons on the buttonbar, eg. bmp, png, ico, gif, jpg, etc (acceptable by freeimage). Larger image files will be reduced to fit the buttonsize, if necessary. It is also possible to specify a bitmap handle of memory buffer of an image.
In addition an exe file also can be specified and in that case, the first icon of the exe will be shown as the bitmap.
Resources and files need not be specified separately. We can use either FILE or RESOURCE clause followed by any files and/or resources.
Large image files are automatically re-sized to fit the size of the button. In the following example, some pngs and jpg are resized. This feature largely reduces the need to maintain bmp files of different sizes of the same image.
A small example showing a buttonbar built with ICO,EXE,GIF,PNG,AlphaBmp and JPG.
In earlier versions, btnbmp can be shown transparently. Though this is not of a regular use, it is possible to show buttonbars also transparently like this:
In the same manner, any image file (including exe file) can be specified as bitmap for XBrowse. Here is an example showing list of applications with their icons shown as bitmaps.
In addition an exe file also can be specified and in that case, the first icon of the exe will be shown as the bitmap.
Resources and files need not be specified separately. We can use either FILE or RESOURCE clause followed by any files and/or resources.
Large image files are automatically re-sized to fit the size of the button. In the following example, some pngs and jpg are resized. This feature largely reduces the need to maintain bmp files of different sizes of the same image.
A small example showing a buttonbar built with ICO,EXE,GIF,PNG,AlphaBmp and JPG.
- Code: Select all Expand view
function AnyImageBtn()
local oWnd, oBar, oFont
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
DEFINE WINDOW oWnd TITLE "BUTTONAR ANY IMAGE 15.02"
oWnd:SetFont( oFont )
DEFINE BUTTONBAR oBar OF oWnd SIZE 72,96 2007
DEFINE BUTTON OF oBar FILE "c:\fwh\icons\fivetech.ico" PROMPT "fivetech"+ CRLF+ "ICO"
DEFINE BUTTON OF oBar FILE "c:\Program Files\Microsoft Office\Office14\Excel.exe" ;
PROMPT "Excel" + CRLF + "EXE"
DEFINE BUTTON OF oBar FILE "c:\Program Files\Microsoft Office\Office14\powerpnt.exe" ;
PROMPT "Excel" + CRLF + "EXE"
DEFINE BUTTON OF oBar FILE "c:\fwh\gifs\gif05.gif" PROMPT "gif06" + CRLF + "GIF"
DEFINE BUTTON OF oBar FILE "c:\fwh\bitmaps\32x32\case.bmp" PROMPT "32x32" + CRLF + "BMP"
DEFINE BUTTON OF oBar FILE "c:\fwh\bitmaps\pngs\image3.png" PROMPT "image3" + CRLF + "PNG"
DEFINE BUTTON OF oBar FILE "c:\fwh\bitmaps\AlphaBmp\ichat.bmp" PROMPT "IChat" + CRLF + "ALPHABMP"
DEFINE BUTTON OF oBar FILE "c:\fwh\bitmaps\olga1.jpg" PROMPT "olga1" + CRLF + "JPG"
ACTIVATE WINDOW oWnd CENTERED
RELEASE FONT oFont
return nil
In earlier versions, btnbmp can be shown transparently. Though this is not of a regular use, it is possible to show buttonbars also transparently like this:
- Code: Select all Expand view
function TranspBtnBar
local oWnd, oBar, oBtn, oFont, oBrush
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
DEFINE BRUSH oBrush FILE "c:\fwh\bitmaps\olga1.jpg" RESIZE
DEFINE WINDOW oWnd TITLE "TRANSPARENT BUTTONBAR" BRUSH oBrush
oWnd:SetFont( oFont )
DEFINE BUTTONBAR oBar OF oWnd SIZE 72,96
oBar:lTransparent := .t.
DEFINE BUTTON OF oBar FILE "c:\fwh\bitmaps\metro\metro-back-48.png" ;
PROMPT "Back" + CRLF + "metro" FLAT TRANSPARENT
DEFINE BUTTON OF oBar FILE "c:\Program Files\Microsoft Office\Office14\Excel.exe" ;
PROMPT "Excel" + CRLF + "exe" FLAT TRANSPARENT
DEFINE BUTTON OF oBar FILE "c:\Program Files\Microsoft Office\Office14\winword.exe" ;
PROMPT "Word" + CRLF + "EXE" FLAT TRANSPARENT
DEFINE BUTTON OF oBar FILE "c:\fwh\gifs\loading.gif" PROMPT "loading"+ CRLF+ "gif" FLAT TRANSPARENT
DEFINE BUTTON OF oBar FILE "c:\fwh\bitmaps\32x32\copy.bmp" PROMPT "copy" + CRLF + "bmp" FLAT TRANSPARENT
DEFINE BUTTON OF oBar FILE "c:\fwh\bitmaps\32x32\paste.bmp" PROMPT "paste" + CRLF + "bmp" FLAT TRANSPARENT
DEFINE BUTTON OF oBar FILE "c:\fwh\bitmaps\pngs\image3.png" PROMPT "image3" + CRLF + "png" FLAT TRANSPARENT
DEFINE BUTTON OF oBar FILE "c:\fwh\bitmaps\AlphaBmp\visa.bmp" PROMPT "Visa" + CRLF + "Alpha" FLAT TRANSPARENT
DEFINE BUTTON OF oBar FILE "c:\fwh\bitmaps\AlphaBmp\ichat.bmp" PROMPT "IChat" + CRLF + "Alpha" FLAT TRANSPARENT
DEFINE BUTTON OF oBar FILE "c:\fwh\bitmaps\metro\users.bmp" PROMPT "users" + CRLF + "metro" FLAT TRANSPARENT
DEFINE BUTTON OF oBar FILE "c:\fwh\bitmaps\metro\exit.bmp" PROMPT "exit" + CRLF + "metro" FLAT TRANSPARENT
for each oBtn in oBar:aControls
oBtn:SetColor( CLR_WHITE, CLR_BLACK )
next
ACTIVATE WINDOW oWnd CENTERED
RELEASE FONT oFont
RELEASE BRUSH oBrush
return nil
In the same manner, any image file (including exe file) can be specified as bitmap for XBrowse. Here is an example showing list of applications with their icons shown as bitmaps.
- Code: Select all Expand view
function XbrExeIcons()
local cPath := "c:\\Program Files\\Microsoft Office\\Office14\\"
local aDir, aExe := {}
local ownd, oBrw, oFont
aDir := Directory( cPath + "*.exe" )
AEval( aDir, { |a| AAdd( aExe, cPath + a[ 1 ] ) } )
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
DEFINE WINDOW oWnd TITLE "MS OFFICE PROGRAMS"
oWnd:SetFont( oFont )
@ 0,0 XBROWSE oBrw OF oWnd DATASOURCE aDir COLUMNS 1 HEADERS "Program" ;
LINES NOBORDER
WITH OBJECT oBrw
:aCols[ 1 ]:AddBitmap( aExe )
:aCols[ 1 ]:bBmpData := { || oBrw:nArrayAt }
//
:CreateFromCode()
END
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd CENTERED
RELEASE FONT oFont
return nil