Aqui est谩 la Clase TMetro modificada para poder variar la posici贸n del t铆tulo, dia, mes y hora. Incluimos estos cambios en el pr贸ximo build de FWH.
* Enhancement: Class TMetro was exiting when clicking on the window, now it is ok. New DATAs for the
title, day, month and hour, so they can be placed on different coordinates. Many thanks to Armando feedback!
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
CLASS TMetro
聽 聽DATA 聽oWnd, oFont, oFontB
聽 聽DATA 聽cFileName
聽 聽DATA 聽aButtons
聽 聽DATA 聽nOriginX, nOriginY
聽 聽DATA 聽nBtnWidth, nBtnHeight
聽 聽DATA 聽cTitle
聽 聽DATA 聽nRow, nCol
聽 聽DATA 聽oTimer
聽 聽DATA 聽hBitmap
聽 聽DATA 聽nTimeRow 聽INIT 聽13
聽 聽DATA 聽nTimeCol 聽INIT 135
聽 聽DATA 聽nTitleRow INIT 聽 3
聽 聽DATA 聽nTitleCol INIT 聽16
聽 聽DATA 聽nDayRow 聽 INIT 聽 2
聽 聽DATA 聽nDayCol 聽 INIT 130
聽 聽DATA 聽nMonthRow INIT 聽 7
聽 聽DATA 聽nMonthCol INIT 130
聽 聽
聽 聽METHOD New( cTitle, nBtnWidth, nBtnHeight, cFileName )
聽 聽
聽 聽METHOD Activate()
聽 聽
聽 聽METHOD AddButton( cCaption, nClrText, nClrPane, lLarge, cImgName, bAction )
聽 聽
聽 聽METHOD End() INLINE ::oWnd:End(), ::oFont:End(), ::oFontB:End(), DeleteObject( ::hBitmap )
聽 聽
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( cTitle, nBtnWidth, nBtnHeight, cFileName ) CLASS TMetro
聽 聽DEFAULT cTitle := "MyApp", nBtnWidth := 132, nBtnHeight := 132
聽 聽
聽 聽::cTitle 聽 聽 = cTitle
聽 聽::aButtons 聽 = {}
聽 聽::nBtnWidth 聽= nBtnWidth
聽 聽::nBtnHeight = nBtnHeight
聽 聽::nOriginX 聽 = 200
聽 聽::nOriginY 聽 = 200
聽 聽::nRow 聽 聽 聽 = 聽 0
聽 聽::nCol 聽 聽 聽 = 聽 0
聽 聽
聽 聽if File( cFileName )
聽 聽 聽 ::hBitmap = ReadBitmap( 0, cFileName )
聽 聽endif 聽 聽
聽
聽 聽DEFINE FONT ::oFont NAME "Segoe UI Light" SIZE 0, -52
聽 聽DEFINE FONT ::oFontB NAME "Segoe UI Light" SIZE 0, -60 BOLD
聽 聽DEFINE WINDOW ::oWnd STYLE nOr( WS_POPUP, WS_VISIBLE ) ;
聽 聽 聽 COLOR CLR_WHITE, RGB( 15, 109, 57 )
聽 聽
聽 聽DEFINE TIMER ::oTimer OF ::oWnd ACTION ::oWnd:Say( ::nTimeRow, ::nTimeCol, Time(),, CLR_BLACK, ::oFontB )
聽 聽
聽 聽ACTIVATE TIMER ::oTimer
聽 聽
return Self 聽
//----------------------------------------------------------------------------//
聽 聽
METHOD Activate() CLASS TMetro
聽 聽ACTIVATE WINDOW ::oWnd MAXIMIZED ;
聽 聽 聽 ON PAINT ( cPS,;
聽 聽 聽 聽 聽 聽 聽 聽 聽DrawBitmap( hDC, ::hBitmap, 0, 0, GetSysMetrics( 0 ), GetSysMetrics( 1 ) ),;
聽 聽 聽 聽 聽 聽 聽 聽 聽::oWnd:Say( ::nTitleRow, ::nTitleCol, ::cTitle,,, ::oFont,, .T. ),;
聽 聽 聽 聽 聽 聽 聽 聽 聽::oWnd:Say( ::nDayRow, ::nDayCol, CDoW( Date() ),,, ::oFont,, .T. ),;
聽 聽 聽 聽 聽 聽 聽 聽 聽::oWnd:Say( ::nMonthRow, ::nMonthCol, CMonth( Date() ) + " " + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽AllTrim( Str( Day( Date() ) ) ),,, ::oFont,, .T. ) )
return nil 聽
//----------------------------------------------------------------------------//
METHOD AddButton( cCaption, nClrText, nClrPane, lLarge, cImgName, bAction ) CLASS TMetro
聽 聽local oBtn
聽 聽local nX := ::nOriginX + ( ::nRow * ( ::nBtnHeight + 8 ) )
聽 聽local nY := ::nOriginY + ( ::nCol * ( ::nBtnWidth + 8 ) )
聽 聽
聽 聽DEFAULT lLarge := .F.
聽 聽
聽 聽if File( cImgName )
聽 聽 聽 @ nX, nY BTNBMP oBtn ;
聽 聽 聽 聽 聽SIZE ( ::nBtnWidth * If( lLarge, 2, 1 ) ) + If( lLarge, 8, 0 ), ::nBtnHeight ;
聽 聽 聽 聽 聽OF ::oWnd PROMPT cCaption NOBORDER FILENAME cImgName
聽 聽else 聽
聽 聽 聽 @ nX, nY BTNBMP oBtn ;
聽 聽 聽 聽 聽SIZE ( ::nBtnWidth * If( lLarge, 2, 1 ) ) + If( lLarge, 8, 0 ), ::nBtnHeight ;
聽 聽 聽 聽 聽OF ::oWnd PROMPT cCaption NOBORDER RESOURCE cImgName
聽 聽endif 聽
聽 聽 聽
聽 聽oBtn:bAction = bAction 聽
聽 聽 聽
聽 聽oBtn:SetColor( nClrText, nClrPane ) 聽 聽
聽 聽
聽 聽AAdd( ::aButtons, oBtn )
聽 聽
聽 聽::nCol++
聽 聽if lLarge
聽 聽 聽 ::nCol++
聽 聽endif 聽
聽 聽if ( ATail( ::aButtons ):nLeft + ATail( ::aButtons ):nWidth ) > ( ::nOriginY * 4 ) + 50
聽 聽 聽 ::nRow++
聽 聽 聽 ::nCol = 0
聽 聽endif 聽
聽 聽
return nil 聽 聽
//----------------------------------------------------------------------------//