Page 1 of 2

Doubt of pure unknowless ... / Duda de puro ignorante ...

Posted: Wed Aug 16, 2017 4:29 pm
by gcarrizo
How explain about it ...
I have a toolbar and there open it a modal window with two buttons .
one of them export and them open in excel... but that sheet excel's app go to background.
Of course if that button be put in toolbar and i execute it excel appears on top.
They Have a way to do the same from a modal window and once i execute it excel is show in top ?
Attached printscreen

Regards
-------------------------------------------------------------------------------------------------------------------
Cómo explicarlo ...
Tengo una barra de herramientas y allí se abre una ventana modal con dos botones.
Uno de ellos exporta y se abre en Excel ... pero al abrir la hoja de Excel la aplicación va al fondo pasa a segundo plano.
Por supuesto si ese botón se pone en la barra de herramientas y lo ejecuto excel aparece en primer plano.
Tienen una manera de hacer lo mismo desde una ventana modal y una vez que lo ejecute excel se muestra en la primer plano ?
Adjunto Caputra de Pantalla .

Saludos

Re: Doubt of pure unknowless ... / Duda de puro ignorante ...

Posted: Wed Aug 16, 2017 8:25 pm
by EduardoLuis
Hola GCarrizo:

Probá con cerrar la ventana modal luego de iniciar Excel.-
P. ej.
DEF.....BUTTON
ON ACTION ( ejecutar() , VENTANAMODAL.RELEASE )

PROCEDURE EJECUTAR
EXECUTE FILE "HOJA_EXCEL.XLS"
RETURN

Espero que con ello resuelvas tu problema.
Cordialmente
Eduardo

Hi GCarrizo:

Try closing modal window after initiate Excel
F. Ex.

DEF....... BUTTON
ON ACTION ( ejecutar() , VENTANAMODAL.RELEASE )

PROCEDURE EJECUTAR
EXECUTE FILE "HOJA_EXCEL.XLS"
RETURN

Hopping this solve's your issue.-
With Regards
Eduardo

Re: Doubt of pure unknowless ... / Duda de puro ignorante ...

Posted: Wed Aug 16, 2017 9:05 pm
by gcarrizo
Thanks for you support.

I try with that but result now is excel in back like focus and toolbar on top ... you see attached printscreen.

Regards
-----------------------------------------------------------------------------------------------------------------------
Gracias por su apoyo.

Intento con eso pero el resultado ahora es excel en como fondo ( el foco en excel ) y la barra de herramientas en el frente ... tal cual se ve en la captura de pantalla adjunta.

Saludos
-----------------------------------------------------------------------------------------------------------------------

Re: Doubt of pure unknowless ... / Duda de puro ignorante ...

Posted: Wed Aug 16, 2017 10:14 pm
by EduardoLuis
Hola Gcarrizo:

Hice un test y si la ventana modal es cerrada, como vos decís pasa el control de foco a la ventana principal y queda EXCEL en 2do. plano.-
Hice otro test sin cerrar la ventana modal, y el foco lo tiene la ventana EXCEL (la que tengo maximizada por defecto), y al cerrarla debo cerrar la venta modal de Hmg para que luego pase el control a la ventana principal de HMG.-
Voy a continuar haciendo otros test y mañana te comento.-
Abrazo

Re: Doubt of pure unknowless ... / Duda de puro ignorante ...

Posted: Thu Aug 17, 2017 4:11 am
by Rathinagiri
http://www.hmgforum.com/viewtopic.php?p=39513#p39513

The above post may help you. It gave an example of getting all the applications running with a particular title. You can get the handle with Excel and make that window focus.

Re: Doubt of pure unknowless ... / Duda de puro ignorante ...

Posted: Thu Aug 17, 2017 10:42 am
by gcarrizo
Gracias nuevamente !!! :geek: ( thanks again !!! )
---------------------------------------------------------------
EduardoLuis wrote: Wed Aug 16, 2017 10:14 pm
Voy a continuar haciendo otros test y mañana te comento.-
Abrazo

Re: Doubt of pure unknowless ... / Duda de puro ignorante ...

Posted: Thu Aug 17, 2017 10:48 am
by gcarrizo
8-)


Analyzing and Testing ...
Thank you for your collaboration.
Regards
---------------------------------------------
Analizando y Probando ...
Gracias por tu colaboracion.
Saludos

--------------------------------------------------------------------------------------------------------


Rathinagiri wrote: Thu Aug 17, 2017 4:11 am http://www.hmgforum.com/viewtopic.php?p=39513#p39513

... You can get the handle with Excel and make that window focus.

Re: Doubt of pure unknowless ... / Duda de puro ignorante ...

Posted: Thu Aug 17, 2017 1:41 pm
by gcarrizo
At last I did was the follow
A) In the main add a function to minimize the app toolbar.
B) In the modal when executing excel in advance, indicate that it did
1st Close Modal
2nd Minimize the toolbar [Main]
3rd Export to Excel

I tried to explain it in the source code, so there is another way... if it is so nice to know. ;)

Best Regards.

-------------------------------------------------------------------------------------------------------------------
Al final lo que hice fue lo siguiente
a) En el principal agregue una funcion para minimizar la toolbar.
b) En la modal al ejecutar excel previamente indique que hiciera lo siguiente:
1º Cierre modal
2º Minimize la toolbar
3º Exporte

Traté de explicarlo en el codigo fuente , por ahi existe otro modo... si es asi seria bueno saberlo.

Saludos .

Code: Select all

Function Exp_2_XLS()

 /* CLOSE THIS MODAL WINDOWS  */
 /* CIERRA ESTA VENTANA MODAL */

Thiswindow.release

/* FUNCTION ON MAIN WITH JUST A SINGLE LINE -> Thiswindow.Minimize  (MINIMIZE TOOLBAR [MAIN])   */
/* FUNCION EN MAIN CON UNA SOLA LINEA       -> Thiswindow.Minimize  (MINIMIZA LA TOOLBAR [MAIN])*/

SET_FOCUS_BY_ MINIMIZE_MAIN()


/* EXPORT & OPEN EXCEL */
/* EXPORTADO Y APERTURA DEL ARCHIVO EN EXCEL */

use DAUX.dbf
COPY TO ('File_Archivo.XLS')
DBCLOSEALL()

Execute File 'excel.exe' PARAMETERS 'File_Archivo.XLS'

Return


Re: Doubt of pure unknowless ... / Duda de puro ignorante ...

Posted: Thu Aug 17, 2017 2:56 pm
by bpd2000
Due to some of incomplete details in your code
Replace Execute line with following function, it may help you
Excel CreateObject has in built Property to get the handle

Code: Select all


FUNCTION OnepExcelandGetHandle()
   LOCAL oExcel, oSheet
   oExcel := CreateObject( "Excel.Application" )
   oExcel:Visible := .F.
  
   hWnd:=oExcel:hWnd

   oSheet := oExcel:Workbooks:Open("c:\Your_FilePath\Book1.xlsx")
   
   oExcel:Visible := .T.
   RETURN hWnd

Code: Select all

#include "hmg.ch"

FUNCTION Main()
Public hwnd

   DEFINE WINDOW Form_1   ;
      AT 90,90            ;
      WIDTH 500           ;
      HEIGHT 300          ;
      TITLE "Demo"        ;
      MAIN
      ON KEY ESCAPE ACTION THISWINDOW.RELEASE
  
   END WINDOW

   @ 50, 50 BUTTON button       ;
      PARENT Form_1             ;
      CAPTION "Excel_Open"      ;
      WIDTH 100                 ;
      HEIGHT 50                 ;
      ONCLICK OnepExcelandGetHandle()
      
  @ 50, 200 BUTTON button2      ;
      PARENT Form_1             ;
      CAPTION "hWnd of Excel"   ;
      WIDTH 100                 ;
      HEIGHT 50                 ;
      ONCLICK MSGINFO(hWnd, "Handle of Excel" + SPACE(10))       
      
   @ 150, 50 BUTTON button3     ;
      PARENT Form_1             ;
      CAPTION "BringToTop"      ;
      WIDTH 100                 ;
      HEIGHT 50                 ;
      ONCLICK BringWindowToTop(hWnd) 

   @ 150, 200 BUTTON button4    ;
      PARENT Form_1             ;
      CAPTION "Show Excel"      ;
      WIDTH 100                 ;
      HEIGHT 50                 ;
      ONCLICK SHOWWINDOW(hWnd) 
   @ 150, 350 BUTTON button5    ;
      PARENT Form_1             ;
      CAPTION "Hide Excel"           ;
      WIDTH 100                 ;
      HEIGHT 50                 ;
      ONCLICK HIDEWINDOW(hWnd) 


   Form_1.Activate

   RETURN NIL


FUNCTION OnepExcelandGetHandle()
   LOCAL oExcel, oSheet
   oExcel := CreateObject( "Excel.Application" )
   oExcel:Visible := .F.
  
   hWnd:=oExcel:hWnd

   oSheet := oExcel:Workbooks:Open("c:\Your_FilePath\Book1.xlsx")
      
   oExcel:Visible := .T.
   RETURN hWnd

Re: Doubt of pure unknowless ... / Duda de puro ignorante ...

Posted: Thu Aug 17, 2017 3:51 pm
by Rathinagiri
Super!