Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FindWindow() VFP from Word
Message
From
25/11/1998 10:55:51
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00139394
Message ID:
00161382
Views:
89
>>Klas,
>>George is right. FindWindow gets 2 parameters, class and title. If any of the parameters you pass null, everything matches :
>>
>>FindWindow(Class,Title) && Check both match
>>FindWindow(0,Title) && Any class match
>>FindWindow(Class,0) && Any title match
>>FindWindow(0,0) && Any class and title match
>>
* Fox code
>>function fWin
>>lParameters tuClass, tuWinTitle
>>DECLARE integer FindWindow in WIN32API string cClass, string cWinName
>>hWnd = FindWindow(tuClass,tuWintitle)
>>clear dlls
>>return hWNd
>>
>>? fwin("Fox_4000001","Microsoft Visual FoxPro") && 824
>>? fwin("Fox_4000001",0)                         && 832
>>? fwin(0,"Microsoft Visual FoxPro")             && 824
>>? fwin(0,0)                                     && 904
>>
>>Here interesting thing with only one instance of VFP (development), fwin("Fox_4000001",0) and fwin(0,"Microsoft Visual FoxPro") return different values (where is the main fox window ?). And many VFP window with same title return only first.
>>
>>I would also test it for you in word if I knew how to write and test that in word.
>>Cetin
>
>Cetin,
>
>There was a thread some months ago where I tried to find a way to use FindWindow in Word to find out if VFP was running and the above was one of your answers.
>
>I still have not found a way to know if VFP is running from Word and I am using the following code in Word (very simple):
>
>
>Declare Function FindWindowA Lib "user32" (lpszClassName As String, lpszWindowName As String) As Long
>
>lnHandle = FindWindowA(0, "Microsoft Visual FoxPro")
Hi Klas,
For connection problems I can't browse the rest of thread. I'm unfortunately purely unfamiliar with VB so all I could do is to make some conversion from VFP into a word macro (tested - works :) <pre>Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
                    ByVal lpWindowName As String) As Long

Sub Macro1()
    Dim hWnd As Long
    ' Search tasks for a VFP session
    For Each myTask In Tasks
        ' Search by class + title
        If FindWindow("Fox_4000001", myTask.Name) > 0 Then 
        ' Found a VFP session
           myTask.Activate  ' Activate VFP session
           myTask.WindowState = wdWindowStateNormal 
        ' Set VFP win state to normal
           Exit For
        End If
    Next myTask
End Sub
Search by both class and title, otherwise just a search by class might return a window handle that you would really have trouble to use via API (or it was just my disability to convert to VB :( ). If you know the exact title of VFP session you could also directly check myTask.name vs "Title" w/o using findwindow.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform