... DEFINE WINDOW wMain ; AT 0, 0 ; WIDTH GetClientWidth () * nKfcW ; HEIGHT GetClientHeight() * nKfcH ; TITLE gTxt(Title) ; ICON cIcon ; MAIN MDI ; CURSOR cCursor ; ON INIT MainExecute() ; ON RELEASE MainExecute() ; ON MOUSECLICK MainExecute() ; ON INTERACTIVECLOSE MainExecute() ; BACKCOLOR aBColor _wCargoSet('') // Wnd.Cargo для окна MainMenu(cPref) // меню от префикса MainStatusBar() // StatusBar hWnd := FormHandle(wMain) AppSet(MainName , GetFormName()) AppSet(MainIndex , FormIndex(wMain)) AppSet(MainHandle, hWnd) AppSet(MainVhod1 , empty(g_Cfg(AppGet(MainName) + cCursor, '', [Window]))) // первый вход AppSet(SBarHeight, GetWindowHeight(ControlHandle(StatusBar, wMain))) AppSet(TBarHeight, 0) AppSet(MainClientWidth , GetClientWidth (hWnd)) AppSet(MainClientHeight, GetClientHeight(hWnd) - AppGet(SBarHeight)) END WINDOW ... STATIC FUNCTION MainStatusBar( cFont, nSize, lBold ) // MDI Main StatusBar LOCAL oS := Application.Sets LOCAL nW3 := oS:W(20) + 16 LOCAL nW4 := oS:W(30) + 16 LOCAL nW5 := oS:W(,4) + 16 LOCAL nW2 := int(( GetClientWidth( _HMG_MainHandle ) - nW3 - nW4 - nW5 ) * 0.4 ) DEFAULT cFont := oS:cFontName, ; nSize := oS:nDefFontSize, ; lBold := .T. IF lBold DEFINE STATUSBAR FONT cFont SIZE nSize BOLD ELSE DEFINE STATUSBAR FONT cFont SIZE nSize ENDIF STATUSITEM "" ACTION MainExecute('stb.1') STATUSITEM "" WIDTH nW2 ACTION MainExecute('stb.2') STATUSITEM "" WIDTH nW3 ACTION MainExecute('stb.3') ICON 'D_DAT' STATUSITEM "" WIDTH nW4 ACTION MainExecute('stb.4') ICON 'D_ORG' STATUSITEM "" WIDTH nW5 ACTION MainExecute('stb.5') ICON 'D_SET' END STATUSBAR RETURN FUNCTION MainExecute( cKey, cTxt ) // выполнение в главном окне LOCAL a,i,j,k LOCAL cThis := '', lRet := .T., o := AppGet(Leto) LOCAL cMain_menu := 'Main_menu_' /* msglog( CRLF ) msglog( procname(), o:IsErrConnect(), o:cPathBase, o:cPathLocal ) msglog( '_HMG_ThisEventType ', _HMG_ThisEventType ) msglog( '_HMG_ThisFormIndex ', _HMG_ThisFormIndex ) msglog( '_HMG_ThisType ', _HMG_ThisType ) msglog( '_HMG_ThisIndex ', _HMG_ThisIndex ) msglog( '_HMG_ThisFormName ', _HMG_ThisFormName ) msglog( '_HMG_ThisControlName', _HMG_ThisControlName) */ IF _HMG_ThisEventType == 'WINDOW_INIT' // ON INIT IF o:IsErrConnect() o:ErrorMsg() ELSE ENDIF ELSEIF _HMG_ThisEventType == 'WINDOW_ONINTERACTIVECLOSE' // ON RELEASE lRet := YesNoMainClose() ELSEIF _HMG_ThisEventType == 'WINDOW_RELEASE' // ON INTERACTIVECLOSE CLOSE ALL IF ! o:ErrorMsg(); o:DisConnect() ENDIF ELSEIF ! empty(_HMG_ThisControlName) .and. ! empty(cKey) // Menu item execute cThis := _HMG_ThisControlName // меню name IF left(cThis, len(cMain_menu)) == cMain_menu i := RAt('_', cThis) j := left(cThis, i-1)+'.'+subs(cThis, i+1) j := subs(j, RAt('_', j)+1) IF j == '1.9'; cKey := j // Exit item из пункта меню с префиксом ENDIF ENDIF IF cKey == '1.9' // Exit item RETURN YesNoMainClose() ELSEIF cKey == '2.1' Wnd_SetKassa() ELSEIF cKey == '2.2' Wnd_SetPVN() ELSEIF cKey == '2.3' Wnd_SetProv() ELSEIF cKey == '2.4' Wnd_Test() ELSEIF cKey == '7.1' Imp_OldBase() ELSEIF 'stb.' $ cKey a := { ; {"1.", "Item line 1", "Execute 1"}, ; {"2.", "Item line 2", "Execute 2"}, ; {"3.", "Item line 3", "Execute 3"}, ; {"4.", "Item line 4", "Execute 4"}, ; {"5.", "Item line 5", "Execute 5"}, ; {"6.", "Item line 6", "Execute 6"}, ; {"7.", "Item line 7", "Execute 7"}, ; {"8.", "Item line 8", "Execute 8"}, ; {"9.", "Item line 9", "Execute 9"} ; } i := 0 IF cKey == 'stb.1' ELSEIF cKey == 'stb.2' ELSEIF cKey == 'stb.3' i := mAchoice(a, 1, 8, 'Setting') ELSEIF cKey == 'stb.4' i := mAchoice(a, 1, 9, 'Setting') ELSEIF cKey == 'stb.5' i := mAchoice(a, 1, 10, 'Setting') ENDIF MsgBox('StatusBar press '+hb_valtoexp(i), 'Achoice') ENDIF ENDIF RETURN lRet FUNCTION mAchoice( aAchoice, nValue, nLayOut, cTitle, nSize, nLines, nRow, nCol ) // меню Achoice LOCAL a, i, j, k LOCAL aItems := {}, aRezult := {} LOCAL aJustify, aHeaders, aWidths, nW, nH LOCAL nAchoice := 0, lNoLines := .T., lHeaders := .F. LOCAL nKols, nWidth := 4, nHeight := 100, lCell := .F. LOCAL cIcon := AppGet(MainIcon) LOCAL aBackColor := AppGet(BackColor) LOCAL cFontName := AppGet(FontNameDef) LOCAL nFontSize := AppGet(FontSizeDef) LOCAL lFontBold := .F., aFontColor, lSysMenu LOCAL lSelected := .T., nMaxRow := 21, uParent, cParent, hParent LOCAL nParentWidth, nParentHeight, nFormWidth, nFormHeight LOCAL nAppRow := Application.Row + GetBorderHeight() + GetTitleHeight() + GetMenuBarHeight() LOCAL nAppCol := Application.Col + GetBorderWidth() LOCAL aHmg := Save_Rest_HMG() DEFAULT nValue := 1, ; nRow := 0, ; nCol := 0, ; cTitle := '', ; nSize := nFontSize, ; nLines := nMaxRow, ; nLayOut := 0 IF hb_IsChar(nSize); nSize := nFontSize + val(nSize) // increment для FontSize ENDIF lSysMenu := ! empty(cTitle) IF empty(aAchoice) RETURN nAchoice ELSEIF hb_IsArray(aAchoice) aItems := aAchoice lHeaders := .F. ELSEIF hb_IsHash(aAchoice) nRow := hb_HGetDef(aAchoice, "ROW" , nRow ) nCol := hb_HGetDef(aAchoice, "COL" , nCol ) aItems := hb_HGetDef(aAchoice, "ITEMS" , NIL) aHeaders := hb_HGetDef(aAchoice, "HEADERS" , NIL) aJustify := hb_HGetDef(aAchoice, "JUSTIFY" , NIL) aRezult := hb_HGetDef(aAchoice, "RETURN" , {} ) cTitle := hb_HGetDef(aAchoice, "TITLE" , cTitle) cFontName := hb_HGetDef(aAchoice, "FONT" , cFontName) nFontSize := hb_HGetDef(aAchoice, "SIZE" , nFontSize) lFontBold := hb_HGetDef(aAchoice, "BOLD" , lFontBold) aFontColor := hb_HGetDef(aAchoice, "FCOLOR" , NIL) aBackColor := hb_HGetDef(aAchoice, "BCOLOR" , NIL) uParent := hb_HGetDef(aAchoice, "PARENT" , NIL) cIcon := hb_HGetDef(aAchoice, "ICON" , cIcon) lNoLines := hb_HGetDef(aAchoice, "NOLINES" , lNoLines) lSysMenu := hb_HGetDef(aAchoice, "SYSMENU" , lSysMenu) lSelected := hb_HGetDef(aAchoice, "SELECTED", lSysMenu) nLines := hb_HGetDef(aAchoice, "MAXROW" , nMaxRow ) nLayOut := hb_HGetDef(aAchoice, "LAYOUT" , nLayOut ) lHeaders := ! empty(aHeaders) ENDIF IF empty(aItems); RETURN nAchoice ENDIF nMaxRow := nLines nKols := len(aItems) IF nMaxRow > nKols; nMaxRow := nKols ENDIF IF ! empty(nSize) ; nFontSize := nSize ENDIF IF nValue > nKols ; nValue := nKols ENDIF IF empty(aRezult) ; aRezult := array(nKols) ENDIF IF empty(aJustify); aJustify := array(nKols) ENDIF IF ! lHeaders aHeaders := array(nKols) aEval(aHeaders, {|x,n| aHeaders[ n ] := hb_ntos(n) }) ENDIF IF empty(uParent) IF ! empty(_HMG_MainClientMDIName) uParent := _HMG_MainClientMDIName ELSEIF ! empty(_HMG_ActiveFormName) uParent := _HMG_ActiveFormName ELSE uParent := Application.FormName ENDIF ENDIF hParent := iif(hb_IsChar(uParent), GetFormHandle(uParent), uParent) IF ! empty(hParent) IF ( i := AScan( _HMG_aFormHandles, hParent) ) > 0 cParent := _HMG_aFormNames[ i ] ENDIF ENDIF nParentWidth := GetClientWidth (hParent) nParentHeight := GetClientHeight (hParent) nAppRow += GetToolBarHeight(hParent) k := len(aItems[1]) aWidths := array(k) a := array(k); aFill(a, 0) FOR i := 1 TO len(aItems) FOR j := 1 TO k a[ j ] := Max(a[j], GetTxtWidth(aItems[ i ][j] + repl('W', 2), nFontSize, cFontName)) NEXT NEXT aEval(aWidths , {|x,n| aWidths [ n ] := a[ n ] }) aEval(aWidths , {|x,n| nWidth += (x + 1) }) IF nKols > nMaxRow; nWidth += GetVScrollBarWidth() // items больше строк в показе ENDIF DEFINE WINDOW wAchoice AT 0,0 WIDTH 100 HEIGHT 100 ICON cIcon MODAL _SetThisFormInfo(FormIndex(wAchoice)) ThisWindow.Sizable := .F. ThisWindow.MaxButton := .F. ThisWindow.MinButton := .F. ThisWindow.Title := cTitle ThisWindow.TitleBar := ! empty(cTitle) ThisWindow.SysMenu := lSysMenu DEFINE GRID Achoice ROW 0 COL 0 WIDTH nWidth HEIGHT nHeight HEADERS aHeaders WIDTHS aWidths ITEMS aItems VALUE nValue NOLINES lNoLines CELLNAVIGATION lCell SHOWHEADERS lHeaders FONTNAME cFontName FONTSIZE nFontSize FONTBOLD lFontBold FONTCOLOR aFontColor BACKCOLOR aBackColor JUSTIFY aJustify IF lSelected ON DBLCLICK ( nAchoice := wAchoice.Achoice.Value, ThisWindow.Release ) ENDIF END GRID wAchoice.Achoice.Height := GetHeghtBrowse( ControlHandle(Achoice, wAchoice), nMaxRow ) wAchoice.Height := GetTitleHeight() + wAchoice.Achoice.Height + GetBorderHeight() + 2 wAchoice.Width := GetBorderWidth() + wAchoice.Achoice.Width + 2 nFormHeight := wAchoice.Height nFormWidth := wAchoice.Width IF empty(nRow + nCol) .and. nParentWidth > nFormWidth .and. nParentHeight > nFormHeight nH := nParentHeight - nFormHeight - GetBorderHeight() - GetStatusBarHeight() nW := nParentWidth - nFormWidth IF ! ThisWindow.TitleBar; nH += GetTitleHeight() ENDIF IF nLayOut == 0 // центровать в Desktop ELSEIF nLayOut == 1 // левый ВЕРХНИЙ угол в parent окне nRow := 1 nCol := 1 ELSEIF nLayOut == 2 // ( 0.3 ) ВЕРХНИЙ угол в parent окне nRow := 1 nCol := int(nW * 0.33) ELSEIF nLayOut == 3 // центр. ВЕРХНИЙ угол в parent окне nRow := 1 nCol := int(nW / 2) ELSEIF nLayOut == 4 // ( 0.6 ) ВЕРХНИЙ угол в parent окне nRow := 1 nCol := int(nW * 0.67) ELSEIF nLayOut == 5 // правый ВЕРХНИЙ угол в parent окне nRow := 1 nCol := nW ELSEIF nLayOut == 6 // левый НИЖНИЙ угол в parent окне nRow := nH nCol := 1 ELSEIF nLayOut == 7 // ( 0.3 ) НИЖНИЙ угол в parent окне nRow := nH nCol := int(nW * 0.33) ELSEIF nLayOut == 8 // центр. НИЖНИЙ угол в parent окне nRow := nH nCol := int(nW / 2) ELSEIF nLayOut == 9 // ( 0.6 ) НИЖНИЙ угол в parent окне nRow := nH nCol := int(nW * 0.67) ELSEIF nLayOut == 10 // правый НИЖНИЙ угол в parent окне nRow := nH nCol := nW ELSEIF nLayOut == 11 // центровать в parent окне nRow := int(nH / 2) nCol := int(nW / 2) ENDIF ENDIF IF nRow > 0 .and. nCol > 0 wAchoice.Row := nAppRow + nRow wAchoice.Col := nAppCol + nCol ENDIF END WINDOW _SetThisFormInfo() IF empty(nRow) .and. empty(nCol); CENTER WINDOW wAchoice ENDIF ACTIVATE WINDOW wAchoice Save_Rest_HMG(aHmg) IF nAchoice > 0 .and. ! empty(aRezult[ nAchoice ]); nAchoice := aRezult[ nAchoice ] ENDIF RETURN nAchoice FUNCTION Save_Rest_HMG( uHMG ) // save\restore _HMG_... переменные пере MODAL LOCAL aHMG IF hb_IsArray(uHMG) aHMG := uHMG _HMG_BeginWindowMDIActive := aHMG[ 1] _HMG_ActiveStatusHandle := aHMG[ 2] _HMG_UserWindowHandle := aHMG[ 3] _HMG_SetFocusExecuted := aHMG[ 4] _HMG_ThisFormName := aHMG[ 5] _HMG_ThisControlName := aHMG[ 6] _HMG_ActiveFontName := aHMG[ 7] _HMG_ActiveFontSize := aHMG[ 8] _HMG_ExtendedNavigation := aHMG[ 9] _HMG_InplaceParentHandle := aHMG[10] ELSE aHMG := array(10) aHMG[ 1] := _HMG_BeginWindowMDIActive aHMG[ 2] := _HMG_ActiveStatusHandle aHMG[ 3] := _hmg_UserWindowHandle aHMG[ 4] := _HMG_SetFocusExecuted aHMG[ 5] := _HMG_ThisFormName aHMG[ 6] := _HMG_ThisControlName aHMG[ 7] := _HMG_ActiveFontName aHMG[ 8] := _HMG_ActiveFontSize aHMG[ 9] := _HMG_ExtendedNavigation aHMG[10] := _HMG_InplaceParentHandle _HMG_BeginWindowMDIActive := .F. _HMG_ExtendedNavigation := .T. ENDIF RETURN aHMG
|