Page 1 of 1

HELP FOR CONSOLE MODE PREVIEW REPORT

Posted: Mon Dec 30, 2013 1:37 am
by henglongbike
I'm a newbird here, please help.

After preview the test report, I can not return back to console mode and program closed.

I make a sample cobe here.

Code: Select all

#include <hmg.ch>

REQUEST HB_GT_WIN_DEFAULT
SETMODE(25,80)

? "Now starting the program."
Wait 

PrintJob()

? "Now ending the program"
Wait

RETURN

Function PrintJob()
	DEFINE WINDOW dummy ;
		at 0,0 ;
		width 0 ;
		height 0 ;
		main ;
		nocaption ;
		nosysmenu ;
		on init StartMain() 
	END WINDOW
	ACTIVATE WINDOW dummy
RETURN

Function StartMain()
	select printer default preview
	start printdoc
	start printpage
	@ 20,20 print "This is a test print"
	end printpage
	end printdoc
	EndPrintJob()
RETURN NIL

Function EndPrintJob()
dummy.release
RETURN NIL

Re: HELP FOR CONSOLE MODE PREVIEW REPORT

Posted: Mon Dec 30, 2013 3:18 am
by Javier Tovar
Hola henglongbike

Quita la linea indicada. / Removes the specified line.


Function StartMain()
select printer default preview
start printdoc
start printpage
@ 20,20 print "This is a test print"
end printpage
end printdoc
EndPrintJob()
RETURN NIL

Saludos/regards

Re: HELP FOR CONSOLE MODE PREVIEW REPORT

Posted: Mon Dec 30, 2013 7:19 am
by mol
Always, when you elease main window, your application will end

Re: HELP FOR CONSOLE MODE PREVIEW REPORT

Posted: Mon Dec 30, 2013 4:34 pm
by henglongbike
Thank Javier Tovar & mol

I have removed the function EndPrintJob(),

also got the problem. It can not return back to console mode.

Can not display "Now ending the program" & wait.

And I see this

viewtopic.php?f=5&t=178
Mixed-Mode: Continue console after gui-window is released

I don't how to do it.

Code: Select all

Code:
#include <minigui.ch>

procedure main
   Load Window dummy as main && is an invisble main window, that calls dummy_onInit()
   main.Activate
return

function dummy_onInit()
   * Console-Part
   ? "Hello world"
   gui_function() && Calls the visible window
   * After the user closes the window, the console-part will continue
   ? "Welcome back!"
   ? "Program will terminate in 5 seconds"
   inkey(5)
   main.release
return

function gui_function()
   Load Window window1 && is a MODAL window
   window1.Center
   window1.activate
return

Re: HELP FOR CONSOLE MODE PREVIEW REPORT

Posted: Wed Jan 01, 2014 3:49 pm
by henglongbike
Please help !!

I have some clipper program need to run in window 8 64bit,

it's need to run between console mode and GUI.

Re: HELP FOR CONSOLE MODE PREVIEW REPORT

Posted: Thu Jan 02, 2014 11:58 am
by srvet_claudio
Hi Henglongbike,
this is equivalent to the previous example:

Code: Select all

#include <hmg.ch>

REQUEST HB_GT_WIN_DEFAULT

Function Main
   DEFINE WINDOW Form_Main;
      AT 0,0 ;
      WIDTH 100; 
      HEIGHT 100;
      MAIN;
      NOSHOW;
      ON INIT ProcMixMode()

   END WINDOW
   ACTIVATE WINDOW Form_Main
Return Nil


Procedure ProcMixMode()
// Console-Part
   SETMODE (25,80)
   ? "Hello world"
   Wait "Press key to continue..."

// Calls the visible window
   GUI_Function()

// After the user closes the window, the console-part will continue
   ?
   ? "Welcome back!"
   ? "Program will terminate in 5 seconds"
   Inkey(5)

// Close the program
   Form_Main.Release
Return


Procedure GUI_Function()
   DEFINE WINDOW Form_Modal;
      AT 0,0 ;
      WIDTH  300; 
      HEIGHT 300;
      TITLE "GUI_Function";
      MODAL

      @ 50,  100 LABEL  Label_1  VALUE "This a modal Window"
      @ 200, 100 BUTTON Button_1 CAPTION "OK" ACTION MsgInfo ("Hello")

   END WINDOW
   CENTER WINDOW Form_Modal
   ACTIVATE WINDOW Form_Modal
Return

In HMG.3.2 exists the trick: SET WINDOW MAIN ON/OFF (see demo in C:\hmg.3.2\SAMPLES\Miscellaneous\ScreenSplash)

Code: Select all

#include <hmg.ch>

REQUEST HB_GT_WIN_DEFAULT

Function Main
// Console-Part
   SETMODE (25,80)
   ? "Hello world"
   Wait "Press key to continue..."

// Calls the visible window
   GUI_Function()

// After the user closes the window, the console-part will continue
   ?
   ? "Welcome back!"
   ? "Program will terminate in 5 seconds"
   Inkey(5)
Return


Procedure GUI_Function()
   SET WINDOW MAIN OFF
   
   DEFINE WINDOW Form_Modal;
      AT 0,0 ;
      WIDTH  300; 
      HEIGHT 300;
      TITLE "GUI_Function";
      MODAL

      @ 50,  100 LABEL  Label_1  VALUE "This a modal Window"
      @ 200, 100 BUTTON Button_1 CAPTION "OK" ACTION MsgInfo ("Hello")

   END WINDOW
   CENTER WINDOW Form_Modal
   ACTIVATE WINDOW Form_Modal
   
   SET WINDOW MAIN ON
Return

Re: HELP FOR CONSOLE MODE PREVIEW REPORT

Posted: Thu Jan 02, 2014 1:38 pm
by srvet_claudio
This demo is with print command:

Code: Select all

#include <hmg.ch>

REQUEST HB_GT_WIN_DEFAULT

Function Main
   DEFINE WINDOW Form_Main;
      AT 0,0 ;
      WIDTH 100; 
      HEIGHT 100;
      MAIN;
      NOSHOW;
      ON INIT ProcMixMode()

   END WINDOW
   ACTIVATE WINDOW Form_Main
Return Nil


Procedure ProcMixMode()
// Console-Part
   SETMODE (25,80)
   ? "Hello world"
   Wait "Press key to continue..."

// Calls the visible window
   GUI_Function()

// After the user closes the window, the console-part will continue
   ?
   ? "Welcome back!"
   ? "Program will terminate in 5 seconds"
   Inkey(5)

// Close the program
   Form_Main.Release
Return


Procedure GUI_Function()
   DEFINE WINDOW Form_Print;
      AT 0,0 ;
      WIDTH  30; 
      HEIGHT 30;
      NOSHOW;
      CHILD

      DEFINE TIMER Timer_1 INTERVAL 300 ACTION Proc_Print()
 
   END WINDOW
   CENTER WINDOW Form_Print
   ACTIVATE WINDOW Form_Print
Return


Procedure Proc_Print()
   Form_Print.Timer_1.Release

   select printer default preview
   start printdoc
   start printpage
   @ 20,20 print "This is a test print"
   end printpage
   end printdoc
   
   Form_Print.Release
Return

Re: HELP FOR CONSOLE MODE PREVIEW REPORT

Posted: Thu Jan 02, 2014 4:18 pm
by henglongbike
Thank srvet_claudio,

Great ! The code is work !

I will write in my program.

Thank you for help.