ExecuteReport( )

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: ExecuteReport( )

Post by Pablo César »

Obrigado Daniel, vou esperar um pouco o do FW e ver a viabilidade. Meus conhecimentos em C são limitados.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

PRINT TO PDF

Post by andyglezl »

Hola
Me pasa algo extraño con este ejemplo...
Solo funciona con la imagen que trae la carpeta: D:\HMG\3.4\SAMPLES\HPDF\HMG_HPDF\hmghpdf.png
Puede alguien probarlo, alguna idea ?
-----------------------------------------------------------------------------------------------------------------------------------------------------
hello
It happens something strange with this example ...
Only works with the image that brings the folder: D:\HMG\3.4\SAMPLES\hPDF\HMG_HPDF\hmghpdf.png
Can someone try, any ideas?
Print_to_PDF.rar
(182.66 KiB) Downloaded 256 times
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: PRINT TO PDF

Post by esgici »

andyglezl wrote: It happens something strange with this example ...
Only works with the image that brings the folder: D:\HMG\3.4\SAMPLES\hPDF\HMG_HPDF\hmghpdf.png
Can someone try, any ideas?
Hola Andres

Yes, tried,

error eliminated; but I didn't like the solution :(
LogoOfiLarge.png
LogoOfiLarge.png (105.97 KiB) Viewed 4282 times
This didn't solved but made more complex the problem :?

I hope "father" of HMG_HPDF Mr. Rathinagiri will give us the correct solution :)

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: ExecuteReport( )

Post by andyglezl »

Gracias esgici
Yo estuve haciendo pruebas con diferentes editores de imagenes y no logré
que funcionara con el tamaño de las imagenes que envié.
-------------------------------------------------------------------------------------------
Thanks esgici
I was experimenting with different editors of images and failed
that worked with the size of the images I sent.
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
Rathinagiri
Posts: 5481
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: ExecuteReport( )

Post by Rathinagiri »

I see that only images with color information about transparency are shown in HPDF.

If I enable this while saving the above image in GIMP, the image is shown in the PDF.
savepng.jpg
savepng.jpg (22.25 KiB) Viewed 4232 times
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

PRINT TO PDF

Post by andyglezl »

Bueno...
Ya pude lograr que se muestre la imagen ".PNG", pero con los ".JPG" continua el problema ???
La imagen que hice (que no se mostraba) la leí con un visor de imagenes llamado
"JPEGView" y le di guardar como (sin modificarla) y con eso ya la pude leer en el .PDF
-------------------------------------------------------------------------------------------------------
Well ...
I could already achieve picture ".PNG" is displayed, but with the ".JPG" continues the problem ???
The picture I made (not showed) I read an image viewer called
"JPEGView" and gave him save as (without modification) and with that and I read the .PDF
HPDF1.jpg
HPDF1.jpg (56.4 KiB) Viewed 4222 times
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
Rathinagiri
Posts: 5481
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: ExecuteReport( )

Post by Rathinagiri »

You have to add 'type JPG' for printing JPEG file types.

Actually this you can get from i_print.ch

Code: Select all

#xtranslate @ <nRow> , <nCol> PRINT IMAGE <cImage> ;
	WIDTH <nWidth> ;
	HEIGHT <nheight> ;
	[ <stretch : STRETCH> ] ;
   [ <transparent: TRANSPARENT> ] ;
   [ TRANSPARENTCOLOR <aTransparentColor> ];
   [ TYPE <cType:JPG,PNG> ] ;
	=> ;
   iif( _HMG_SYSDATA \[ 513 \],_HMG_HPDF_IMAGE ( <cImage> , <nRow> , <nCol> , <nheight> , <nWidth> , <.stretch.>, <"cType"> ), _HMG_PRINTER_H_IMAGE ( _HMG_SYSDATA \[ 374 \] , <cImage> , <nRow> , <nCol> , <nheight> , <nWidth> , <.stretch.> , <.transparent.> , <aTransparentColor> ) )
Type is not required for ordinary print. For PDF Print you need to mention the type.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
trmpluym
Posts: 304
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: ExecuteReport( )

Post by trmpluym »

Amarante wrote:Clearing Up ....
This routine is not of my own ... it was originally made by Rossine, who posted it on another forum and that Pablo thought was a woman. I just changed for my needs.
Run_MyProcess does not prevent the user closes their program .... you need to make use of other artifices to prevent the ever-existing, user wretched, miserable and other insults that I should not speak here to find a flaw in your program.
Another time I will show in a sample program.
------------------
Aclarar ....
Esta rutina no es de mi propia ... que fue hecho originalmente por Rossine, quien lo publicó en otro foro y que Pablo creía que era una mujer. Acabo de cambiar para mis necesidades.
Run_MyProcess no impide que el usuario cierra su programa .... lo necesario para hacer uso de otros artificios para evitar la siempre existente, el usuario desventurado, miserable y otros insultos que no debo hablar aquí para encontrar un defecto en su programa.
Otra vez voy a mostrar en un programa de ejemplo.
------------------
Esclarecendo....
Essa rotina não é de minha autoria... foi feita originalmente por Rossine, que postou ela em outro fórum e que o Pablo achava que era mulher. Eu apenas alterei para minhas necessidades.
A Run_MyProcess não impede que o usuário feche o seu programa.... você precisa fazer usar de outros artificios para impedir o sempre existente, usuário desgraçado, miseravel e outros impropérios que não devo falar aqui de achar uma falha no seu programa.
Outra hora demonstrarei em um programa exemplo.
Thanks for sharing the code ! I tried it with a simple example:

Run_MyProcess( "notepad test.txt")

But i get the error:

Date:04/27/15 Time: 11:20:14
Error BASE/1081 Argument error: +

Called from GETFORMHANDLE(3685)
Called from RUN_MYPROCESS(46)
Called from RUNMYPROCESS(1)

Line 46 of the PRG RUN_MYPROCESS is:

SetLayeredWindowAttributes( GetFormHandle( cWin_ ), 0, 180, LWA_ALPHA )

Also the build.log contains the following error:

Cannot open EVENTS.prg, assumed external

Do i miss some code or do i do something wrong ?
User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL
Location: Araruama-RJ, Brazil

Re: ExecuteReport( )

Post by Amarante »

trmpluym,
Test by inserting the line:
#include "fileio.ch"
See the example below:

Code: Select all

#include "hmg.ch"
#include "fileio.ch"

Function Main

	DEFINE WINDOW Win_1 ;
		ROW 0 ;
		COL 0 ;
		WIDTH 640 ;
		HEIGHT 480 ;
		TITLE 'Test' ;
		WINDOWTYPE MAIN
    
    @ 030,160 BUTTON Button_1 CAPTION "Create & Open Test.txt" ACTION {||Test1()} WIDTH 290

	END WINDOW

	Win_1.Center

	Win_1.Activate

Return

PROCEDURE Test1()
  hb_memowrit( "test.txt", "Test File..." )
  Run_MyProcess( "notepad test.txt")
  RETURN

/**
*
* Run_MyProcess
*
* Description: Executes an external process
* Syntax.....: Run_MyProcess( <expC1>, [expL1], [expB1], [expN1], [expN2] )
* Parameters.: <expC1> - Expression of process running
*              [expL1] - Wait on process (default .T.)
*              [expB1] - Block-function to be performed during the process
*              [expN1] - Time (default 1)
*              [expN2] - Number of times to perform the block-function (default 0)
* Return.....: expN - Result of the process
* Example....:
*   Run_MyProcess( "SumatraPDF.exe " + "Certidao.PDF", .T. )
*   ------ other sample -----
*   hb_memowrit( "test.txt", "Test File..." )
*   ? "Retorno:", Run_MyProcess( "notepad test.txt", .T., { || QOUT( "Waiting Notepad close..." ) }, 1 )
*   WAIT "When you get here notepad already ended. press ENTER..."
*   ? "Retorno:", Run_MyProcess( "notepad test.txt", .F. )
*   WAIT "When you get here notepad is still running. press ENTER..."
*   ? "Retorno:", Run_MyProcess( "notepad test.txt",, { | nCtd | QOUT( "Waiting Notepad close (" + hb_ntos( 5 - nCtd ) + ")..." ) },, 5 )
*   WAIT "The Loop was closed after in 5 seconds..."
*   ? "Retorno:", Run_MyProcess( "notepad test.txt",, { | nCtd | QOUT( "Forcing the closure of Notepad by returning the codeblock..." ), IIF( nCtd = 2, .F., .T. ) } )
*   WAIT "The Loop was closed..."
*
*/
FUNCTION Run_MyProcess( cExecute, lWait, bBlock, nTime, nOccurs )

  #define LWA_ALPHA    0x02

  LOCAL cWin_ := _HMG_SYSDATA[ 316 ]                      // Name of the current window
  LOCAL hProcess
  LOCAL nCtd := 0
  LOCAL nResult
  LOCAL lRet

  __DefaultNIL( @lWait, .T. )
  __DefaultNIL( @nTime, 1 )
  __DefaultNIL( @nOccurs, 0 )

  hProcess := HB_ProcessOpen( cExecute )
  IF hProcess <> F_ERROR
    SetLayeredWindowAttributes( GetFormHandle( cWin_ ), 0, 180, LWA_ALPHA )
    DO WHILE ( nResult := HB_ProcessValue( hProcess, .F. ) ) == - 1
      DO EVENTS
      IF .NOT. lWait
        EXIT
      ENDIF
      nCtd += 1
      IF HB_IsBlock( bBlock )
        lRet := EVAL( bBlock, nCtd )
        IF HB_IsLogical( lRet ) .AND. .NOT. lRet
          HB_ProcessClose( hProcess, .T. )
          EXIT
        ENDIF
      ENDIF
      IF nTime > 0
        HB_IdleSleep( nTime )
      ENDIF
      IF nCtd == nOccurs
        HB_ProcessClose( hProcess, .T. )
        EXIT
      ENDIF
    ENDDO
    SetLayeredWindowAttributes( GetFormHandle( cWin_ ), 0, 255, LWA_ALPHA )
  ELSE
    MsgInfo( "Error Open Process" )
  ENDIF
  RETURN nResult
trmpluym
Posts: 304
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: ExecuteReport( )

Post by trmpluym »

Hi Amarante,

Works like a charm :D

Many thanks again for sharing the code !

Theo
Post Reply