Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    [VB6] richiamare periodicamente una funzione

    Come posso fare a richiamre la funzione function1 ciclicamente?
    Io già so che function1 durerà 30 secondi, come posso richiamre function1 alla fine dei 30-35 secondi(vorrei dare anche qlc secondo di "riposo")?
    Non mi conviene fare un ciclo infinito per richiamare la funzione, o no?

    Ho provato a mettere un timer settato a 30000 creando la funzione in questo modo, ma la function1 non mi viene richiamata quando trascorrono i 10 secondi.
    codice:
    Private Sub Timer1_Timer()
            Call function1
            Me.Hide
    End Sub
    CIAO

  2. #2
    infatti hai sbagliato valore

    se vuoi che venga richiamata ongi 10 secondi devi mettere 10000 e non 30000 (che equivale a 30 secondi)
    visitate www.pcprimipassi.it, il portale italiano per i neofiti del computer

    "Tanto prima o poi ti buco...." disse il baco alla noce!

  3. #3
    Si si, a parte il problema del tempo :-) ora mi accorgo che la seconda volta non mi richiama la funzione.
    Apro un form dove ho messo nel Form_load timer1.enabled=true in modo che comincia a contare, poi la funzione timer è:
    codice:
    Public Sub Timer1_Timer()
           Static tempo As Integer
    If tempo = 0 Then
        Call ProcessCapInfo
        Me.Hide
        tempo = tempo + 1
    
    ElseIf tempo = 10 Then
        tempo = 0
        Call ProcessCapInfo
      magbox "entrato"
        Me.Hide
    Else
        tempo = tempo + 1
    Exit Sub
    End If
    la ProcessCapInfo viene chiamata solo la prima volta(cioè quando tempo = 0) mentre quando tempo = 10 viene visualizzata solo la msgbox
    senza che si avvii la ProcessCapInfo.
    codice:
    Public Sub ProcessCapInfo()
    With CapParams
    '   // set the defaults we won't bother the user with
    '   show message after pre-roll
        .fMakeUserHitOKToCapture = -(True) ' - converts VB Boolean to C BOOL
    '   in case we use error callbacks later
        .wPercentDropForError = 10
    '   fUsingDOSMemory is obsolete
        .fUsingDOSMemory = False
    '   The number of video buffers should be enough to get through
    '   disk seeks and thermal recalibrations
        .wNumVideoRequested = 32
    '   Do abort on the left mouse
        .fAbortLeftMouse = -(True)
    '   Do abort on the right mouse
        .fAbortRightMouse = -(True) '- converts VB boolean to C BOOL
    '   If wChunkGranularity is zero, the granularity will be set to the
    '   disk sector size.
        .wChunkGranularity = 0
    '   use default
        .dwAudioBufferSize = 0
    '   attempt to disable caching
        .fDisableWriteCache = -(True)
    '   not using MCI
        .fMCIControl = False
        .fStepCaptureAt2x = False
    '   not multi-threading
        .fYield = False
    '   request audio buffers
        .wNumAudioRequested = 4 '10 is max limit
    
    '   //these parameters are loaded from registry
        If "AUDIO" = Trim$(UCase(GetSetting(App.Title, "preferences", "streammaster", "AUDIO"))) Then
            .AVStreamMaster = AVSTREAMMASTER_AUDIO 'use audio clock to synchronize AVI
        Else
            .AVStreamMaster = AVSTREAMMASTER_NONE
        End If
        'set index size of AVI file (max frames)
        .dwIndexSize = Val(GetSetting(App.Title, "preferences", "maxframes", INDEX_15_MINUTES))
    
    '   //Now set the parameters from the UserInput
        .dwRequestMicroSecPerFrame = microsSecFromFPS(Val(txtFps.Text))
        .fCaptureAudio = -(CBool(chkAudio.Value))
        .fLimitEnabled = -(CBool(chkLimit.Value))
        .wTimeLimit = Val(txtSec.Text)
    
    End With
    'set the new setup info
    Call capCaptureSetSetup(frmMain.capwnd, CapParams)
    'Kludgy - but...
    Me.Tag = True 'this tells main form that OK button was pushed
    End Sub
    Purtroppo(o per fortuna) questo è un codice che ho trovato in rete e mi rendo sempre più conto di quanto è difficile mettere mano al codice scritto da altri.
    Sono disposto anche a mettere l'intero progetto a disposizione se qlc1 volesse aiutarmi.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.