Visualizzazione dei risultati da 1 a 9 su 9
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2003
    Messaggi
    137

    vb 2005 conversione progetto

    Sto importando un progetto fatto con vb 6 in vb 2005 solo che come è ovvio, ci sono dei problemi. Quello che proprio non riesco a capire è in questo pezzo di codice:

    codice:
    GetWindowThreadProcessId(mhwndVB, mlngProcessID)
    	' The process ID makes the hidden window caption unique.
    		If 0 = FindWindow(vbNullString, PROC_CAPTION & CStr(mlngProcessID)) Then
    		' The window wasn't found, so this is the first thread.
                    If App.StartMode = vbSModeStandalone Then
                        ' Create hidden form with unique caption.
                        mfrmProcess.Text = PROC_CAPTION & CStr(mlngProcessID)
                        ' The Initialize event of MainApp (Instancing =
                        '   PublicNotCreatable) shows the main user interface.
                        ma = New MainApp
                        ' (Application shutdown is simpler if there is no
                        '   global reference to MainApp; instead, MainApp
                        '   should pass Me to the main user form, so that
                        '   the form keeps MainApp from terminating.)
                    Else
                        Err.Raise(ERR_NoAutomation + vbObjectError, , "Application can't be started with Automation")
                    End If
    			End If
    l'errore è in grassetto con il messaggio:

    vbSModeStandalone non dichiarato. Sapete dirmi come sistemarlo? grazie mille

  2. #2
    Utente di HTML.it
    Registrato dal
    Mar 2003
    Messaggi
    137
    inoltre ho questo messaggio che non riesco a risolvere su questa riga:

    Call EnumThreadWindows(System.Threading.Thread.CurrentT hread.ManagedThreadID, AddressOf EnumThreadWndMain, 0)

    Il messaggio è: Errore 1 L'espressione "AddressOf" non può essere convertita in "Integer" perché "Integer" non è un tipo delegato.

    Declare Function EnumThreadWindows Lib "user32" (ByVal dwThreadId As Integer, ByVal lpfn As Integer, ByVal lParam As Integer) As Integer

    codice:
    ' Call-back function used by EnumThreadWindows.
    Public Function EnumThreadWndMain(ByVal hWnd As Integer, ByVal lParam As Integer) As Integer
    		' Save the window handle.
    		mhwndVB = hWnd
    		' The first window is the only one required.
    		' Stop the iteration as soon as a window has been found.
    		EnumThreadWndMain = ENUM_STOP
    	End Function
    Che devo fare per risolverli??

  3. #3
    Puo' darsi che non c'entri nulla, ma i parametri dell'EnumThreadWindows , sulla guida API, sono diversi. Ti posto l'esempio tratto dall'API guide:
    codice:
    'The EnumThreadWindows function enumerates all nonchild windows associated with a 
    'thread by passing the handle of each window, in turn, to an application-defined callback 
    'function. EnumThreadWindows continues until the last window is enumerated or the 
    'callback function returns FALSE.
    'in a form
    Private Sub Form_Load()
        'KPD-Team 2000
        'URL: http://www.allapi.net/
        'E-Mail: KPDTeam@Allapi.net
        Dim ThreadID As Long, ProcessID As Long  ' receive id to thread and process of Form1
        ' Determine the thread which owns this window
        ThreadID = GetWindowThreadProcessId(Me.hWnd, ProcessID)
        ' Use the callback function to list all of the enumerated thrad windows
        EnumThreadWindows ThreadID, AddressOf EnumThreadWndProc, 0
        'Show the results
        Me.AutoRedraw = True
        Me.Print sClasses
    End Sub
    'In a module
    Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
    Declare Function EnumThreadWindows Lib "user32" (ByVal dwThreadId As Long, ByVal lpfn As Long, ByVal lParam As Long) As Long
    Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
    'variable used to list all the classnames
    Public sClasses As String
    Public Function EnumThreadWndProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
        Dim Ret As Long, sText As String
        'create a string-buffer
        sText = Space(255)
        'get the classname of the window handle
        Ret = GetClassName(hWnd, sText, 255)
        'cut off the unnecessary part of Chr$(0)'s
        sText = Left$(sText, Ret)
        'add this classname to the list of classnames
        sClasses = sClasses + sText + vbCrLf
        'continue the enumeration
        EnumThreadWndProc = 1
    End Function
    Ciauz

    Chico

  4. #4
    Originariamente inviato da kappabit
    Il messaggio è: Errore 1 L'espressione "AddressOf" non può essere convertita in "Integer" perché "Integer" non è un tipo delegato.
    Address Of in Vb 2005 dovrebbe apparire con accanto l'icona di una "valigetta" e un "cubetto rosa" dentro alla "valigetta". Quelle sono le sub delegate, significa che in questo caso Integer non puoi utilizzarlo, prova ad utilizzare Decimal, o Int32, o Int16 o int 64. Oppure potresti provare Double!
    Imbarazzo della scelta!! Per me! Ma non può essere, dovrebbe essere un Namespace personalizzato!! Non esiste almeno, nel mio computer "Address Of " !

    Secondo me sono una fregatura, a che cacchio servono le Delegate Sub?:

    codice:
    Public Delegate Sub  Aryballos()
    Non puoi mettere nemmeno un comando in questo metodo!!
    codice:
        Public Sub  Skyphos()
            'Qui le istruzioni 
        End Sub
    Devi utilizzare ^^ la sub in alto!

    Questo esempio significa che ste Delegate Sub non servono a niente, non so perchè si usano!!
    Devi mettere un metodo nella Delegate Sub ( Una Sub nella Delegate Sub).
    Vabbè allora come può essere che ti dice che non è un tipo di Delegate????

  5. #5
    Utente di HTML.it L'avatar di cassano
    Registrato dal
    Aug 2004
    Messaggi
    3,002
    io le uso sempre e sono utilissime con i thread ma anche per altre operazioni asincrone.

  6. #6
    Utente di HTML.it
    Registrato dal
    Mar 2003
    Messaggi
    137
    però perchè non mi va? ecco cosa dice la guida:

    Aggiungere un delegato per l'operatore AddressOf e modificare il parametro della dichiarazione di funzione secondo il tipo Delegate:

    codice:
    Delegate Function SubClassProcDelegate(ByVal hwnd As Integer, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer 
    Declare Function SetWindowLong Lib "USER32.DLL" Alias "SetWindowLongA" (ByVal hwnd As Integer, ByVal attr As Integer, ByVal lVal As SubClassProcDelegate) As Integer
    Sub SubClassWindow(ByVal hwnd As Integer)
       If PrevProcPtr = 0 Then
          PrevProcPtr = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf SubClassProc)
       End If
    End Sub
    ma non va, l errore non è più sulla riga di prima ma si è spostato sul declare EnumThreadWindows ...

  7. #7
    Utente di HTML.it
    Registrato dal
    Mar 2003
    Messaggi
    137
    funzionaa!!!! Ok grazie mille lo stesso praticamente bisogna fare come detto nella guida anche se non capisco prima nello stesso modo non andasse!!

  8. #8
    Originariamente inviato da cassano
    io le uso sempre e sono utilissime con i thread ma anche per altre operazioni asincrone.
    Cosa sono i thread?
    Vorresti dire che le delegate sub servono per i thread?

  9. #9
    Utente di HTML.it L'avatar di cassano
    Registrato dal
    Aug 2004
    Messaggi
    3,002
    si anche ma nn solo.

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 © 2026 vBulletin Solutions, Inc. All rights reserved.