galería de imágenes

User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: galería de imágenes

Post by Antonio Linares »

José Luis,

Add this new DATA in Class TAlbum:

DATA lExit INIT .F.

and modify this method this way:

Code: Select all

METHOD Activate() CLASS TAlbum

   ::CreateWindow()
   ::CreateControls()
   ::SetVScroll()
   ::oWnd:bResized := { |t,w,h| ::Resize( t, w, h ) }

   if ::oWnd:IsKindOf( "MDICHILD" )
      ACTIVATE WINDOW ::oWnd VALID ::lExit := .T.
   else
      ACTIVATE WINDOW ::oWnd CENTERED VALID  ::lExit := .T.
   endif

   StopUntil( { || ::lExit } )

return Self
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
José Luis Sánchez
Posts: 484
Joined: Thu Oct 13, 2005 9:23 am
Location: Novelda - Alicante - España
Contact:

Re: galería de imágenes

Post by José Luis Sánchez »

Antonio,

your code works fine, I've made a small sample with a mail window calling the talbum and the window remains on the top of the main window. In my program it doesn't work, I don't know why, it's very strange.

I want to create a control based on talbum so I can create a dialog with the album and other controls. I've never done a control, my friend Paco was who created them, but I think I can do it.

My goal is to create something like the Plex interface, like in this image.

Image

In Plex, the slider on the top right changes the size of the thumbnails, this is a feature I'd like to achieve.

I'll post in this threat any advance in the control. If someone wants to help me please contact me.

Kind regards,
José Luis
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: galería de imágenes

Post by nageswaragunupudi »

Can you see if MDI application suits you?

Please try this and let us have your response.

Code: Select all

function Main()

   local oWnd, oBar
   local aImages := nil

   DEFINE WINDOW oWnd MDI
   DEFINE BUTTONBAR oBar OF oWnd SIZE 100,32 2007
   DEFINE BUTTON OF oBar PROMPT "Album" CENTER ACTION ;
      ( aImages  := ImageArray(), TAlbum():New( aImages ):Activate() )

   ACTIVATE WINDOW oWnd CENTERED

return nil
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: galería de imágenes

Post by nageswaragunupudi »

Sorry, I did not see the above two postings.
Nice.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: galería de imágenes

Post by Antonio Linares »

José Luis,

Is your main window MDI ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
José Luis Sánchez
Posts: 484
Joined: Thu Oct 13, 2005 9:23 am
Location: Novelda - Alicante - España
Contact:

Re: galería de imágenes

Post by José Luis Sánchez »

Antonio, I use TFSDI https://www.alanit.com/2006/06/fsdi2006/ that is a dialog overlaped the main window. In the link you can download a sample.

Regards,
User avatar
José Luis Sánchez
Posts: 484
Joined: Thu Oct 13, 2005 9:23 am
Location: Novelda - Alicante - España
Contact:

Re: galería de imágenes

Post by José Luis Sánchez »

I noticed that the INIT clause doesn't assign .F. to lExit so I changed the code:

Code: Select all

METHOD Activate() CLASS TAlbum
   local hWndMain
   ::CreateWindow()
   ::CreateControls()
   ::SetVScroll()
   ::oWnd:bResized := { |t,w,h| ::Resize( t, w, h ) }
   ::lExit := .F.

   ACTIVATE WINDOW ::oWnd CENTERED ;
      VALID (::lExit := .t.) // ON INIT ( ::oWnd:Center( oApp():oWndMain ) )

   StopUntil( { || ::lExit  } )
   
return Self
and then it runs ok. I have this in mind for several years, look at this https://www.alanit.com/2008/03/libra/.

I will try to create a control with Mr. Rao class, but for me it is fully usable.

Thank you very much to both of you.

Kind regards,
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: galería de imágenes

Post by Antonio Linares »

José Luis,

Using DATA lExit INIT .F. automatically initializes it to .F.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: galería de imágenes

Post by Antonio Linares »

José Luis,

A first try implementing Class TAlbum as a control:

Code: Select all

#include "FiveWin.ch"

function Main()

   local oDlg, oAlbum

   DEFINE DIALOG oDlg SIZE 1250, 800

   oAlbum = TAlbum():New( 0, 0, 1200, 800, oDlg )

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oAlbum:SetSize( 1250, 800 ),;
                oAlbum:LoadImages( ASize( DirectoryRecurse( "c:\fwh\bitmaps\*.*" ), 8 ) ) )

return nil

CLASS TAlbum FROM TPanel

   CLASSDATA lRegistered INIT .F.

   DATA   aPhotos    INIT  {} 
   DATA   nImgWidth  INIT 210
   DATA   nImgHeight INIT 300
   DATA   nGutter    INIT  30

   METHOD AddImage( cImage ) 

   METHOD DefControl( oCtrl )   
      
   METHOD Initiate( hDlg )   

   METHOD LoadImages( aImages )

ENDCLASS

METHOD DefControl( oCtrl ) CLASS TAlbum
   
   DEFAULT oCtrl:nId := oCtrl:GetNewId()

   if AScan( ::aControls, { | o | o:nId == oCtrl:nId } ) > 0
      #define DUPLICATED_CONTROLID  2
      Eval( ErrorBlock(), _FWGenError( DUPLICATED_CONTROLID, ;
                          "No: " + Str( oCtrl:nId, 6 ) ) )
   else
      AAdd( ::aControls, oCtrl )
      oCtrl:hWnd = 0
   endif

return nil   

METHOD Initiate( hDlg ) CLASS TAlbum

   local aPhoto

   if ::oWnd:IsKindOf( "TDIALOG" )
      ::Super:Initiate( hDlg )
   endif 

return nil

METHOD AddImage( cImage ) CLASS TAlbum

   local oImg, nCols := Int( ::nWidth / ::nImgWidth )
   local nRows := Int( ::nHeight / ::nImgHeight )
   local nRow := Int( Len( ::aControls ) / ( nRows * nCols ) + 0.5 )
   local nCol := Len( ::aControls ) - ( nRow * nCols )

   // MsgInfo( nRow )
   // MsgInfo( nCol )

   AAdd( ::aPhotos, cImage )

   @ ::nGutter + ( ::nImgHeight + ::nGutter ) * nRow,;
     ::nGutter + ( ::nImgWidth + ::nGutter ) * nCol;
     XIMAGE oImg OF Self ;
     SIZE ::nImgWidth, ::nImgHeight // NOBORDER

   oImg:SetSource( cImage )
   oImg:Shadow()

return nil   

METHOD LoadImages( aImages ) CLASS TAlbum

   ::aPhotos = aImages 
   AEval( ::aPhotos, { | aPhoto | ::AddImage( aPhoto[ 1 ] ) } )

return nil
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
José Luis Sánchez
Posts: 484
Joined: Thu Oct 13, 2005 9:23 am
Location: Novelda - Alicante - España
Contact:

Re: galería de imágenes

Post by José Luis Sánchez »

Thanks Antonio, the dialog version works fine, but doesn't has the scroll feature.

Regards,
User avatar
José Luis Sánchez
Posts: 484
Joined: Thu Oct 13, 2005 9:23 am
Location: Novelda - Alicante - España
Contact:

Re: galería de imágenes

Post by José Luis Sánchez »

About centering the TAlbum over the main window of my program, I do the following:

Code: Select all

   ACTIVATE WINDOW ::oWnd ;
      ON INIT ::oWnd:Center( oApp():oWndMain ) ;
      VALID (::lExit := .t.)
and I get this error:
Application
===========
Path and name: C:\alanit\develop\bitacora\bitacora.exe (32 bits)
Size: 5,786,624 bytes
Compiler version: Harbour 3.2.0dev (r1904111533)
FiveWin version: FWH 19.05
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200

Time from start: 0 hours 0 mins 4 secs
Error occurred at: 18-01-2021, 19:22:23
Error description: Error BASE/1004 No existe el m‚todo: CENTER
Args:
[ 1] = U
[ 2] = O TWINDOW

Stack Calls
===========
Called from: ..\contrib\hbct\ctmisc.prg => CENTER( 0 )
Called from: .\prg\fwh\TALBUM.PRG => (b)TALBUM_ACTIVATE( 96 )

I don't know what has hbct to do in this. In my .bc file I have:

bitacora.exe, +
bitacora.map, +
c:\fivetech\fwh1905\lib\filexls.lib +
c:\fivetech\fwh1905\lib\FiveH.lib +
c:\fivetech\fwh1905\lib\FiveHC.lib +

and some lines after I link hbct.

Regards,
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: galería de imágenes

Post by Antonio Linares »

José Luis,

It seems as ::oWnd hasn't been assigned previously

Error description: Error BASE/1004 No existe el m‚todo: CENTER
Args:
[ 1] = U

That means that ::oWnd is nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
José Luis Sánchez
Posts: 484
Joined: Thu Oct 13, 2005 9:23 am
Location: Novelda - Alicante - España
Contact:

Re: galería de imágenes

Post by José Luis Sánchez »

I don't undestand this. I'm using the same code from Mr. Rao. If I write:

Code: Select all

  oAlbum := TAlbum():New():Activate()
I don't have the error, but if I write

Code: Select all

oAlbum := TAlbum():New()
oAlbum:Activate()
I get the error.
User avatar
José Luis Sánchez
Posts: 484
Joined: Thu Oct 13, 2005 9:23 am
Location: Novelda - Alicante - España
Contact:

Re: galería de imágenes

Post by José Luis Sánchez »

Mr. Rao,

it's possible to add a method to select a image and highlight it and then with arrow keys move and select other image ?

Regards,
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: galería de imágenes

Post by Antonio Linares »

José Luis Sánchez wrote:I don't undestand this. I'm using the same code from Mr. Rao. If I write:

Code: Select all

  oAlbum := TAlbum():New():Activate()
I don't have the error, but if I write

Code: Select all

oAlbum := TAlbum():New()
oAlbum:Activate()
I get the error.
José Luis,

Please post the error.log here, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply