Dimming background screens helps to grab the attention of the user when it is desired to force him/her to answer a question or pay attention to a necessary process.
Code: Select all
#INCLUDE "dcdialog.CH"
FUNCTION Main()
LOCAL GetList[0], oDlg, cText, bGets
ExtraDialog()
TEXT INTO cText WRAP
This window will be dimmed when the
"Test Window" button is clicked.
The Desktop will be dimmed when the
"Test Desktop" button is clicked.
ENDTEXT
bGets := {|oStatic,GetList|AddStuff(@oStatic,GetList)}
@ 2,10 DCSAY cText SAYWORDBREAK SIZE 70,7 FONT '16.Arial Bold'
@ 13,30 DCPUSHBUTTON CAPTION 'Test Window' SIZE 20,2 ;
ACTION {|o|o:=DC_DimScreen(oDlg,GRA_CLR_WHITE,,bGets),AnotherScreen(),o:destroy()}
@ 16,30 DCPUSHBUTTON CAPTION 'Test Desktop' SIZE 20,2 ;
ACTION {|o|o:=DC_DimScreen(AppDeskTop(),GRA_CLR_BLACK,,bGets), ;
AnotherScreen(),o:destroy(), ;
oDlg:toFront()}
DCREAD GUI EVAL {|o|oDlg := o} TITLE 'Dialog Dimmer Test' SETAPPWINDOW
RETURN nil
* --------------
PROC appsys ; return
* --------------
STATIC FUNCTION ExtraDialog()
LOCAL GetList[0], oDlg, oStatic, cBitmap := '..\..\bitmaps\wizard.bmp'
@ 0,0 DCSAY 'This is a test' SAYSIZE 0 FONT '24.Arial Bold'
@ 30,0 DCSTATIC TYPE XBPSTATIC_TYPE_BITMAP CAPTION cBitmap SIZE 300,300 PIXEL OBJECT oStatic
DCREAD GUI FIT TITLE 'Testing' EXIT EVAL {|o|oDlg := o}
oDlg:setPos({200,200})
RETURN oDlg
* -------------
STATIC FUNCTION AddStuff( GetList, oStatic )
LOCAL cText
TEXT INTO cText WRAP
Do not look here.
Keep your eyes on the ball.
Answer the stupid question.
ENDTEXT
@ 1,5 DCSAY cText SAYWORDBREAK FONT '20.Arial Bold' SAYSIZE 70,10 ;
COLOR GRA_CLR_RED
RETURN nil
* -------------
FUNCTION AnotherScreen()
LOCAL lStatus
DCMSGBOX 'Do you want to back up your data?' FONT '12.Arial Bold' ;
YESNO TO lStatus
return lStatus
* ------------
FUNCTION DC_DimScreen( oDlg, nColor, nTransparency, bGets )
LOCAL GetList[0], hWnd, oStatic, oDlg2, oDeskTop := AppDeskTop(), ;
GetOptions, aChildren, i
DEFAULT oDlg := SetAppWindow(), ;
nColor := GRA_CLR_BLACK, ;
nTransparency := 50
@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_TEXT ;
COLOR nil, nColor ;
OBJECT oStatic
DCGETOPTIONS NOTITLEBAR HIDE BORDER XBPDLG_NO_BORDER
DCREAD GUI EXIT EVAL {|o|oDlg2 := o} OPTIONS GetOptions OWNER oDlg
hWnd := oDlg2:getHwnd()
IF oDlg == oDeskTop
oDlg2:setParent(oDeskTop)
oDlg2:setPos({0,0})
oDlg2:setSize(oDeskTop:currentSize())
aChildren := oDlg:childList()
ELSE
oDlg2:setParent(oDlg:parent)
oDlg2:setPos(oDlg:currentPos())
oDlg2:setSize(oDlg:currentSize())
ENDIF
oStatic:setSize(oDlg2:drawingArea:currentSize())
oStatic:setPos({0,0})
DC_SetWindowTransparency(hWnd,nTransparency)
oDlg2:show()
IF Valtype(bGets) == 'B'
GetList := {}
Eval(bGets,GetList,@oStatic)
DCREAD GUI PARENT oStatic EXIT
ENDIF
oDlg2:disable()
oDlg2:show()
RETURN oDlg2