John,
If you don't want to use Alt/F4 to close the application, then a slight
modification as below finds the window handle and closes it under program
control.


Dave Crozier
 The secret to staying young is to live honestly, eat slowly, and to lie
about your age 

*********
* This Program closes a named NON VFP Window
* Without using keystrokes
*
Public cWindow_Title
Private nWindow

* Window/App to search for
cWindow_Title='temp.txt - Notepad'

nWindow = isrunning(cWindow_Title)
*
If nWindow<>0
  Close_Window(nWindow)
Endif
*
Return


****************
* Close the Window
*
Function Close_Window(pnWindow)
  Declare Long FindWindow in User32 ;
    String cClassname, String cTitle

  Declare Long SendMessage in User32 ;
    Long nhWnd, Long Msg, Long wParam, Long lParam

  SendMessage(pnWindow, 0x10, 0, 0)
  *
Endfunc

**********************************
* Generic routine to check if a given application is running on the user's
system
*
Function isrunning
Lparameter tcTitle  && all or Part Of the App's window title

  Declare Integer GetActiveWindow ;
    IN Win32API

  * Current App's window
  hNext = GetActiveWindow()
        
  Declare Integer GetWindow In Win32API ;
    INTEGER HWnd, Integer nType
                
  Declare Integer GetWindowText In Win32API ;
    INTEGER HWnd, String @cText, Integer nType
        
  * iterate through the open windows
  Do While hNext<>0
    ctext = Replicate(Chr(0),80)
                
    * Get Window Title
    GetWindowText(hNext,@ctext,80)
                
    * Parameter text is present in window title
    If Upper(Alltrim(tcTitle)) $ Upper(ctext)
      Return hNext
    Endif
                
    * Try next Window
    hNext = GetWindow(hNext,2)
    *
  Enddo
        
  * required window not found
  Return 0
  *
Endfunc


 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of John Weller
Sent: 18 October 2006 13:48
To: [email protected]
Subject: RE: Setting Default Printer

Excellent!!!!

Unfortunately it generates another question :-(  I seem to be going 2 steps
forward and 1 back with this project.

I can now set a printer to be the default and print a batch of PDF files on
that printer.  If I then set another printer to be the default and try and
print a further batch without closing the Acrobat window which was opened by
the first batch they are printed to the first printer so obviously I need to
close Acrobat between printing batches.  The solution appears to be to use
TerminateProcess however this needs the ProcessHandle which begs the
question - how do I find the process handle?  I can't be certain whether the
user will have Acrobat Reader or the full version, nor can I be certain
which version as they may well upgrade in the fullness of time.


John Weller
Wessex Computer Solutions
01380 728880
07976 393631

>
> For others following this thread: Check out the OUTSTANDING 
> www.news2news.com site - a collection of free and subscription based 
> content about how to use the Win32 api's from VFP. Well written, 
> accurate with 100's of fully documented copy and paste VFP code 
> snippets. Highly, highly, HIGHLY recommended!
>
> The www.news2news.com site gets a "6 out of 5 stars" rating from me.
>
>



[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to