Bitmap on listbox

Post Reply
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Bitmap on listbox

Post by Silvio »

I tried fwbrowse sample into fwppc but it not run ok
I not see any bitmaps
I want show bitmaps for level as fwbrowse.prg ( clients functions)
Best Regards, Saludos

Falconi Silvio
User avatar
Arturo Lopesoria
Posts: 84
Joined: Fri Aug 10, 2007 1:47 am
Location: Mexico DF
Contact:

Re: Bitmap on listbox

Post by Arturo Lopesoria »

Hello
can you try Listbox?
The way I use bitmaps in listbox works fine, (this example for simulate mark/Unmark a browse cell:

Code: Select all

    hBmpCheckOn := LoadBitmap( GetResources(), "checkon" )      
    hBmpCheckOff:= LoadBitmap( GetResources(), "checkoff" )     
    REDEFINE LISTBOX aoLbx[LBX_GRUPOPR] ;
         FIELDS if( PasGrpPr->OK=" ", hBmpCheckOff, hBmpCheckOn ),;
            PasGrpPr->DESCRIPCIO,;
                  PasGrpPr->(TRANSFORM(CANTIDAD,"99999.9")),;
                  PasGrpPr->(TRANSFORM(PRECIO,"99,999.99")),;
                  PasGrpPr->(transform(existencia,"99999")) ;
         HEADERS "Ok", "Descripcion", "Cant", "Precio", "Existencia" ; 
         FONT oFont ;
         ID 901 OF aoDlgs[DLG_GRUPOPR] ALIAS cAlias2
 
see the result .ppo and you can view how the function is called.
Arturo LS
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Bitmap on listbox

Post by Silvio »

thank you
but on fbrowse.prg ( fwh)
the bitmaps are different : look here please

Code: Select all

function Clients()

   local oDlg
   local oLbx
   local cVar

   local aHBitMaps:= { ReadBitmap( 0, "..\bitmaps\Level1.bmp" ), ; // BitMaps de 14 x 32
                       ReadBitmap( 0, "..\bitmaps\Level2.bmp" ), ;
                       ReadBitmap( 0, "..\bitmaps\Level3.bmp" ), ;
                       ReadBitmap( 0, "..\bitmaps\Level4.bmp" ),;
                       ReadBitmap( 0, "..\bitmaps\Level5.bmp" ) }
   local n

   if ! File( "clientes.dbf" )
      DbCreate( "Clientes.dbf", { { "Nombre",    "C", 40, 0 },;
                                  { "Direccion", "C", 50, 0 },;
                                  { "Telefono",  "C", 12, 0 },;
                                  { "Edad",      "N",  2, 0 },;
                                  { "Productos", "C", 10, 0 },;
                                  { "Nivel",     "N",  2, 0 } } )
   endif

   USE Clientes

   if RecCount() == 0
      APPEND BLANK
   endif

   INDEX ON Clientes->Nombre TO CliName

   SET INDEX TO CliName

   GO TOP

   DEFINE DIALOG oDlg FROM 3, 3 TO 26, 79 TITLE "Clients Management"

   @ 0,  1 SAY " &Clients List"  OF oDlg

   @ 1, 1 LISTBOX oLbx FIELDS aHBitmaps[ Max( 1, Clientes->Nivel ) ],;
                              Clientes->Nombre, AllTrim( Clientes->Direccion ),;
                              Clientes->Telefono,;
                              Str( Clientes->Edad, 3 ) ;
          HEADERS    "L", "Name", "Address", "Phone", "Age" ;
          FIELDSIZES 16, 222, 213, 58, 24 ;
          SIZE 284, 137 OF oDlg

   // Lets use different row colors
   oLbx:nClrText      = { || SelColor( Clientes->Nivel ) }
   oLbx:nClrForeFocus = { || SelColor( Clientes->Nivel ) }
   oLbx:bRClicked     = { | nRow, nCol | ShowPopup( nRow, nCol, oLbx ) }
   // Try different line styles !!!
   oLbx:nLineStyle = 1
   oLbx:bKeyChar := {|nKey| if( nKey == VK_RETURN , EditRecord( oLbx ) , )}

   oLbx:aJustify = { .f., .f., .t., .f., .t. }

   // Uncomment this to quickly calculate the desired columns width
   // Right click with the mouse over the browse and you will
   // see the columns sizes!
   // oLbx:bRClicked = { || oLbx:ShowSizes() }

   @ 8.7,  1.4 BUTTON "&New"    OF oDlg ACTION EditClient( oLbx, .t. ) ;
                                            SIZE 40, 12
   @ 8.7,  9.4 BUTTON "&Modify" OF oDlg ACTION EditClient( oLbx, .f. ) ;
                                              SIZE 40, 12
   @ 8.7, 17.4 BUTTON "&Delete" OF oDlg ACTION DelClient( oLbx )  SIZE 40, 12
   @ 8.7, 25.4 BUTTON "&Search" OF oDlg ACTION SeekClient( oLbx ) SIZE 40, 12

   @ 8.7, 33.4 BUTTON "&Print"  OF oDlg ;
      ACTION oLbx:Report( "clients Report", .t. ) ;  // .t. --> wants preview
      SIZE 40, 12

   @ 8.7, 42 BUTTON "&Exit"   OF oDlg ACTION oDlg:End()         SIZE 40, 12

   ACTIVATE DIALOG oDlg

   USE

   AEval( aHBitmaps, { | hBmp | DeleteObject( hBmp ) } )

return nil
 
Best Regards, Saludos

Falconi Silvio
User avatar
Arturo Lopesoria
Posts: 84
Joined: Fri Aug 10, 2007 1:47 am
Location: Mexico DF
Contact:

Re: Bitmap on listbox

Post by Arturo Lopesoria »

I dont know FWH yet, but apears to be very similar, maybe if you increase column 1 size more than 16...
Arturo LS
User avatar
mmercado
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Re: Bitmap on listbox

Post by mmercado »

Hi Silvio:
Silvio wrote:I tried fwbrowse sample into fwppc but it not run ok
I not see any bitmaps
I want show bitmaps for level as fwbrowse.prg ( clients functions)
You should better use resources for bitmaps, here you are a working sample:

Code: Select all

#include "FWCE.ch"

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

Function Main()

   Local oWnd, oLbx, ;
         aHBitMaps:= { LoadBitmap( GetResources(), "Level1" ), ;
                       LoadBitmap( GetResources(), "Level3" ), ;
                       LoadBitmap( GetResources(), "Level2" ), ;
                       LoadBitmap( GetResources(), "Level4" ), ;
                       LoadBitmap( GetResources(), "Level5" ) }

   USE ( CurDir() + "\Clientes" ) EXCLUSIVE NEW
   INDEX ON Clientes->Nombre TO CliName
   SET INDEX TO CliName
   GO TOP

   DEFINE WINDOW oWnd TITLE "Clients Management"

   @  0,  0 LISTBOX oLbx ;
            FIELDS aHBitmaps[ Max( 1, Clientes->Nivel ) ], ;
                              Clientes->Nombre, AllTrim( Clientes->Direccion ), ;
                              Clientes->Telefono, ;
                              Str( Clientes->Edad, 3 ) ;
            HEADERS "L", "Name", "Address", "Phone", "Age" ;
            FIELDSIZES 16, 112, 112, 58, 24 ;
            SIZE 234, 263 PIXEL OF oWnd

   // Lets use different row colors
   oLbx:nClrText      = { || SelColor( Clientes->Nivel ) }
   oLbx:nClrForeFocus = { || SelColor( Clientes->Nivel ) }
   // Try different line styles !!!
   oLbx:nLineStyle = 1
   oLbx:aJustify = { .F., .F., .F., .F., .T. }

   ACTIVATE WINDOW oWnd ON CLICK MsgInfo( "Click!" )

   DbCloseAll()

Return Nil

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

Static Function SelColor( nNivel )

   Local nColor := CLR_BLACK

   Do Case
      Case nNivel == 1
           nColor = CLR_HRED
      Case nNivel == 2
           nColor = CLR_HGREEN
      Case nNivel == 3
           nColor = CLR_HBLUE
   EndCase

Return nColor 
The RC file

Code: Select all

Level1 BITMAP "..\Bitmaps\Level1.bmp"
Level2 BITMAP "..\Bitmaps\Level2.bmp"
Level3 BITMAP "..\Bitmaps\Level3.bmp"
Level4 BITMAP "..\Bitmaps\Level4.bmp"
Level5 BITMAP "..\Bitmaps\Level5.bmp"
 
Make sure that bitmaps are in refered FwPpc folder and "Clientes.dbf" is in PocketPc testing folder.

Best regards.

Manuel Mercado.
manuelmercado at prodigy dot net dot mx
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Bitmap on listbox

Post by Silvio »

thanks,
but why we cannot use bitmap at folder and we must use resources?
Perhaps there is a bug on xharbour ce?
I sad this because i try to use pp4 hand basic last year before to purchase fwppc and with it can use all in source , the last one you cannot use are dbf files instead of pdb files.

Manuel, when we can use your sbrowse and your sbutton in fwppc?

I am sure U're working for us...


.
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Bitmap on listbox

Post by Silvio »

thanks to All
NOW i SEE BITMAPS ON listbox

the error I made is this :

aHBitMaps:= { ReadBitmap( 0, CurDir() +"\Level1.bmp" ), ; // BitMaps de 14 x 32
ReadBitmap( 0, CurDir() +"\Level2.bmp" ), ;
ReadBitmap( 0, CurDir() +"\Level3.bmp" ), ;
ReadBitmap( 0, CurDir() +"\Level4.bmp" ),;
ReadBitmap( 0, CurDir() +"\Level5.bmp" ) }



instead of this

aHBitMaps:= { LoadBitmap( GetResources(), "Level1" ), ;
LoadBitmap( GetResources(), "Level3" ), ;
LoadBitmap( GetResources(), "Level2" ), ;
LoadBitmap( GetResources(), "Level4" ), ;
LoadBitmap( GetResources(), "Level5" ) }
Best Regards, Saludos

Falconi Silvio
User avatar
mmercado
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Re: Bitmap on listbox

Post by mmercado »

Hi Silvio:
Silvio wrote:but why we cannot use bitmap at folder and we must use resources?
Perhaps there is a bug on xharbour ce?
Not such a bug, it was just an advice for portability.
Silvio wrote:I sad this because i try to use pp4 hand basic last year before to purchase fwppc and with it can use all in source , the last one you cannot use are dbf files instead of pdb files.
?????
Silvio wrote:Manuel, when we can use your sbrowse and your sbutton in fwppc?
No problem with TSBrowse, TSButton have problems with transparency and some non supported GDI functions.
Silvio wrote:I am sure U're working for us...
Are you? :D

Regards.

Manuel Mercado
manuelmercado at prodigy dot net dot mx
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Bitmap on listbox

Post by Silvio »

Sorry Manuel

Fwppc perhaps not support GDI


but you can found helps from this http://www.pocketpcdn.com/forum/index.php


Or you can see here : http://www.pocketpcdn.com/articles/tran ... tatic.html

or here http://www.codeproject.com/KB/mobile/tr ... trols.aspx




For WinCE 2.0 and later you can the TransparentImage() instead of BitBlt which takes a COLORREF as its last parameter that is used as a transparency color
Here's the function prototype for TransparentImage

BOOL TransparentImage(HDC hdcDest, LONG DstX, LONG DstY, LONG DstCx, LONG DstCy, HANDLE hSrc, LONG SrcX, LONG SrcY, LONG SrcCx, LONG SrcCy, COLORREF TransparentColor );

It may not do exactly what you want but it will give you a wider range to use as the transparent color


for sample I found How draw a circle in Transparency

/// This will hold the data regarding the Transparency

BLENDFUNCTION blendFunction;
blendFunction.BlendOp = (byte)0x00;
blendFunction.BlendFlags = (byte)0x00;
blendFunction.SourceConstantAlpha = 210;
blendFunction.AlphaFormat = (byte)0;
////////////////////////////////////////////////////////////////////////////////


/////////// Draw the transpernt image

if (0 == AlphaBlend(hdc, 0, BTStripY,DEVICEWIDTH,100,
hcompdc, 0, 0, 48,20, blendFunction));
Best Regards, Saludos

Falconi Silvio
Post Reply