Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Howto get window handle of modify command ?
Message
From
19/06/2003 04:31:29
Dorin Vasilescu
ALL Trans Romania
Arad, Romania
 
 
To
18/06/2003 23:35:31
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00801577
Message ID:
00801631
Views:
25
This code will return a window handle (even for VFP toolbars or user defined toolbars), but it need the window caption passed as parameter.
PROCEDURE GethWnd
PARAMETERS tcCaption
DeclareAPI()
lnhWnd = 0
lnVFPHnd = _VFP.hWnd 
GetWindows(lnVFPHnd, 0,0)
RETURN lnWhnd

PROCEDURE GetWindows
LPARAMETERS lnHandle,lnParent,lnLevel
#DEFINE GW_HWNDNEXT   2 
#DEFINE GW_CHILD      5 
LOCAL WinCaption, hWindow, hParent, lvl
LOCAL hChild, oChild, hNext, oNext 
WinCaption = ''
hWindow = 0
hParent = 0
lvl = 0
IF lnHandle = 0 
	RETURN .F. 
ENDIF 
lvl = lnLevel 
hWindow = lnHandle 
hParent = lnParent 
WinCaption = GetWinText(lnHandle)
IF TRIM(WinCaption) == TRIM(tcCaption)
   	lnhWnd = hWindow
endif
hChild = GetWindow(hWindow, GW_CHILD) 
oChild = GetWindows( hChild, hWindow, lvl+1)
IF lnParent <> 0 
    hNext = GetWindow(hWindow, GW_HWNDNEXT) 
    oNext = GetWindows(hNext, hParent, lvl) 
ENDIF 

FUNCTION  GetWinText(hWindow) 
    LOCAL lcBuffer, lnResult 
    lcBuffer = Space(250) 
    lnResult = GetWindowText(hWindow, @lcBuffer, Len(lcBuffer)) 
RETURN Left(lcBuffer, lnResult) 

PROCEDURE DeclareAPI
    DECLARE INTEGER GetActiveWindow IN user32 
    DECLARE INTEGER GetWindow IN user32 INTEGER hwnd, INTEGER wFlag 
    DECLARE INTEGER GetWindowText IN user32; 
        INTEGER hwnd, STRING @lpString, INTEGER cch 
>Hi Everyone,
>
>Does anyone know how you can retrieve the window handle of a window opened by MODIFY COMMAND?
>
>The reason I need it is to programatically save the prg file that I am editing using the _EdSave function.
>
>What I have is a two windows defined using Define Window, and have opened up the procedure using the following :
>
>
>MODIFY COMMAND test.prg ;
>	NOMENU NOWAIT WINDOW wEditor IN WINDOW wParent SAVE
>
>
>When I try to call the _WGetPort method after that to get the window handle, it only gets the window handle of the parent window.
>
>Is there anything I could do to get the editor window handle?
>
>Many thanks,
>
>Michael Henstock
>AWS
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform