FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Fuente sin destruir
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Fuente sin destruir
Posted: Fri Mar 13, 2015 04:24 PM

Buscando recursos y funetes sin destruir , checkres me devuelve esto :

13-03-2015 17:12:46: FONT,-1442181153,TMDIFRAME:GETFONT(2868)->TMDICLIENT:GETFONT(2845)->TMDICLIENT:NEW(146)->TMDIFRAME:NEW(171)->MAIN(306)

al salir de de mdiclient no se libera la fuente automaticamante ?
Saludos.

Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: Fuente sin destruir
Posted: Fri Mar 13, 2015 06:49 PM

+1
Es el unico recurso que se me queda "colgado" en mis programas.

Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Fuente sin destruir
Posted: Sat Mar 14, 2015 07:18 AM
Este ejemplo aqui no deja nada:

Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oWnd

   SetResDebug( .T. )

   DEFINE WINDOW oWnd MDI 

   ACTIVATE WINDOW oWnd

   CheckRes()
   WinExec( "notepad checkres.txt" )

return nil


y este tampoco:
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oWnd, oFont

   SetResDebug( .T. )

   DEFINE FONT oFont NAME "Verdana" SIZE 0, -10

   DEFINE WINDOW oWnd MDI 
   
   oWnd:SetFont( oFont )    

   ACTIVATE WINDOW oWnd

   oFont:End()

   CheckRes()
   WinExec( "notepad checkres.txt" )

return nil


Podeis proporcionar un ejemplo ? gracias
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: Fuente sin destruir
Posted: Sat Mar 14, 2015 02:44 PM

Antonio, tu segundo ejemplo me ha dado la solucion.
Tenia oWnd:oFont := oFont en vez de oWnd:SetFont(oFont)
Gracias

Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Fuente sin destruir
Posted: Sat Mar 14, 2015 03:18 PM

Muy bien! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Fuente sin destruir
Posted: Sat Mar 14, 2015 05:00 PM
En mi caso era algo mas complicado ...
Dejo aqui la solución por si a alguien le pasa lo mismo.
Lo que no entiendo es porque me lo marca como que es de mdichild cuando es de un txbrowse..
tengo un una clase derivada de txBrowse para que todos los browses muestren el mismo "estilo" ...

Code (fw): Select all Collapse
CLASS MyBrowse FROM TXBrowse
   CLASSDATA lRegistered AS LOGICAL // This is compulsory for derived classes
    METHOD New( oWnd ) CONSTRUCTOR 
 ENDCLASS


METHOD New( oWnd ) CLASS MyBrowse

   DEFINE FONT ::oFont NAME "Arial" SIZE 0, -15   // aqui desaparece el font 
   ::Super:New( oWnd )

  //   DEFINE FONT ::oFont NAME "Arial" SIZE 0, -15 // aqui se mantiene el font al salir ...
    
   ::lKineticBrw:= .f.
   ::l2007:= .t.
   ::bClrHeader   := ;
   ::bClrFooter   := {|| { GetSysColor( COLOR_BTNTEXT ), If( ::l2007, nRGB( 229, 229, 229 ), GetSysColor( COLOR_BTNFACE ) ), ;
                           nRGB( 149, 149, 149 ), nRGB( 230, 230, 230 ) } }
     
   ........
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Fuente sin destruir
Posted: Sat Mar 14, 2015 05:23 PM
Mas sobre el tema ...
¿ Cual es la manera correcta de asignar fuentes a oCol:oHeaderFont y oCol:oFooterFont y luego destruirlas ?

Si se hace así la fuente se queda ...
Code (fw): Select all Collapse
  DEFINE FONT oheaderFONT NAME "Arial" SIZE 0, -8

 oBrw := TxBrowse():New( ::oWnd )
   oCol := oBrw:AddCol()
      WITH OBJECT oCol
         :cHeader  := "Descripción"
         :oHeaderFont := oheaderFONT
         :bStrData  := { || left((::calias)->descrip ,32 ) }
          :nWidth := 290
       END
 obrw:SetRDD()
  obrw:CreateFromCode()

  // oHeaderFont:end()  // si la destruyo aqui no se aplica al browse.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Fuente sin destruir
Posted: Sat Mar 14, 2015 07:46 PM
If you created a font like this:
Code (fw): Select all Collapse
METHOD New( oWnd ) CLASS MyBrowse

   DEFINE FONT ::oFont NAME "Arial" SIZE 0, -15   // aqui desaparece el font

oBrw:Destroy() takes care of releasing this font and there should be no problem.

When we assign a font to header or footer or data, the font object's counter is not incremented. So xbrowse does not need to destroy the font.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Fuente sin destruir
Posted: Sat Mar 14, 2015 09:38 PM
Ok .If a Font is assign to a headerFont we have to destroy it.
If we are to assign in a derived class, we add that destruction within the method destroy().

ok. Si asignamos una fuente al header o al footer , es responsabilidad nuestra destruirla.
Si pretendemos asignarla dentro de una clase derivada , tendremos que añadir esa destrucción dentro del metodo destroy()

Code (fw): Select all Collapse
#include "fivewin.ch"
#include "xbrowse.ch"

function TestMain()

   local oWnd
   local oBrw
   local oBar
   local lEmpty := .f.
   local oHeaderFont
   local aArray := {}
   
    SetResDebug( .t. )
   
      DEFINE FONT oheaderFONT NAME "Arial" SIZE 0, -28
   
   DEFINE WINDOW oWnd TITLE "Testing Autosave Data" 
   
  
   if empty( aArray )                          
      aArray := {{"one","two","three","four"},;
        {"one","two","three","four"},;
        {"one","two","three","four"},;
        {"one","two","three","four"}}    
   endif

   
   @ 0,0 XBROWSE oBrw OF oWnd ;
      COLUMNS {1,2,3,4} ;
      HEADERS {"Activated-1","Activated-2","Deactivated-1","DeActivated-2"} ;
      array aArray LINES CELL fastedit
   
   oBrw:aCols[ 1 ]:lAutoSave := .t.
   oBrw:aCols[ 2 ]:lAutoSave := .t.
   
   oBrw:aCols[ 2 ]:oHeaderFont := oheaderFONT
   
   aeval( oBrw:aCols, { |oCols| oCols:nEditType := EDIT_GET } )
   
   oWnd:oClient := oBrw
   
   oBrw:createfromcode()
   
   activate window oWnd 
      
  oheaderFONT:end()    // matar la fuente del header 

   checkres()
     
return nil
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Fuente sin destruir
Posted: Sat Mar 14, 2015 09:44 PM

Parent class' destroy method already provides for destruction of ::oFont.
You do not need to do anything in your derived class

Regards



G. N. Rao.

Hyderabad, India
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Fuente sin destruir
Posted: Sun Mar 15, 2015 09:58 AM
nageswaragunupudi wrote:Parent class' destroy method already provides for destruction of ::oFont.
You do not need to do anything in your derived class


If oFontheader:end() is disable in the above example

03/14/15 22:26:32: C:\fwh\samples\xbcell.exe -- FONT,1611271663,TESTMAIN(15)

Continue the discussion