FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour close EXCEL.EXE
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
close EXCEL.EXE
Posted: Sat Mar 10, 2007 02:34 AM

Hi Everybody,

Is there a way from within FWH to close Ms-Excel (EXCEL.EXE) if it is running in the background?

Thanks,
Jeff

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: close EXCEL.EXE
Posted: Sat Mar 10, 2007 09:58 AM
This is a working sample:

#include "Fivewin.ch"


FUNCTION MAIN()

    IF CLOSEEXCEL()
        ? "Excel closed"
    ENDIF

    RETURN NIL


#define GW_HWNDNEXT	2
#define GW_CHILD	5


STATIC FUNCTION CLOSEEXCEL()

    LOCAL hWnd := GETWINDOW( GETDESKTOPWINDOW(), GW_CHILD )

    WHILE hWnd != 0
        IF GETWINDOWTEXT( hWnd ) = "Microsoft Excel"
            POSTMESSAGE( hWnd, WM_CLOSE )
            RETURN .T.
        ENDIF

        hWnd = GETWINDOW( hWnd, GW_HWNDNEXT )
    ENDDO

    RETURN .F.


EMG
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
close EXCEL.EXE
Posted: Sat Mar 10, 2007 11:54 AM

Hi Enrico,

Once again I thank you.

It is people like you that make me glad I picked FWH as my programming language. Your knowledgeable and quick replies not only help solve our issues but also help expand our understanding of FWH.

I wish we had 10 of you ... but the one we do have is pretty dam good.

Thanks again for all you help.

Jeff

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
close EXCEL.EXE
Posted: Sat Mar 10, 2007 01:26 PM
Jeff Barnes wrote:[...]FWH as my programming language.


FWH is not a programming language but "merely" a library. :-)

EMG
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
close EXCEL.EXE
Posted: Sat Mar 10, 2007 05:32 PM
EnricoMaria wrote:
Jeff Barnes wrote:[...]FWH as my programming language.


FWH is not a programming language but "merely" a library. :-)

EMG


Enrico, what is correct.

When I worked with Clipper I use to say I was a Clipper Programmer, and that Clipper was my "language".

Now If somebody ask me which language I use ¿Which is the right answer? c++? [x]Harbour FWH or .......?

Thanks for your help and support
Saludos/Regards,

José Murugosa

"Los errores en programación, siempre están entre la silla, el teclado y la IA!!"
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
close EXCEL.EXE
Posted: Sat Mar 10, 2007 06:13 PM
jose_murugosa wrote:Enrico, what is correct.

When I worked with Clipper I use to say I was a Clipper Programmer, and that Clipper was my "language".

Now If somebody ask me which language I use ¿Which is the right answer? c++? [x]Harbour FWH or .......?


xHarbour is better than FWH but xHarbour is a compiler not a language. Clipper is also a compiler. dBase III is an interpreter. I don't know if our beloved programming language has really a name. What do you think about "xBase language"?

EMG
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
close EXCEL.EXE
Posted: Sat Mar 10, 2007 06:15 PM
EnricoMaria wrote:
jose_murugosa wrote:Enrico, what is correct.

When I worked with Clipper I use to say I was a Clipper Programmer, and that Clipper was my "language".

Now If somebody ask me which language I use ¿Which is the right answer? c++? [x]Harbour FWH or .......?


xHarbour is better than FWH but xHarbour is a compiler not a language. Clipper is also a compiler. dBase III is an interpreter. I don't know if our beloved programming language has really a name. What do you think about "xBase language"?

EMG


Ok, I like it, thanks, Have a nice weekend.
Saludos/Regards,

José Murugosa

"Los errores en programación, siempre están entre la silla, el teclado y la IA!!"
Posts: 128
Joined: Mon Jul 31, 2006 03:23 PM
close EXCEL.EXE
Posted: Sun Mar 11, 2007 10:51 PM
Hi ! Enrico.

Clipper is my language when I was Born

Thank's Enrico for some help for me.

You are the good guy in the world :-)
How to focus my window application
        IF GETWINDOWTEXT( hWnd ) = "My Application"
            //POSTMESSAGE( hWnd, WM_CLOSE )
            POSTMESSAGE(hWnd,????????) <--- 
            RETURN .T.
        ENDIF


Best Regard
Areang
Posts: 16
Joined: Sun Oct 23, 2005 03:00 PM
close EXCEL.EXE
Posted: Mon Mar 12, 2007 08:08 AM
Me too. :-)

try this:

[code]
SetActiveWindow(hWnd)
[code]


areang wrote:Hi ! Enrico.

Clipper is my language when I was Born

Thank's Enrico for some help for me.

You are the good guy in the world :-)
How to focus my window application
[code]
IF GETWINDOWTEXT( hWnd ) = "My Application"
//POSTMESSAGE( hWnd, WM_CLOSE )
POSTMESSAGE(hWnd,????????) <---
RETURN .T.
ENDIF
[/code]

Best Regard
Areang
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
close EXCEL.EXE
Posted: Mon Mar 12, 2007 08:20 AM
Or

BringWindowToTop( hWnd )


EMG
Posts: 128
Joined: Mon Jul 31, 2006 03:23 PM
close EXCEL.EXE
Posted: Wed Mar 14, 2007 01:12 PM
Hi All !

This is work sample :
for setfocus and maximize windows to the top

#include "Fivewin.ch"

#define SW_NORMAL              1
#define SW_MAXIMIZE            3
#define SW_MINIMIZE            6
#define SW_RESTORE             9


FUNCTION MAIN()

    IF CLOSEEXCEL()
        ? "My Application ready for you"
    ENDIF

    RETURN NIL


#define GW_HWNDNEXT   2
#define GW_CHILD   5


STATIC FUNCTION CLOSEEXCEL()

    LOCAL hWnd := GETWINDOW( GETDESKTOPWINDOW(), GW_CHILD )

    WHILE hWnd != 0
        IF GETWINDOWTEXT( hWnd ) = "My Applicationl"
//           POSTMESSAGE( hWnd, WM_CLOSE ) <-- work for close windows
//           BringWindowToTop( hWnd ) <-- not work
              SetActiveWindow( hWnd )
              ShowWindow( hWnd, SW_MAXIMIZE )
            RETURN .T.
        ENDIF

        hWnd = GETWINDOW( hWnd, GW_HWNDNEXT )
    ENDDO

    RETURN .F.


Please reply !

regards
areang

Continue the discussion