Skip to content

Latest commit

 

History

History
65 lines (47 loc) · 1.45 KB

sample_049.md

File metadata and controls

65 lines (47 loc) · 1.45 KB

Home

Obtaining window class name for the main VFP window

Code:

DO declare

LOCAL hWindow
hWindow = GetActiveWindow()

? "GetActiveWindow():", hWindow
? "Window Class:", GetWindowClass(hWindow)
? "Window Caption:", GetWindowCaption(hWindow)
?
? "_vfp.hWnd:", _vfp.hWnd
? "_screen.hWnd:", _screen.hWnd
? "_SCREEN.Caption:", _screen.Caption

FUNCTION GetWindowClass(lnWindow)
	LOCAL lnLength, lcText

	lcText = SPACE(250)
	lnLength = RealGetWindowClass(lnWindow,;
		@lcText, Len(lcText))

RETURN IIF(lnLength > 0,;
	Left(lcText, lnLength), "#empty#")

FUNCTION GetWindowCaption(lnWindow)
	LOCAL lnLength, lcText

	lcText = SPACE(250)
	lnLength = GetWindowText(lnWindow,;
		@lcText, Len(lcText))

RETURN IIF(lnLength > 0,;
	Left(lcText, lnLength), "#empty#")

PROCEDURE declare
	DECLARE INTEGER GetActiveWindow IN user32

	DECLARE INTEGER RealGetWindowClass IN user32;
		INTEGER hWindow, STRING @ pszType,;
		INTEGER cchType

	DECLARE INTEGER GetWindowText IN user32;
		INTEGER hWindow,;
		STRING @lpString, INTEGER cch  

Listed functions:

GetActiveWindow
GetWindowText
RealGetWindowClass

Comment:

Compare the results when:
- running this code using DO in the Command Window;
- running from an open Program Edit window using Ctrl+E