Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
ShellExec('MyPdfForm.pdf')
pdfCap = 'Adobe Reader - [LL_Affidavit_2002.pdf]'
pdfWin = FindWindow(pdfCap)
IF pdfWin<=0
MessageBox('Error Finding PDF window')
SUSP
ENDIF
vfpForm = create('form')
vfpForm.visible = .t.
TakeWindow(pdfWin, vfpForm.Caption)
* Resize, remove titlebar
SetWinPos(pdfWin,30,30,200,200,.t.)
* Utility routines:
************************************************************************
* WinApi :: ShellExecute*********************************
*** Author: Rick Strahl, West Wind Technologies
*** [URL unfurl="true"]http://www.west-wind.com/[/URL]
*** Function: Opens a file in the application that it's
*** associated with.
*** Pass: lcFileName - Name of the file to open
*** lcWorkDir - Working directory
*** lcOperation - "Open" "Run" "Play" "Edit" etc...
*** Return: 2 - Bad Association (invalid URL)
*** 31 - No application association
*** 29 - Failure to load application
*** 30 - Application is busy***
*** Values over 32 indicate success
*** and return an instance handle for
*** the application started (the browser)
************************************************************************
FUNCTION ShellExec
LPARAMETERS lcFileName, lcWorkDir, lcOperation, pcParameters
LOCAL pp, lcParam
pp = pCount() && LAS v9b1w wgcs
if pp>3 && LAS v9b1w wgcs
lcParam = pcParameters && LAS v9b1w wgcs
else && LAS v9b1w wgcs
lcParam = ''
endif
lcWorkDir=IIF(type("lcWorkDir")="C",lcWorkDir,"")
lcOperation=IIF(type("lcOperation")="C",lcOperation,"Open")
DECLARE INTEGER ShellExecute ;
IN SHELL32.DLL ;
INTEGER nWinHandle,;
STRING cOperation,;
STRING cFileName,;
STRING cParameters,;
STRING cDirectory,;
INTEGER nShowWindow
RETURN ShellExecute(0,lcOperation,lcFilename,lcParam,lcWorkDir,1)
*ENDFUNC ShellExecute
*********************************************************
* FindWindow( cWindowName )
* Auth: William GC Steinford
* Date: 7/16/98
* Purp: Ask windows if a particular window name exists
* (Case Insensitive)
FUNCTION FindWindow
LPARAMETERS cWinName
DECLARE INTEGER FindWindow in win32api as apiFindWindow INTEGER nClass, STRING cName
Return apiFindWindow( 0, cWinName )
PROCEDURE TakeWindow
* Author : William GC Steinford
* Date : Nov 2002
LPARAMETERS pncWindowTitle, pncParentWindow
LOCAL lnWHND, lnVFP, lnRes, lnCNT, lnWinCnt
DECLARE INTEGER FindWindow in win32api as apiFindWindow ;
INTEGER nClass, STRING cName
DECLARE INTEGER FindWindowEx in win32api as apiFindWindowEx ;
INTEGER nParent, INTEGER nChildAfter, ;
INTEGER nClass, STRING cName
* First get the VFP window handle
lnVFP = apiFindWindow( 0, _Screen.Caption )
if lnVFP<=0
RETURN -1
ENDIF
lnWinCnt = lnVFP
lnWHND = iif(VarType(pncWindowTitle)='N', pncWindowTitle, apiFindWindow(0,pncWindowTitle) )
* Not outside of VFP... if we have a parent window, check inside VFP
if lnWHND<=0 and vartype(pncParentWindow)='C' and not empty(pncParentWindow)
lnWHND=apiFindWindowEx( lnVFP, 0, 0, pncWindowTitle ) && Look in VFP window
if lnWHND=0 && Not in Main VFP window... This is the case if this window
&& was created by VFP
&& Container windows in VFP have no title
lnCNT = apiFindWindowEx( lnVFP, 0, 0, '' ) && Find in container window
do while lnWHND=0 and lnCNT<>0
lnWHND = apiFindWindowEx( lnCNT, 0, 0, pncWindowTitle ) && Look in container
lnCNT = apiFindWindowEx( lnVFP, lnCNT, 0, '' ) && Find next container window
enddo
endif
endif
if lnWHND<0
RETURN -1
endif
* Find the Parent Window
if vartype(pncParentWindow)='C' and not empty(pncParentWindow)
lnWinCNT=apiFindWindowEx( lnVFP, 0, 0, pncParentWindow ) && Look in container
if lnWinCnt=0 && Not in Main VFP window... This is the case if this window
&& was created by VFP
&& Container windows in VFP have no title
lnCNT = apiFindWindowEx( lnVFP, 0, 0, '' ) && Find in container window
do while lnWinCnt=0 and lnCNT<>0
lnWinCnt = apiFindWindowEx( lnCNT, 0, 0, pncParentWindow ) && Look in container
lnCNT = apiFindWindowEx( lnVFP, lnCNT, 0, '' ) && Find next container window
enddo
if lnWinCNT<=0
RETURN -1 && Couldnt find new parent window
endif
endif
else
if vartype(pncParentWindow)='N'
if pncParentWindow<0
lnWinCnt = 0 && Use VFP Main Window
else
lnWinCnt = pncParentWindow && Use passed HWND
endif
else
DEFINE WINDOW TakeWindowXoXoX TITLE "TakeWindowXoXoX" AT 0,0 Size 1,1
SHOW WINDOW TakeWindowXoXoX
* Find the empty-caption window inside VFP that contains "TakeWindowXoXoX"
lnWinCNT =0
lnCNT = apiFindWindowEx( lnVFP, 0, 0, '' ) && Find first container window
DO WHILE lnCnt<>0 and lnWinCnt=0
lnWinCNT = apiFindWindowEx( lnCNT, 0, 0, 'TakeWindowXoXoX' ) && Find Marker Window
if lnWinCnt=0
lnCNT = apiFindWindowEx( lnVFP, lnCNT, 0, '' ) && Find next container window
endif
ENDDO
if lnWinCnt<>0
lnWinCnt = lnCnt
endif
RELEASE WINDOW TakeWindowXoXoX
endif
endif
DECLARE INTEGER SetParent in Win32API as apiSetParent ;
INTEGER hWndChild, INTEGER hWndNewParent
if lnWinCnt<>0 && Use proper container window
lnRes = apiSetParent( lnWHND, lnWinCnt )
else
lnRes = apiSetParent( lnWHND, lnVFP )
endif
RETURN lnRes
PROCEDURE SetWinPos
LPARAM wHnd, X, Y, cWid, cHig, lRemBord
#define GWL_STYLE (-16)
#define WS_BORDER 0x00800000
#define NOT_WS_BORDER 0xFF7FFFFF && 4286578687
#define SWP_ASYNCWINDOWPOS 0x4000
* The frame changed: send WM_NCCALCSIZE */
#define SWP_FRAMECHANGED 0x0020
if lRemBord
DECLARE INTEGER SetWindowLong IN user32;
LONG hWnd,;
INTEGER nIndex,;
LONG dwNewLong
*SetWindowLong( wHnd, GWL_STYLE, WS_BORDER )
DECLARE LONG GetWindowLong IN user32;
LONG hWnd,;
INTEGER nIndex
lnRet = SetWindowLong(wHND,GWL_STYLE, BITAND( NOT_WS_BORDER, GetWindowLong(wHND,GWL_STYLE)))
endif
DECLARE INTEGER SetWindowPos IN user32;
INTEGER hwnd,;
INTEGER hWndInsertAfter,;
INTEGER x,;
INTEGER y,;
INTEGER cx,;
INTEGER cy,;
INTEGER wFlags
LOCAL lnFlags, lnInsideWHND
lnFlags = SWP_ASYNCWINDOWPOS
if lRemBord
lnFlags = BITOR(lnFlags , SWP_FRAMECHANGED)
endif
lnInsideWHND = 0
* FindWindow(_Screen.caption)
SetWindowPos( wHnd, lnInsideWhnd, X, Y, cWid, cHig, lnFlags )