// main.prg
#INCLUDE "FIVEWIN.CH"
STATIC oWInd // main mdi window
STATIC oBmap // mdi window .bmp
STATIC lExitPgm := .F.
STATIC xMESSAGE
//----------------------------------
FUNC MAIN()
LOCAL cDEFA,nLEN,cFILE,cRIGHTS,SAYING,mSTART,aDIR,cRDD
LOCAL cREAD,cWRITE,cSUPER,cOLDDEFA,cADMIN
LOCAL nPOS,cLOGIN,dEXE
LOCAL nYEAR,nSCR1,nSCR2,aVER
LOCAL oICO, oRs, cSQL, oErr, cPROG
LOCAL lOK, oDLG, cINIFILE, cERR
LOCAL TEXT_EOF, BYTES_READ,cTEXT,nHANDLE
LOCAL oSAY, cSAY
PUBLIC xVOL := "C:", xREAD,xWRITE,xLOGIN,xSUPER,xADMIN
PUBLIC xPROVIDER, xSOURCE, xCATALOG, xUSERID, xPASSWORD, xPROGID
PUBLIC xTABLE, xHOLD_TABLE, xQUE_TABLE
//--------------
PARAMETERS xTEXT
REQUEST DBFCDX
rddsetdefault ( "DBFCDX" )
xREAD := " "
xWRITE := " "
xLOGIN := " "
xSUPER := " "
xPROGID := " "
xADMIN := " "
xPROVIDER := "SQLOLEDB"
*xSOURCE := "MSSQL01"
xSOURCE := "LWMWEBDB01"
xCATALOG := "PCAS"
xUSERID := "pcasuser"
xPASSWORD := "pcas"
nSCR1 := GetSysMetrics(0)
nSCR2 := GetSysMetrics(1)
//-- get timestamp on .exe //
cFILE := GetModuleFileName( GetInstance() )
aDIR := DIRECTORY( cFILE )
dEXE := aDIR[1] [3]
// where .exe started from is default directory //
mSTART := RAT( "\", cFILE )
cDEFA := SUBSTR(cFILE,1,mSTART-1)
aDIR := NIL
SET DEFA to ( cDEFA )
cOLDDEFA := cDEFA
cRDD := xPROVIDER+" on "+xSOURCE+" 32 bit -b x86"
SET DELETED on
SET CENTURY on
SET 3DLOOK on
nYEAR := ( year( DATE() )-5 )
SET EPOCH to ( nYEAR )
// test for TEXT mode /NL for no logo
IF EMPTY( xTEXT )
xTEXT := " "
ENDIF
xTEXT := ALLTRIM( UPPER(xTEXT))
xLOGIN := WNetGetUser() // FiveWin function
xLOGIN := UPPER( xLOGIN )
xLOGIN := xLOGIN+SPACE(8)
xLOGIN := SUBSTR(xLOGIN,1,8)
xWRITE := 'Y'
xSUPER := 'Y'
xADMIN := 'Y'
cRIGHTS := _Rights()
//----- main menu -------//
xMESSAGE := "User "+xLOGIN+" Rights "+cRIGHTS+ ;
" Default= "+cDEFA+" Rdd= "+cRDD+ ;
" Revision "+DTOC(dEXE)+;
" -r"+str(nSCR1,4)+" x "+STR(nSCR2,4)
*DEFINE ICON oICO RESOURCE "COUPLE"
DEFINE WINDOW oWind ;
FROM 0,2 to 28,78 ;
TITLE "PCAS Time and Data entry Program" ;
MENU BuildMenu(cOLDDEFA,dEXE,cRDD,nSCR1,nSCR2,oWind) ;
MDI
DEFINE BITMAP oBMAP FILENAME (cOLDDEFA+"\PCAS.BMP") of oWind
SET MESSAGE OF oWind ;
to xMESSAGE CLOCK
// key handler to trap key strokes ESC to quit //
oWind:bKeyDown := {|nKey| IF(nKEY = 27, oWIND:END(), ) }
ACTIVATE WINDOW oWind ;
MAXIMIZED ;
ON PAINT ( IF( xTEXT = "/NL", ,PalBmpDraw( hDC, 0,0, oBMAP:hBitmap, oBMAP:hPalette, nSCR1, nSCR2 )));
ON INIT ( IF( xTEXT = "/NL", , MSGLOGO( cDEFA+"\SPLASH.BMP",2 )), ;
oWIND:Select(), oWIND:Refresh() ) ;
VALID ( IIF( !lExitPgm, ExitPgm( .T. ) , .F. ))
RETURN( NIL )
//---------------------------
Static Func _Rights()
LOCAL cREAD,cWRITE,cSUPER,cADMIN,cRIGHTS
STORE " " to cWRITE,cSUPER,cADMIN
cREAD := "R"
IF xWRITE = 'Y'
cWRITE := "W"
ENDIF
IF xSUPER = "Y"
cSUPER := "S"
ENDIF
IF xADMIN = "Y"
cADMIN := "A"
ENDIF
IF cWRITE = " " .and. cSUPER = " " .and. cADMIN = " "
cRIGHTS := "(READ)"
ELSE
cRIGHTS := "("+cREAD+cWRITE+cSUPER+cADMIN+")"
ENDIF
RETURN( cRIGHTS )
//--------------------------//
Static FUNC BuildMenu( cOLDDEFA, dEXE, cRDD,nSCR1,nSCR2,oWnd )
LOCAL oMenu, cRIGHTS, cDEFA
cDEFA := SET(7)
MENU oMenu
MENUITEM "&Pcas Data Entry ..." ;
ACTION Msginfo( "Menu 1") ;
MESSAGE "PCAS Data Entry"
MENUITEM "&Reports ..." ;
ACTION( _Rptmenu( oWnd )) ;
MESSAGE "Report Menu"
MENUITEM "&Utilities..." ;
ACTION( _UTILmenu( oWnd ) ) ;
MESSAGE "Utilities Programs"
MENUITEM "&Coordinator.." ;
ACTION Msginfo( "Menu 4") ;
MESSAGE "Coordinators Menu"
MENUITEM "&Login Diff User .." ;
ACTION Msginfo( "Menu 5") ;
MESSAGE "Login as a different User"
MENUITEM "&Intranet PCAS Manual .." ;
ACTION Msginfo( "Menu 6") ;
MESSAGE "PCAS Help on the DHECNET"
MENUITEM "&Quit" ;
ACTION oWiND:END() ;
MESSAGE "End this Program"
ENDMENU
RETURN( oMenu )
//-----------------------
Static FUNCTION ExitPgm( lCLEAN )
IF lCLEAN = .T.
lExitPgm := .T.
SET RESOURCES to
SysReFresh()
ENDIF
RETURN( lExitPgm )
//----------------------------------
Static FUNC _utilmenu( oWnd )
LOCAL oWndChild, oDlg, oBtn1, oBTN2, oBTN3, oBTN4, oBTN5, oBTN6
LOCAL oBTN7, oBTN8, oICO, aGrad
*oWnd:oMenu:Hide() // trying to make the mdi menu hide
aGrad := { { 1.0, 16777215, nRGB(4,53,107) },{ 1.0, nRGB(4,53,107), 16777215 } }
/*
DEFINE WINDOW oWndChild MDICHILD ;
FROM 1,1 to 25,38 ;
MENU BuildMenu1() ;
NOMINIMIZE ;
NOZOOM ;
OF oWnd ;
TITLE "Utility Menu"
oWndChild:bGotFocus := { || oDlg:SetFocus() }
*/
DEFINE DIALOG oDlg RESOURCE "UTILMENU" ; // OF oWndChild ;
TITLE "Utility Menu" ;
REDEFINE BUTTON oBtn1 ID 101 OF oDlg ;
ACTION ( Msginfo( "Indexing not required for SQL" ))
REDEFINE BUTTON oBtn2 ID 102 OF oDlg ;
ACTION ( MsgInfo( "Menu 2" )) // , _UtilBrow( oWnd ) )
REDEFINE BUTTON oBtn3 ID 103 OF oDlg ;
ACTION ( MsgInfo( "Menu 3" )) //,_empbrow( oWnd ) )
REDEFINE BUTTON oBtn4 ID 104 OF oDlg ;
ACTION ( MsgInfo( "Menu 3" )) //, _grpbrow( oWnd ) )
REDEFINE BUTTON oBtn5 ID 105 OF oDlg ;
ACTION ( MsgInfo( "Menu 4" )) //,_FyppBrow( oWnd ) )
REDEFINE BUTTON oBtn6 ID 106 OF oDlg ;
ACTION( MsgInfo( "Menu 5" )) //,_Purge() )
REDEFINE BUTTON oBtn7 ID 107 OF oDlg ;
ACTION( MsgInfo( "Menu 6" )) //, _HoliBrow(oWnd) )
REDEFINE BUTTON oBtn8 ID 108 OF oDlg ;
ACTION( oDlg:End(), dbCloseAll() )
ACTIVATE DIALOG oDlg NOWAIT ;
ON PAINT GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, aGrad, .T. )
* VALID ( oDlg:End(), .t. )
/*
ACTIVATE DIALOG oDlg NOWAIT ; // It has to be NonModal --> NOWAIT clause
ON INIT ( oDlg:Move( 0, 0 ) ) ;
VALID ( oWndChild:End(), .t. )
*/
/*
ACTIVATE WINDOW oWndChild ;
ON INIT oWndChild:SetSize( oDlg:nWidth, oDlg:nHeight, .T. )
*/
RETURN(NIL)
//-----------------------
static FUNC BuildMenu1()
LOCAL oMENU
MENU oMENU
MENUITEM " "
ENDMENU
RETURN( oMENU )
//----------------------------------
Static FUNC _rptmenu( oWnd )
LOCAL oWndChild, oDlg, oBtn1, oBTN2, oBTN3
LOCAL Oico
DEFINE WINDOW oWndChild MDICHILD ;
FROM 1,1 to 15, 46.8 ;
MENU BuildMenu3() ;
NOMINIMIZE ;
NOZOOM ;
OF oWnd ;
TITLE "Report Menu"
oWndChild:bGotFocus := { || oDlg:SetFocus() }
DEFINE DIALOG oDlg RESOURCE "RPTMENU" OF oWndChild ;
COLOR RGB(192,192,192), RGB(45,121,147)
REDEFINE BUTTON oBtn1 ID 101 OF oDlg ;
ACTION ( msginfo("menu 1") )
REDEFINE BUTTON oBtn2 ID 102 OF oDlg ;
ACTION ( msginfo("menu 2") )
REDEFINE BUTTON oBtn3 ID 105 OF oDlg ;
ACTION( dbCloseAll(), oWndChild:End() ) ;
DEFAULT
ACTIVATE DIALOG oDlg NOWAIT ; // It has to be NonModal --> NOWAIT clause
ON INIT ( oDlg:Move( 0, 0 ) ) ;
VALID ( oWndChild:End(), .t. )
ACTIVATE WINDOW oWndChild ;
ON INIT oWndChild:SetSize( oDlg:nWidth, oDlg:nHeight, .T. )
return nil
//-----------------------
static FUNC BuildMenu3()
LOCAL oMENU
MENU oMENU
MENUITEM " "
ENDMENU
RETURN( oMENU )
//-- END
// end main.prg