HELP FOR CONSOLE MODE PREVIEW REPORT

HMG en Español

Moderator: Rathinagiri

Post Reply
henglongbike
Posts: 8
Joined: Fri Sep 21, 2012 3:05 am

HELP FOR CONSOLE MODE PREVIEW REPORT

Post 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
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: HELP FOR CONSOLE MODE PREVIEW REPORT

Post 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
User avatar
mol
Posts: 3805
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HELP FOR CONSOLE MODE PREVIEW REPORT

Post by mol »

Always, when you elease main window, your application will end
henglongbike
Posts: 8
Joined: Fri Sep 21, 2012 3:05 am

Re: HELP FOR CONSOLE MODE PREVIEW REPORT

Post 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
henglongbike
Posts: 8
Joined: Fri Sep 21, 2012 3:05 am

Re: HELP FOR CONSOLE MODE PREVIEW REPORT

Post 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.
User avatar
srvet_claudio
Posts: 2223
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: HELP FOR CONSOLE MODE PREVIEW REPORT

Post 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
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
srvet_claudio
Posts: 2223
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: HELP FOR CONSOLE MODE PREVIEW REPORT

Post 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
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
henglongbike
Posts: 8
Joined: Fri Sep 21, 2012 3:05 am

Re: HELP FOR CONSOLE MODE PREVIEW REPORT

Post by henglongbike »

Thank srvet_claudio,

Great ! The code is work !

I will write in my program.

Thank you for help.
Post Reply