Page 1 of 2
Print preview in HMG Console mode
Posted: Thu Aug 12, 2010 5:30 am
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.

Re: Print preview in HMG Console mode
Posted: Thu Aug 12, 2010 5:51 am
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
Re: Print preview in HMG Console mode
Posted: Thu Aug 12, 2010 7:54 am
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
Re: Print preview in HMG Console mode
Posted: Thu Aug 12, 2010 8:41 am
by mol
Fine example. Till now, I thought it isn't possible because of not activation main window.
Thanks, Rathi!
Re: Print preview in HMG Console mode
Posted: Thu Aug 12, 2010 11:18 am
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
Re: Print preview in HMG Console mode
Posted: Mon Sep 20, 2010 5:30 am
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
Re: Print preview in HMG Console mode
Posted: Mon Sep 20, 2010 6:31 am
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.
Re: Print preview in HMG Console mode
Posted: Mon Sep 20, 2010 12:56 pm
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.
Re: Print preview in HMG Console mode
Posted: Mon Sep 20, 2010 1:19 pm
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)

Re: Print preview in HMG Console mode
Posted: Mon Sep 20, 2010 1:44 pm
by Rathinagiri
Nice example Grigory. Thanks.
