Print preview in HMG Console mode

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Print preview in HMG Console mode

Post by sudip »

Hello All,

Is there any way to preview the reports in console mode of HMG?

Just now one of my friends (Mr. Manohar Maski) asked me how to see print preview with HMG in console mode. I don't know.

He used SELECT PRINTER command and is very happy to see his old Clipper app is now printing on Windows printers :)

Thanks in advance. :)
With best regards,
Sudip
jparada
Posts: 430
Joined: Fri Jan 23, 2009 5:18 pm

Re: Print preview in HMG Console mode

Post by jparada »

Hi Sudip,

Please take a look:

http://hmgforum.com/viewtopic.php?f=5&t=1504

Maybe this will help to you

Best Regards
Javier
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Print preview in HMG Console mode

Post by Rathinagiri »

With Javier's help, I had created a small sample. I think this would work.

Code: Select all

#include <hmg.ch>

Function Main
define window dummy at 0,0 width 0 height 0 main nocaption nosysmenu on init startmain() 
end window
activate window dummy
Return

function startmain
?"Now starting the program."
wait 
select printer default preview
start printdoc
start printpage
@ 20,20 print "This is a test print"
end printpage
end printdoc
?"Now ending the program"
wait
endmain()
return nil


function endmain
release window dummy
return nil
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3723
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Print preview in HMG Console mode

Post by mol »

Fine example. Till now, I thought it isn't possible because of not activation main window.

Thanks, Rathi!
Last edited by mol on Mon Sep 20, 2010 5:27 am, edited 1 time in total.
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Print preview in HMG Console mode

Post by sudip »

Hello,

Thank you Rathi.

Here is my code: (some idea taken from J.Parada and I wrote it before seeing Rathi's code.)

Code: Select all

#include <hmg.ch>

// here is our main window
function Main()
   define window winMain at 0, 0 width 100 height 100 main noshow ;
      on init ConsoleMain()
   end window
   activate window winMain
   return nil
   
   
// here comes our old clipper / harbour console codes 
function ConsoleMain()
   
   clear screen
   @ 1, 1 to maxrow()-1, maxcol()-1 double
       
   @ maxrow()-2, 1 say "Press any key to start print preview in console mode ..."
   inkey(0)
   
   PrintTest()
   
   clear screen
   @ maxrow()-2, 1 say "Print test done. Press any key to quit ..."
   inkey (0)
   
   thiswindow.release()
    
   retur nil
   
   
// here comes print test   
Function PrintTest()
   SELECT PRINTER DEFAULT PREVIEW
   
   START PRINTDOC NAME "Print from HMG Console Mode"
   START PRINTPAGE
   
   @ 100, 100 print "This is print test from HMG Console Mode" 
   
   END PRINTPAGE
   END PRINTDOC
   
   return nil
   
With best regards,
Sudip
User avatar
mol
Posts: 3723
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Print preview in HMG Console mode

Post by mol »

I'm returning to this topic. I want to ask if it's possible to move focus to console and from console to window?
I've used Rathi' sample, it works fine, but after running program, text console doesn't get focus. We need to move to it via ALT-Tab or mouse key.
When I activate window form, focus is still at console...
Marek
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Print preview in HMG Console mode

Post by Rathinagiri »

I am afraid it is not possible.

The reason is, after we give the command end printdoc the preview window is released, however the dummy window is not released. If we release that window, the application is closed immediately.

I think Roberto can help in this regard.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: Print preview in HMG Console mode

Post by Roberto Lopez »

rathinagiri wrote:I am afraid it is not possible.

The reason is, after we give the command end printdoc the preview window is released, however the dummy window is not released. If we release that window, the application is closed immediately.

I think Roberto can help in this regard.
If you want to set the focus to a non HMG generated window (like console) you must code a little of C and WinAPI.

The easier way is to locate the window by his title and then operate on it to (ie) give the focus.

AFAIR, at least one of the Grigory's utilities does it.

I gues that him is the right person to help you here.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
gfilatov
Posts: 1070
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Print preview in HMG Console mode

Post by gfilatov »

mol wrote:I'm returning to this topic. I want to ask if it's possible to move focus to console and from console to window?
I've used Rathi' sample, it works fine, but after running program, text console doesn't get focus. We need to move to it via ALT-Tab or mouse key.
When I activate window form, focus is still at console...
Hi Marek,

Please be so kind to revise the following mixed mode sample:

Code: Select all

#include "minigui.ch"

Function Main

    SET STATIONNAME TO "MAINPROC"
    _HMG_Commpath:= GetCurrentFolder()+"\"

    DEFINE WINDOW Form_1 ;
        AT 0,0 ;
        WIDTH 640 HEIGHT 480 ;
        TITLE 'Harbour MiniGUI Demo' ;
        MAIN ;
        FONT 'Arial' SIZE 10
        
        DEFINE LABEL Label1
            ROW 10
            COL 10
            VALUE "Good morning"   
        END LABEL 

        DEFINE GETBOX Box11
            ROW 10
            COL 100
            VALUE 2.5
            PICTURE '999,999,999,999.9999'
        END GETBOX 

        DEFINE BUTTON Btn1
            ROW 50
            COL 10
            CAPTION 'DOS 1'
            ACTION THIS.CAPTION:=ALLTRIM(STR(GETDATA(FN1())))
        END BUTTON

        DEFINE BUTTON Btn2
            ROW 100
            COL 10
            CAPTION 'Message'
            ACTION  FN2(3)
        END BUTTON

        DEFINE BUTTON Btn4
            ROW 150
            COL 10
            CAPTION 'EXIT'
            ACTION Form_1.release
        END BUTTON

    END WINDOW

    HideConsole()
    Form_1.Center()
    Form_1.Activate()
Return Nil

FUNCTION FN1()
LOCAL r1 := 0
LOCAL r2 := 0
MEMVAR GetList
    HIDE WINDOW Form_1
    ShowConsole()
    CLEAR SCREEN

    @ 10,10 SAY ' S1 ' GET r1 pict '9999'
    @ 12,10 SAY ' S2 ' GET r2 pict '9999'
    READ
    SENDDATA("MAINPROC",R2)
    HideConsole()
    RESTORE WINDOW Form_1
RETURN NIL


FUNCTION FN2(n)
LOCAL i
    HIDE WINDOW Form_1
    ShowConsole()
    CLEAR SCREEN
    FOR i:=1 TO n
        ?i
    NEXT 
    WAIT
    HideConsole()
    RESTORE WINDOW Form_1
    MsgBox('bla'+TRANSFORM(n,'99'),'Title')
RETURN NIL


#pragma BEGINDUMP

#include <windows.h>
#include "hbapi.h"
#include "hbapiitm.h"

HB_FUNC( HIDECONSOLE )
{
    ShowWindow(( HWND) FindWindow( NULL, "demo" ), SW_MINIMIZE);
}

HB_FUNC( SHOWCONSOLE )
{
    ShowWindow(( HWND) FindWindow( NULL, "demo" ), SW_RESTORE);
}

#pragma ENDDUMP
Hope that give you an idea(s) :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Print preview in HMG Console mode

Post by Rathinagiri »

Nice example Grigory. Thanks. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply