Page 2 of 2

Re: Small Question about Word and FWH

PostPosted: Mon Jul 17, 2023 5:31 pm
by Antonio Linares
Dear Michel,

If you don't call cWord:Quit() does Word remain opened ?

So you can only call cWord:Quit() if there no more FWH apps using it

is that correct ? thanks

Are you using Borland or MSVC32 ?

Re: Small Question about Word and FWH

PostPosted: Mon Jul 17, 2023 5:48 pm
by driessen
That is correct.

I use Borland

Re: Small Question about Word and FWH

PostPosted: Mon Jul 17, 2023 5:53 pm
by Antonio Linares
Dear Michel,

Please change your function this way:
Code: Select all  Expand view
STATIC PROCEDURE WordQuit

    local nFWHApps := 0

    EnumWindows( { | hWnd | If( GetClassName( hWnd ) == "TWINDOW", nFWHApps++, ) } )

   if nFWHApps == 1
      cWord:Quit()
   endif

RETURN


I am emailing you a modified fivehc.lib

many thanks for your feedback

Re: Small Question about Word and FWH

PostPosted: Mon Jul 17, 2023 8:21 pm
by driessen
Antonio,

If I understand well, this function is checking if another FWH-application is active.

This function is doing its job fantasticly.

But would it be difficult to create a same function for other applications or files (Word- or Excel-documents)?

Re: Small Question about Word and FWH

PostPosted: Mon Jul 17, 2023 8:32 pm
by Antonio Linares
Dear Michel,

> would it be difficult to create a same function for other applications or files (Word- or Excel-documents)?

You simply apply the same logic:

if there is only one FWH app running then you can quit it, if not, you don't

Re: Small Question about Word and FWH

PostPosted: Mon Jul 17, 2023 8:53 pm
by driessen
Antonio,

But what if Word is started manually?
The document in that session can't be closed either.
How to prevent that?

Re: Small Question about Word and FWH

PostPosted: Tue Jul 18, 2023 5:55 am
by Antonio Linares
Dear Michel,

Please use this code:
Code: Select all  Expand view
STATIC PROCEDURE WordQuit

    local nFWHApps := 0

    EnumWindows( { | hWnd | If( GetClassName( hWnd ) $ "TWINDOW,OpusApp", nFWHApps++, ) } )

   if nFWHApps == 1
      cWord:Quit()
   endif

RETURN

Re: Small Question about Word and FWH

PostPosted: Tue Jul 18, 2023 6:06 am
by driessen
Thanks a lot, Antonio.
I am away for the day and I will test it tonight.
Have a nice day.

Re: Small Question about Word and FWH

PostPosted: Tue Jul 18, 2023 9:23 pm
by driessen
Hello Antonio,

I did some testing.

The function returns 4 if a Word session is opened.
If a second Word session is opened, the function returns 6.
If no Word session is active, the function returns 3.

Weard, isn't it?

Any suggestion?

Thanks.

Re: Small Question about Word and FWH

PostPosted: Wed Jul 19, 2023 6:22 am
by Antonio Linares
Dear Michel,

Please try it this way:
Code: Select all  Expand view
STATIC PROCEDURE WordQuit

    local nFWHApps := 0

    EnumWindows( { | hWnd | If( GetClassName( hWnd ) $ "TWINDOW,OpusApp", nFWHApps++, ) } )

   if nFWHApps == 4
      cWord:Quit()
   endif

RETURN

Re: Small Question about Word and FWH

PostPosted: Wed Jul 19, 2023 11:25 am
by driessen
Hello Antonio,

Thanks to all your efforts, I have made a combination of testing other FWH-applications and other Word-sessions.

This the code which seem to work (I need to do more tests):
Code: Select all  Expand view
STATIC PROCEDURE WordQuit

   LOCAL nFWHApps1 := 0
   LOCAL nFWHApps2 := 0

   EnumWindows( { | hWnd | If( GetClassName( hWnd ) == "TWINDOW"       , nFWHApps1++, ) } )
   EnumWindows( { | hWnd | If( GetClassName( hWnd ) $ "TWINDOW,OpusApp", nFWHApps2++, ) } )

   IF nFWHApps1 < 2 .AND. nFWHApps2 < 3
      cWord:Quit()
   ENDIF

RETURN
I do some more tests and I will let you know.

Re: Small Question about Word and FWH

PostPosted: Wed Jul 19, 2023 1:09 pm
by Antonio Linares
very good :-)

Re: Small Question about Word and FWH

PostPosted: Wed Jul 19, 2023 2:14 pm
by driessen
Antonio,

I can't use xHarbour Builder. EnumWinows() is unresolved, the message says.

What do i need to do to solve this problem?

Re: Small Question about Word and FWH

PostPosted: Wed Jul 19, 2023 4:52 pm
by Antonio Linares
Dear Michel,

Already sent to your email

Re: Small Question about Word and FWH

PostPosted: Wed Jul 19, 2023 10:10 pm
by driessen
Thanks a lot, Antonio.

This function is now also accepted in xHarbour Builder.