#include "FiveWin.ch"
#define H_RES GetSysMetrics( 0 )
#define V_RES GetSysMetrics( 1 )
REQUEST HB_CODEPAGE_LTWIN
function Main()
SET MULTIPLE OFF
SET SCOREBOARD OFF
SET EXCLUSIVE OFF
SET DELETED ON
SET SOFTSEEK OFF
SET AUTOPEN OFF
SET CENTURY ON
SET DATE ANSI
SET EPOCH TO 2000
SET CONFIRM ON
SET ESCAPE ON
SET WRAP ON
SET DATE FORMAT TO "YYYY.MM.DD"
SET DBFLOCKSCHEME TO 2
set( _SET_CODEPAGE, "LTWIN" )
private nHorRes := H_RES
private nVerRes := V_RES
private oWndPagr
private oWndMenu
private oWndRibn
private oImgRibn
private lImgRibn := .f.
private cLg := "L"
private nLg := 1
pagr_antr()
DEFINE WINDOW oWndPagr MDI FROM 10, 50 to nVerRes / 3, nHorRes - 50 PIXEL TITLE "National chars"
SET MESSAGE OF oWndPagr TO "" NOINSET
oWndPagr:bValid := { || ExitWnd() }
oWndPagr:bInit := { || Pagr_ribn(), Pagr_menu() }
ACTIVATE WINDOW oWndPagr MAXIMIZED
return( NIL )
static function ExitWnd()
if !MsgYesNo( "Do you really want to quit ?" )
return .f.
endif
dbcloseall()
FreeResources()
return( .t. )
function Pagr_menu()
local oVmenu, oMenu, oItem, oTxt
local cStr, cLine
local aPgrMen := {}
local aSubMen := {}
local aTxt
local cMenu := "pmenu.txt"
local u := v := z := 0
local cPct := ".\pict\"
if oWndMenu # NIL
oWndMenu:Show()
oWndMenu:SetFocus()
return( NIL )
endif
oTxt := TTxtFile():New( cMenu )
if oTxt:Open()
do while !oTxt:lEof()
cLine := oTxt:ReadLine()
aTxt := txtRow2Array( cLine, chr( 9 ) )
if len( aTxt ) > 3
aTxt[ 1 ] := val( aTxt[ 1 ] )
if alltrim( upper( aTxt[ 2 ] ) ) == "P"
aadd( aPgrMen, aTxt )
endif
if alltrim( upper( aTxt[ 2 ] ) ) == "S"
aadd( aSubMen, aTxt )
endif
endif
oTxt:Skip()
enddo
oTxt:Close()
else
Alert( "Can't open main menu file ..." )
dbcloseall()
clear all
quit
endif
DEFINE WINDOW oWndMenu MDICHILD TITLE "Main menu" NOSYSMENU NOICONIZE OF oWndPagr
oVMenu := TVistaMenu():New( 0, 0, 100, 300, oWndMenu )
oVMenu:nColumns := 1
oVMenu:nType := 2
/*
oVMenu:oFont := nil
DEFINE FONT oVMenu:oFont NAME "Verdana" SIZE 9, 22
//DEFINE FONT ::oFont NAME "Segoe UI" SIZE 9, 22
oVMenu:oFont2 := nil
DEFINE FONT oVMenu:oFont2 NAME "Verdana" SIZE 6, 13
//DEFINE FONT ::oFont2 NAME "Segoe UI" SIZE 6, 15
*/
// lithuanian in 3 position of array
// english in 4 position
z := if( cLg == "L", 3, 4 )
asort( aPgrMen,,, { |x,y| x[ 1 ] < y[ 1 ] } )
for u := 1 to len( aPgrMen )
oMenu := oVMenu:AddItem( alltrim( AnsiToOem( aPgrMen[ u, z ] ) ), cPct + alltrim( aPgrMen[ u, 5 ] ) )
for v := 1 to len( aSubMen )
if aSubMen[ v, 1 ] == aPgrMen[ u, 1 ]
cStr := alltrim( aSubMen[ v, 5 ] )
oItem := oMenu:AddItem( alltrim( AnsiToOem( aSubMen[ v, z ] ) ) )
menu_run( oItem, cStr )
endif
next
next
oWndMenu:oClient := oVMenu
oWndMenu:bValid := { || oWndMenu := NIL, .t. }
ACTIVATE WINDOW oWndMenu ON INIT oWndMenu:Move( 20, 50, nHorRes / 2, nVerRes - 150, .t. )
return( NIL )
function menu_run( oItem, cPrg )
oItem:bAction := { || MsgInfo( cPrg ) }
return( NIL )
function Pagr_ribn()
local oReBar
local cPct := ".\pict\16\"
oImgRibn := TImageList():New( 16, 16 ) // width and height of bitmaps
oImgRibn:AddMasked( TBitmap():Define( , cPct + "favorites.bmp", oWndPagr ), nRGB( 255, 0, 255 ) )
oImgRibn:AddMasked( TBitmap():Define( , cPct + "new.bmp", oWndPagr ), nRGB( 255, 0, 255 ) )
oImgRibn:AddMasked( TBitmap():Define( , cPct + "edit.bmp", oWndPagr ), nRGB( 255, 0, 255 ) )
oImgRibn:AddMasked( TBitmap():Define( , cPct + "delete16.bmp", oWndPagr ), nRGB( 255, 0, 255 ) )
oImgRibn:AddMasked( TBitmap():Define( , cPct + "save.bmp", oWndPagr ), nRGB( 255, 0, 255 ) )
oImgRibn:AddMasked( TBitmap():Define( , cPct + "search.bmp", oWndPagr ), nRGB( 255, 0, 255 ) )
oWndRibn := TToolBar():New( oWndPagr, 20, 22, oImgRibn )
oWndRibn:AddButton( { || Pagr_menu() }, "Main menu" )
oWndRibn:AddSeparator()
oWndRibn:AddButton( { || MsgInfo( "Naujas iraðas !" ) }, "New" )
oWndRibn:AddButton( { || MsgInfo( "Edit !" ) }, "Edit" )
oWndRibn:AddSeparator()
oWndRibn:AddButton( { || MsgInfo( "Ðalinti !" ) }, "Delete record" )
oWndRibn:AddButton( { || MsgInfo( "Save !" ) }, "Issaugoti" )
oWndRibn:AddButton( { || MsgInfo( "Ieðkoti !" ) }, "Search" )
oReBar := TReBar():New( oWndPagr )
oReBar:InsertBand( oWndRibn )
lImgRibn := .t.
return( NIL )
function pagr_antr()
cSave := if( cLg == "L", "Iraðyti", "Save" )
cGerai := if( cLg == "L", "Gerai", "OK" )
cCancel := if( cLg == "L", "Atsisakyti", "Cancel" )
cCont := if( cLg == "L", "Testi", "Continue" )
cTaip := if( cLg == "L", "Taip", "Yes" )
cNe := if( cLg == "L", "Ne", "No" )
cPPrint := if( cLg == "L", "Printeris", "Printer" )
cPFont := if( cLg == "L", "Rap.ðriftai", "Rep.fonts" )
return( NIL )
function txtRow2Array( cRow, cDlm )
local nPos
local cTkn
local aRet := {}
local lCont := .t.
local lTrim := .t.
local nDlm
DEFAULT cDlm := chr( 9 )
nDlm := Len( cDlm )
do while lCont
nPos := at( cDlm, cRow )
if nPos > 0 // If found a delimiter
cTkn := substr( cRow, 1, nPos - 1 ) // Extract token
else
cTkn := cRow // Else use remainder of str
lCont := .F.
endif
if lTrim
cTkn := alltrim( cTkn ) // Trim unless asked not to
endif
aadd ( aRet, cTkn ) // Add a new element
cRow := substr( cRow, nPos + nDlm )
enddo
return( aRet )