frmwindow.frm

来自「多种图表的绘制及其运用」· FRM 代码 · 共 545 行 · 第 1/2 页

FRM
545
字号
VERSION 5.00
Begin VB.Form frmWindow 
   Caption         =   "Window"
   ClientHeight    =   3945
   ClientLeft      =   165
   ClientTop       =   450
   ClientWidth     =   4800
   LinkTopic       =   "Form1"
   ScaleHeight     =   3945
   ScaleWidth      =   4800
   Begin VB.TextBox objTBOX 
      Height          =   360
      Index           =   0
      Left            =   30
      TabIndex        =   3
      Text            =   "objTBOX"
      Top             =   975
      Visible         =   0   'False
      Width           =   1305
   End
   Begin VB.PictureBox objPIC 
      AutoRedraw      =   -1  'True
      DrawWidth       =   3
      ForeColor       =   &H00000000&
      Height          =   945
      Index           =   0
      Left            =   2940
      ScaleHeight     =   59
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   64
      TabIndex        =   2
      Top             =   105
      Visible         =   0   'False
      Width           =   1020
   End
   Begin VB.TextBox objTAREA 
      Height          =   720
      Index           =   0
      Left            =   1500
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   1
      Text            =   "frmWindow.frx":0000
      Top             =   225
      Visible         =   0   'False
      Width           =   1245
   End
   Begin VB.CommandButton objBUTTON 
      Caption         =   "objBUTTON"
      Height          =   480
      Index           =   0
      Left            =   90
      TabIndex        =   0
      Top             =   180
      Visible         =   0   'False
      Width           =   1245
   End
End
Attribute VB_Name = "frmWindow"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' =========================================================
'  === Project of Data-flow Visual Programming Language ===
' =========================================================
' Copyright Emu8086, Inc. Free Code !
'
'
' URL: http://www.emu8086.com/vb/


' info@emu8086.com






Option Explicit

' collection of all GUI objects on form:
Public theGUI As GUI_Collection

' window events handlers:
Dim sDo_on_load As String
Dim sDo_on_resize As String

' keep the original caller function, to avoid
'  calling resize function over and over:
Dim sCallerFunction As String
Dim bAllow_resize As Boolean

Private Sub Form_Activate()
    bWINDOW_ACTIVATED = True
End Sub

Private Sub Form_Load()
    ' don't allow resizing!
    bAllow_resize = False

    bWINDOW_LOADED = True
    
    sCallerFunction = currentFileName
        
    Me.Icon = frmMain.Icon
    
    FORCE_CLOSE = False

    ' initialize the collection:
    Set theGUI = New GUI_Collection
    Set theGUI.Parent = Me

    setWindowSize Me, currentRunPointer.zParam1
    setControls Me, currentRunPointer.zParam2, True
    
    ' use temporary variable, since
    '    rcToken() changes the source string
    Dim sTemp As String
    sTemp = currentRunPointer.zParam3
    '=========== set "ON LOAD" function:
    sDo_on_load = rcToken(sTemp, "|")
    '=========== set "ON RESIZE" function:
    sDo_on_resize = rcToken(sTemp, "|")
  
    
    ' execute "On Load" function for a window:
    If sDo_on_load <> "" Then
        executeFunction sDo_on_load, "ONLOAD-NOPARAM"
    End If

    ' should be set "True" only after "On Load" is loaded,
    '  to prevent simultaneous call of executeFunction():
    bAllow_resize = True
    
    ' here you can call Form_Resize() to resize execute,
    '  (original Form_Resize() call is ignored because of
    '    bAllow_resize = False).
End Sub

Private Sub Form_Resize()
    If Me.WindowState = vbMinimized Then Exit Sub

    bWINDOW_IS_RESIZING = True
    
    ' make sure it won't be executed several times!
    '   solutions:
    '    a. stop everything with emptying the STACK?
    '    b. I think I'll better run here in an iternal loop,
    '       until any function returns to this file.
    '    c. just exit sub... it doesn't seem to be buggy at least.
    
    ' Form_Load() and Form_Resize() seems to execute
    ' at the same time, here is the print out of a Timer:
    '     load:  65406.15
    '     resize:  65406.15
    '     activate:  65406.48
    ' that's why bAllow_resize is set only after "ON LOAD" is executed,
    '  because when calling executeFunction() simultaneously
    '  for "ON LOAD" and "ON RESIZE" only one of them is executed...
    ' IMPR: I'm not sure if someone can click on two buttons simultaneously to make
    '         a simultaneous call of executeFunction(), but in any way we should think
    '         of a better solution.
    If (Not bAllow_resize) _
       Or (StrComp(ExtractFileName(sCallerFunction), ExtractFileName(currentFileName), vbTextCompare) <> 0) _
       Or (Not bWINDOW_LOADED) Or (Not bWINDOW_ACTIVATED) Then
        bWINDOW_IS_RESIZING = False
        Exit Sub
    End If

 'since:
 'sCallerFunction: G:\Projects\TZ\tz0081in\d.tzr
 'currentFileName: \\ORT\SYS\USERS\MARGOLIN\PROJECTS\TZ\TZ0081IN\d.tzr
 ' when comparing, compare only the file name and not full path!!!



    ' execute "On Resize" function for a window:
    If sDo_on_resize <> "" Then
        executeFunction sDo_on_resize, "ONRESIZE-NOPARAM"
    End If
    
    bWINDOW_IS_RESIZING = False
End Sub



Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    ' continue when window is closed,
    '  only if closed by user:
    If Not FORCE_CLOSE Then
        Set currentRunPointer = getNextBlock(currentRunPointer, "")  ' any (should be one).
        frmMain.StartExecution
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    bWINDOW_LOADED = False
    bWINDOW_ACTIVATED = False
End Sub


' left click on button:
Private Sub objButton_Click(Index As Integer)
   executeFunction theGUI.getObjectFromIndex(Index, "BUTTON").sFunction1, "NO_PARAMETERS"
End Sub

' right click on button:
Private Sub objBUTTON_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 2 Then
        executeFunction theGUI.getObjectFromIndex(Index, "BUTTON").sFunction2, "NO_PARAMETERS"
    End If
End Sub

' left and right clicks on a picture box:
Private Sub objPIC_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        ' left click:
        executeFunction theGUI.getObjectFromIndex(Index, "PIC").sFunction1, X & "," & Y
    ElseIf Button = 2 Then
        ' right click:
        executeFunction theGUI.getObjectFromIndex(Index, "PIC").sFunction2, X & "," & Y
    End If
End Sub

' left and right clicks on a text area:
Private Sub objTAREA_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        ' left click:
        executeFunction theGUI.getObjectFromIndex(Index, "TAREA").sFunction1, X & "," & Y
    ElseIf Button = 2 Then
        ' right click:
        executeFunction theGUI.getObjectFromIndex(Index, "TAREA").sFunction2, X & "," & Y
    End If
End Sub


' left and right clicks on a text box:
Private Sub objTBOX_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then
        ' left click:
        executeFunction theGUI.getObjectFromIndex(Index, "TBOX").sFunction1, X & "," & Y
    ElseIf Button = 2 Then
        ' right click:
        executeFunction theGUI.getObjectFromIndex(Index, "TBOX").sFunction2, X & "," & Y
    End If
End Sub

' executes a function, if it's not a registered
'   function name, then it's a filename:
' IMPR: simultaneous call of this function makes problems,
'        since: 1. both functions will return to the same place,
'               2. currentRunPointer will be resent by second
'                  "simultaneous" call, and first will be lost for ever,
'                  and thus it will not be executed.
'        solution: make sure executeFunction() isn't called
'                  simultaneously, though it's hard to click two
'                  buttons at the same time, "ON_LOAD" and "ON_RESIZE"
'                  seems to execute simultaneously (fixed in this
'                  module by bAllow_resize).
Private Sub executeFunction(sCommand As String, sParameters As String)

    ' just in case, sometimes it maybe called on Resize when
    '   flow is going to be terminated, so this fixes it:
    ' this also prevents executing functions when flow is stoped,
    '   but window isn't unloaded for some reason:
    If currentRunPointer Is Nothing Then Exit Sub
    

    ' result of internal function is ignored (not stored):
    If Not executeInternalFunction(sCommand, sParameters, "") Then
    
        ' copied (with changes) from "FUNCTION" of

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?