FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour clear the Clipboard
Posts: 30
Joined: Mon Oct 30, 2006 02:39 PM
clear the Clipboard
Posted: Sun Aug 31, 2008 06:25 PM

How to clear the Clipboard ( "Clipboard") of winxp, I am using __KEYBOARD (CHR (300)), to copy the screen, but when the Clipboard has no more space, the __KEYBOARD (CHR (300)) to working.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
clear the Clipboard
Posted: Sun Aug 31, 2008 06:31 PM

Please review fwh\samples\TestClip.prg

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 30
Joined: Mon Oct 30, 2006 02:39 PM
clear the Clipboard
Posted: Sun Aug 31, 2008 09:55 PM
Antonio, if I open the area of transfer after using oClp:Clear(), this clean, but after a while the app not save the screen, this message:
Shut one or more application to free up more memory and try again.
But if you leave the app, and return back to work.

  DEFINE ICON oIcon   FILE "IMG.ICO"
  
  DEFINE WINDOW oApp  ICON oIcon
  
  DEFINE CLIPBOARD oClp OF oApp
                              
  DEFINE TIMER oTmrIdx INTERVAL   10000 ACTION ( waitIdx( oTmrIdx,oTray,oIcon,oClp) ) OF oApp
  ACTIVATE TIMER oTmrIdx
     
  ACTIVATE WINDOW oApp ;
           ON INIT oTray := TTrayIcon():New(oApp,oIcon,"",{|nRow,nCol|MenuTray(nRow,nCol,oTray,oIcon)},{|nRow,nCol|MenuTray(nRow,nCol,oTray,oIcon)}) ;
           VALID oTray:End() ;
           ON RIGHT CLICK oTray:SetIcon( oIcon, "Another" )


RETURN NIL

FUNCTION WaitIdx( oTmrIdx,oTray,oIcon,oClp)    

  local lFileExists := .f., cDir := CurDrive()+":\"+GetCurDir()+'\'
  LOCAL Dir, vArq, vNum, nBytes
  
  oTmrIdx:Deactivate()

  __KEYBOARD(CHR(300))
  SalvaTela("Tela",oIcon)
  syswait(1)
  oClp:Clear()
  
  Release All
  RESALLFREE()
  SYSREFRESH()
  CLEAR MEMORY

  oTmrIdx:Activate()
[/b]
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
clear the Clipboard
Posted: Sun Aug 31, 2008 10:27 PM

Whats the source code for SalvaTela() ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 30
Joined: Mon Oct 30, 2006 02:39 PM
clear the Clipboard
Posted: Sun Aug 31, 2008 10:37 PM
static function SalvaTela(cFileName,oIcon)
****************************************
LOCAL oTClip, hBitmap, fBit, Result := .f.
LOCAL oBmpImage


   Default cFileName := "Tela.JPG"

   cFileName := AllTrim(cFileName)

   if AT('.jpg',lower(cFilename)) == 0
      cFileName += '.JPG'
   end

   if file("Tela.BMP")
      FERASE("Tela.BMP")
   end


   oTClip := TClipBoard():New() //New(WndMain()) 
   syswait(.1) 
   hBitmap := oTClip:GetBitMap()
   syswait(.3)
   oTClip:Close() 
   oTClip:End()
   Result := (hBitmap != 0)

   if Result

      fBit:=dibfrombitmap(hBitmap)
      SysWait(.1)
      
      dibwrite("Tela.BMP",fBit)
      
    
      FISaveImg( "Tela.BMP", "Tela.JPG", 2, 70 )

      Ferase("Tela.BMP")
      Result := File("Tela.JPG")
   else
      ?"error: not save"
   end

Return Result
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
clear the Clipboard
Posted: Sun Aug 31, 2008 10:52 PM
You have to release the bitmap and the dib, thats why you are consuming your sistem memory!
  if Result 

      fBit:=dibfrombitmap(hBitmap) 
      DeleteObject( hBitmap )
      SysWait(.1) 
      
      dibwrite("Tela.BMP",fBit) 
      GlobalFree( fBit )
    
      FISaveImg( "Tela.BMP", "Tela.JPG", 2, 70 ) 

      Ferase("Tela.BMP") 
      Result := File("Tela.JPG") 
   else 
      ?"error: not save" 
   end
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 344
Joined: Tue Oct 11, 2005 11:33 AM
clear the Clipboard
Posted: Mon Sep 01, 2008 08:34 PM
Olá Antonio,

No exemplo abaixo quando clico em "Salvar" a função "FISaveImg" sempre me retorna falso e o arquivo "TELA.JPG" é gerado com tamanho 0, porque ?

#include "fivewin.ch"

*************
function Main
*************

   local oDlg, oIco, cTest := "Hello world!   ", oClp

   DEFINE ICON oIco FILE "\fwh\icons\fivewin.ico"

   DEFINE DIALOG oDlg TITLE "I am a DialogBox" COLOR "W+/B" ;
      ICON oIco

   @ 1, 3 GET cTest

   @ 3, 5 BUTTON "&Salvar" SIZE 40, 12 ;
      ACTION SALVA( oDlg, oClp ) DEFAULT

   @ 3, 16 BUTTON "&Cancel" SIZE 40, 12 ACTION oDlg:End()

   DEFINE CLIPBOARD oClp OF oDlg 

   ACTIVATE DIALOG oDlg CENTERED ;
      VALID MsgYesNo( "Do you want to end ?" )

   oCLp:end()

return NIL

**************
function SALVA( oDlg, oClp )
**************

__KEYBOARD(CHR(300)) 

  SalvaTela( "Tela" )
  syswait(1) 
  oClp:Clear() 
  
* Release All 
* RESALLFREE() 
  SYSREFRESH() 
* CLEAR MEMORY 

return NIL

*************************
static function SalvaTela( cFileName )
*************************

LOCAL oTClip, hBitmap, fBit, Result := .f. 
LOCAL oBmpImage 


   Default cFileName := "Tela.JPG" 

   cFileName := AllTrim(cFileName) 

   if AT('.jpg',lower(cFilename)) == 0 
      cFileName += '.JPG' 
   end 

   if file("Tela.BMP") 
      FERASE("Tela.BMP") 
   end 

   oTClip := TClipBoard():New() //New(WndMain()) 
   syswait(.1) 
   hBitmap := oTClip:GetBitMap() 
   syswait(.3) 
   oTClip:Close() 
   oTClip:End() 
   Result := (hBitmap != 0) 

   if Result 

      fBit := dibfrombitmap( hBitmap ) 
      SysWait(.1) 
      dibwrite( "Tela.BMP", fBit )
      GlobalFree( fBit ) 
      DeleteObject( hBitmap ) 
      
msgstop(       FISaveImg( "Tela.BMP", "Tela.JPG", 2, 70 )  )

      Ferase("Tela.BMP") 
      Result := File("Tela.JPG") 
   else 
      ?"error: not save" 
   end 

Return Result 

static function FISAVEIMG( cSrcFile, cDstFile, nDstFormat, nQuality )

   local nSrcFormat, hDib, hDib2, lOk

   DEFAULT nQuality := 0

   hLib = LoadLibrary( "freeimage.dll" )

   nSrcFormat = FIGETFILETYPE( cSrcFile, 0 )

   hDib = FILOAD( nSrcFormat, cSrcFile, 0 )
   hDib2 = FICNV24( hDib )
   lOk = FISAVE( nDstFormat, hDib2, cDstFile, nQuality )

   FIUNLOAD( hDib )
   FIUNLOAD( hDib2 )

   FreeLibrary( hLib )

return lOk

//----------------------------------------------------------------------------//

DLL32 FUNCTION FIGETFILETYPE( cFileName AS LPSTR, nSize AS LONG ) AS LONG ;
      PASCAL FROM "_FreeImage_GetFileType@8" LIB hLib

DLL32 FUNCTION FILOAD( nFormat AS LONG, cFileName AS LPSTR, nFlags AS LONG ) AS LONG ;
      PASCAL FROM "_FreeImage_Load@12" LIB hLib

DLL32 FUNCTION FISAVE( nFormat AS LONG, hDib AS LONG, cFileName AS LPSTR, nFlags AS LONG ) AS BOOL ;
      PASCAL FROM "_FreeImage_Save@16" LIB hLib

DLL32 FUNCTION FIUNLOAD( hDib AS LONG ) AS VOID ;
      PASCAL FROM "_FreeImage_Unload@4" LIB hLib

DLL32 FUNCTION FICNV24( hDib AS LONG ) AS LONG ;
      PASCAL FROM "_FreeImage_ConvertTo24Bits@4" LIB hLib

//----------------------------------------------------------------------------//
Obrigado, Regards, Saludos



Rossine.



Harbour and Harbour++
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
clear the Clipboard
Posted: Mon Sep 01, 2008 10:43 PM

Rossine,

Has comprobado que Tela.bmp esté correcto ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 344
Joined: Tue Oct 11, 2005 11:33 AM
clear the Clipboard
Posted: Tue Sep 02, 2008 01:27 PM

Antonio,

É gerado o arquivo TELA.BMP no tamanho de 1.920.054, mas não consigo abrí-lo com o ms-paint (paint).

O paint me retorna a seguinte mensagem:

"O Paint não pode ler este arquivo. Este não é um arquivo de bitmap válido ou não há suporte para o formato atualmente."

Saludos,

Rossine.

Obrigado, Regards, Saludos



Rossine.



Harbour and Harbour++
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
clear the Clipboard
Posted: Tue Sep 02, 2008 03:16 PM

Rossine,

has comprobado que despues de hacer:

__KEYBOARD(CHR(300))

haya una copia correcta de la imagen en el clipboard ?

Por lo que comentas parece que el bitmap esta corrupto...

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 344
Joined: Tue Oct 11, 2005 11:33 AM
clear the Clipboard
Posted: Tue Sep 02, 2008 04:33 PM
Antonio,


has comprobado que despues de hacer:
__KEYBOARD(CHR(300))
haya una copia correcta de la imagen en el clipboard ?


Sim, após: __KEYBOARD(CHR(300)) ... executei o "PAINT" e colei a imagem que estava no clipboard.

Este exemplo roda bem aí com você ?

Saludos,
Obrigado, Regards, Saludos



Rossine.



Harbour and Harbour++
Posts: 344
Joined: Tue Oct 11, 2005 11:33 AM
clear the Clipboard
Posted: Tue Sep 02, 2008 04:38 PM
Rossine wrote:Antonio,


has comprobado que despues de hacer:
__KEYBOARD(CHR(300))
haya una copia correcta de la imagen en el clipboard ?


Sim, após: __KEYBOARD(CHR(300)) ... executei o "PAINT" e colei a imagem que estava no clipboard.


Baixe o arquivo TELA.BMP aqui:
http://geocities.yahoo.com.br/qiinformatica2000/TELA.ZIP

Este exemplo roda bem aí com você ?

Saludos,
Obrigado, Regards, Saludos



Rossine.



Harbour and Harbour++
Posts: 344
Joined: Tue Oct 11, 2005 11:33 AM
clear the Clipboard
Posted: Tue Sep 02, 2008 04:39 PM
Antonio,


has comprobado que despues de hacer:
__KEYBOARD(CHR(300))
haya una copia correcta de la imagen en el clipboard ?


Sim, após: __KEYBOARD(CHR(300)) ... executei o "PAINT" e colei a imagem que estava no clipboard normalmente.


Baixe o arquivo TELA.BMP aqui:
http://geocities.yahoo.com.br/qiinformatica2000/TELA.ZIP

Este exemplo roda bem aí com você ?

Saludos,
Obrigado, Regards, Saludos



Rossine.



Harbour and Harbour++
Posts: 344
Joined: Tue Oct 11, 2005 11:33 AM
clear the Clipboard
Posted: Fri Sep 05, 2008 12:05 PM

Olá,

É possível fazer isto funcionar ? :(

Gracias,

Rossine.

Obrigado, Regards, Saludos



Rossine.



Harbour and Harbour++

Continue the discussion