Page 1 of 1

Show all bmps

PostPosted: Tue Jan 19, 2010 11:29 am
by MdaSolution
Can I show all bmp are in a folder into a Panel ?
sample



nMargenLeft :=200

DEFINE WINDOW oWndChild MDICHILD of oWnd;
TITLE "New Test" ;
VSCROLL

oPanel := TPanel():New( 0, 0, 1000, nMargenLeft, oWndChild )
oPanel:SetColor(0,RGB(143,172,230))
oWndChild:oLeft:= oPanel


-> Show all bitmaps

aDir = Directory( "c:\fwh\bitmaps\*.bmp" )
nrow:= 0
nCol:= 0
FOR i = 1 TO LEN( aDir )
@ nrow, nCol BUTTON oBtn[i] File aDir[ i, F_NAME ] SIZE 22, 22 PIXEL OF oPanel
nrow:=+1
NEXT i
...

I wish have five bitmaps for each row...


How I can make it please

Re: Show all bmps

PostPosted: Tue Jan 19, 2010 3:53 pm
by nageswaragunupudi
Please try this interesting sample;
Code: Select all  Expand view

#include "fivewin.ch"
#include "xbrowse.ch"

function main()

   local abmp := {}

   AEval( Directory( 'c:\fwh\bitmaps\*.bmp' ), { |a| AAdd( abmp, 'c:\fwh\bitmaps' + a[ 1 ] ) } )

   XBROWSER aBmp SETUP oBrw:aCols[ 1 ]:cDataType := '
F'

return nil


We see all bitmaps in the browse. This can be extended to show all bitmaps in any manner we like.

Re: Show all bmps

PostPosted: Tue Jan 19, 2010 4:46 pm
by nageswaragunupudi
Here is a sample to show all bitmaps with 5 bitmaps in each row, using xbrowse.
Code: Select all  Expand view

#include "FiveWin.Ch"
#include "xbrowse.ch"

function main()
   local cPath := 'c:\fwh\bitmaps'
   local aDir := Directory( cPath + '
*.bmp' )
   local abmp
   local n, r, c
   local oWnd, oBrw, oBar

   aBmp  := Array( Int( Len( aDir ) / 5 ) + 1, 5 )
   r := 1
   c := 1
   for n := 1 to Len( aDir )
      aBmp[ r, c ] := cPath + aDir[ n, 1 ]
      if ++c > 5
         c  := 1
         r++
      endif
   next n
   if c <= 5
      AFill( ATail( aBmp ), '
', c )
   endif

   DEFINE WINDOW oWnd
   DEFINE BUTTONBAR oBar OF oWnd 2007
   SET MESSAGE OF oWnd TO '
' 2007

   @ 0,0 XBROWSE oBrw SIZE 240,1000 PIXEL OF ownd ;
      AUTOCOLS ARRAY aBmp COLOR CLR_BLACK,RGB( 143, 172, 230 )

   WITH OBJECT oBrw
      :lRecordSelector  := .f.
      :lHeader          := .f.
      :lHScroll         := .f.
      :nRowHeight       := 40
   END
   AEval( oBrw:aCols, { |o| o:cDataType := '
F', o:nWidth := 40 } )

   oBrw:CreateFromCode()
   oWnd:oLeft     := oBrw
   ACTIVATE WINDOW oWnd

return nil


Screen Shot:
Image

Re: Show all bmps

PostPosted: Tue Jan 19, 2010 4:54 pm
by Silvio
Nas ,
nice sample
Do U think we can load also the other format graphics sample png, jpg ....
It can be use for a Ribbon Gallery control

Re: Show all bmps

PostPosted: Tue Jan 19, 2010 5:05 pm
by MdaSolution
Mr Rao,

Itry the test number 1 and number two

they are compiled but I cannot see the bitmaps

I tried to insert my folder of Images ".\images\*.bmp" and I cannot see any bmps

there is something of wrong or I not understand How make it

Re: Show all bmps

PostPosted: Tue Jan 19, 2010 5:37 pm
by nageswaragunupudi
Silvio wrote:Nas ,
nice sample
Do U think we can load also the other format graphics sample png, jpg ....
It can be use for a Ribbon Gallery control

Yes. png, jpg, etc all valid image files.

Re: Show all bmps

PostPosted: Tue Jan 19, 2010 5:38 pm
by nageswaragunupudi
>>
I tried to insert my folder of Images ".\images\*.bmp" and I cannot see any bmps
>>
Please try giving absolute path. Please make sure the path is properly evaluated.
The sample has to work.

I noticed a small problem in the way the code is shown in the forums.
The last backslash is not displaed.
I wrote 'c:\fwh\bitmaps\'
but it shows as 'c:\fwh\bitmaps'
In your code please make the appropriate changes

Re: Show all bmps

PostPosted: Tue Jan 19, 2010 7:59 pm
by MdaSolution
Sorry Mr Rao
I forget the slash "\" now run ok on c:\fwh\bitmaps\ thank you so much

I tried with other folders

I have a folder on the folder of my application called ".\pat\ "
I isert it but it not run

Re: Show all bmps

PostPosted: Tue Jan 19, 2010 8:06 pm
by MdaSolution
I try with the first sample
Code: Select all  Expand view
#include "FiveWin.Ch"
#include "xbrowse.ch"

function main()

   local aDir := Directory( 'C:\FWH\bitmaps\*.bmp' )
   local abmp
   local n, r, c
   local oWnd, oBrw, oBar

   aBmp  := Array( Int( Len( aDir ) / 5 ) + 1, 5 )
   r := 1
   c := 1
   for n := 1 to Len( aDir )
      aBmp[ r, c ] := 'C:\FWH\bitmaps' + aDir[ n, 1 ]
      if ++c > 5
         c  := 1
         r++
      endif
   next n

   DEFINE WINDOW oWnd
   DEFINE BUTTONBAR oBar OF oWnd 2007
   SET MESSAGE OF oWnd TO '
' 2007

   @ 0,0 XBROWSE oBrw SIZE 240,1000 PIXEL OF ownd ;
      AUTOCOLS ARRAY aBmp COLOR CLR_BLACK,RGB( 143, 172, 230 )

   WITH OBJECT oBrw
      :lRecordSelector  := .f.
      :lHeader          := .f.
      :lHScroll         := .f.
      :nRowHeight       := 40
   END
   AEval( oBrw:aCols, { |o| o:cDataType := '
F', o:nWidth := 40 } )

   oBrw:CreateFromCode()
   oWnd:oLeft     := oBrw
   ACTIVATE WINDOW oWnd

   return nil





If I click on scroll button to see the last bmp it make error 9003 "Too Many recoursive handle calls"

Re: Show all bmps

PostPosted: Tue Jan 19, 2010 8:36 pm
by nageswaragunupudi
i have edited the sample i posted earlier.
please copy the changes i made.
particularly the code after the loop.