Page 1 of 1

function that does not let me load a screen more than once

Posted: Tue Oct 01, 2019 3:12 pm
by digitsoft
Hello Roger
In Express there is a function that does not let me load a screen more than one

Re: function that does not let me load a screen more than on

Posted: Wed Oct 02, 2019 11:18 am
by bwolfsohn
This is what i used to use (before i retired :) )

if is_this_window_open( cWindowName )
return(nil)
endif

***************************
function is_this_window_open( cWindowName )
***************************
local lRetval:=.f.,i
local oMainwindow:=SetAppwindow()
local nDeskTopWindows := Len(AppDeskTop():childList())
local nChildWindows,aChildList

// added in case oMainwindow does not have drawing area
IF !ismembervar(oMainWindow,"drawingarea")
return(lRetval)
ENDIF
nChildWindows := Len(oMainWindow:drawingarea:childList())
aChildList := oMainWindow:drawingarea:childList()


IF (nDesktopWindows >2 .OR. nChildWindows>1) .AND. !Empty(cWindowName)
FOR i := 1 TO nChildwindows
IF ismembervar(aChildList,"title")
IF aChildList:title == cWindowName
err_msg("Cannot open "+cWindowName+" twice")
SetAppFocus(aChildList)
lRetVal := .t.
EXIT
ENDIF
ENDIF
NEXT
ENDIF
return(lRetval)

Re: function that does not let me load a screen more than on

Posted: Tue Nov 19, 2019 8:34 am
by digitsoft
Thank you

bwolfsohn wrote:This is what i used to use (before i retired :) )

if is_this_window_open( cWindowName )
return(nil)
endif

***************************
function is_this_window_open( cWindowName )
***************************
local lRetval:=.f.,i
local oMainwindow:=SetAppwindow()
local nDeskTopWindows := Len(AppDeskTop():childList())
local nChildWindows,aChildList

// added in case oMainwindow does not have drawing area
IF !ismembervar(oMainWindow,"drawingarea")
return(lRetval)
ENDIF
nChildWindows := Len(oMainWindow:drawingarea:childList())
aChildList := oMainWindow:drawingarea:childList()


IF (nDesktopWindows >2 .OR. nChildWindows>1) .AND. !Empty(cWindowName)
FOR i := 1 TO nChildwindows
IF ismembervar(aChildList,"title")
IF aChildList:title == cWindowName
err_msg("Cannot open "+cWindowName+" twice")
SetAppFocus(aChildList)
lRetVal := .t.
EXIT
ENDIF
ENDIF
NEXT
ENDIF
return(lRetval)