Page 2 of 4
Re: galería de imágenes
Posted: Sat Jan 16, 2021 7:47 am
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 | Expand
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
Re: galería de imágenes
Posted: Sat Jan 16, 2021 3:08 pm
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.

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
Re: galería de imágenes
Posted: Sun Jan 17, 2021 12:17 pm
by nageswaragunupudi
Can you see if MDI application suits you?
Please try this and let us have your response.
Code: Select all | Expand
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
Re: galería de imágenes
Posted: Sun Jan 17, 2021 3:39 pm
by nageswaragunupudi
Sorry, I did not see the above two postings.
Nice.
Re: galería de imágenes
Posted: Sun Jan 17, 2021 5:43 pm
by Antonio Linares
José Luis,
Is your main window MDI ?
Re: galería de imágenes
Posted: Sun Jan 17, 2021 6:15 pm
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,
Re: galería de imágenes
Posted: Sun Jan 17, 2021 6:28 pm
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 | Expand
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,
Re: galería de imágenes
Posted: Mon Jan 18, 2021 7:49 am
by Antonio Linares
José Luis,
Using DATA lExit INIT .F. automatically initializes it to .F.
Re: galería de imágenes
Posted: Mon Jan 18, 2021 11:48 am
by Antonio Linares
José Luis,
A first try implementing Class TAlbum as a control:
Code: Select all | Expand
#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
Re: galería de imágenes
Posted: Mon Jan 18, 2021 5:29 pm
by José Luis Sánchez
Thanks Antonio, the dialog version works fine, but doesn't has the scroll feature.
Regards,
Re: galería de imágenes
Posted: Mon Jan 18, 2021 6:28 pm
by José Luis Sánchez
About centering the TAlbum over the main window of my program, I do the following:
Code: Select all | Expand
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,
Re: galería de imágenes
Posted: Tue Jan 19, 2021 9:48 am
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
Re: galería de imágenes
Posted: Tue Jan 19, 2021 3:33 pm
by José Luis Sánchez
I don't undestand this. I'm using the same code from Mr. Rao. If I write:
I don't have the error, but if I write
I get the error.
Re: galería de imágenes
Posted: Tue Jan 19, 2021 3:35 pm
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,
Re: galería de imágenes
Posted: Tue Jan 19, 2021 4:18 pm
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:
I don't have the error, but if I write
I get the error.
José Luis,
Please post the error.log here, thanks