Mostrar Mensajes

Esta sección te permite ver todos los posts escritos por este usuario. Ten en cuenta que sólo puedes ver los posts escritos en zonas a las que tienes acceso en este momento.


Mensajes - yokesee

Páginas: [1] 2 3
1
Visual Basic 6 / Re:Vb6NotifyIcon
« en: Marzo 13, 2023, 04:02:20 pm »
Hola J. Elihu
Muy buen trabajo.
Tengo un problema, me gustaría poder mover el icono en una posicion expecifica de la barra y que se quedara anclada, pero cada vez que vuelves abrir el programa se oculta creo que se debe a que en el evento Class_Initialize se ejecuta:
Código: [Seleccionar]
    '/* Guid to Uniquely Identify */
    Call CoCreateGuid(Guid_)
Y esto crea un guid aleatorio cada vez entonces windows no lo puede guardar la información para guardar la posición de ese icono.

Un saludo y gracias

2
Muchas gracias NEBIRE lo tendré en cuenta todos tus consejos.
Se que hay otros lenguajes que permiten todo esto de controles y crear plugin sin necesidad de registrar lo,
que posiblemente sean mas fáciles de usar.Pero me cuesta mucho despegarme de mi querido y ya un poco anticuado VB6.

Puedes probar con un VPN o alguna pagina que te redireccione allí con otra ip por que aquí en España por ejemplo si funciona perfectamente y en distintas ciudades.

un saludo

3
ya es que en el programa principal no le quería cargar de muchas cosas y tener lo todo mas modular con plugins.
pues la pagina funciona perfectamente creo que es problema tuyo entro muy a menudo en ella incluso hace menos de un mes me resolvieron una duda.

4
Hola muchas gracias por contestar
si mi código estaba un poco desordenado pero era por que estuve haciendo pruebas cuando funciona luego todo lo suelo optimizar un poco mas.

me funciono perfectamente con el ctl lo que no entiendo es por que no funciona con un simple botón me importaba que funcionara con el ctl ya que lo del botón era a modo de prueba un botón se puede instanciar sin ningún problema.

es que uso una clase para cargar las dll sin necesidad de registrar a modo de plugins y como no se puede hacer los mismo con los controles de usuario ocx y necesito de unos pocos pues con este sistema me sale un poco del paso.
http://www.vbforums.com/showthread.php?782719-VB6-Regfree-Usage-of-your-own-VB-and-other-COM-Dlls-per-DirectCOM-Helper
uso esa por si a alguien le interesa.

un saludo y muchas gracias

5
Hola a todos
tengo un dll del que obtengo un form y lo meto dentro de un PictureBox y también desactivo el foco para que no parpadee la ventana al cambiar el foco y funciona todo bien.
Yo quería usar lo pero para controles sueltos e conseguido instanciar lo en donde yo quiero pero dejan de funcionar los eventos.
lo probé con un simple botón con un MsgBox simple que al dar le click y al instanciar lo por suelto no funciona el evento.
Es una prueba seria también para controles personalizados.
Como podría recibir los eventos.
Un saludo y gracias


código que uso para instanciar la ventana dentro del PictureBox .
Código: [Seleccionar]
Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function CloseWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long

Private Const WM_DESTROY = &H2
Private Const WM_CLOSE = &H10
Const SHOWMAXIMIZED_eSW = 3&
Const WS_HIDE = 0
Const WS_NORMAL = 1
Const GWL_STYLE = (-16)
Const WS_CHILD = &H40000000
Const WS_EX_CLIENTEDGE = &H200

Public Sub MoveWindowInPictureBox_expecifico(formmover As Form, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long)
'    MsgBox formmover.hwnd
    MoveWindow formmover.hwnd, x, y, nWidth, nHeight, 1
End Sub
Public Sub MoveWindowInPictureBox_cero(formmover As Form)
'    MsgBox formmover.hwnd
    MoveWindowInPictureBox formmover, 0, 0
End Sub
Public Sub MoveWindowInPictureBox(formmover As Form, ByVal x As Long, ByVal y As Long)
'    MsgBox formmover.hwnd
    MoveWindow formmover.hwnd, x, y, formmover.Width, formmover.Height, 1
End Sub
Public Sub SetParentToPictureBox(hwndwindow As Long, hwndPictureBox As Long)
    Call SetParent(hwndwindow, hwndPictureBox)
    SetWindowLong hwndwindow, GWL_STYLE, GetWindowLong(hwndwindow, GWL_STYLE) Or WS_CHILD
End Sub

Public Sub ShowWindowInPictureBox_NORMAL(hwndwindow As Long)
    Call ShowWindow(hwndwindow, WS_NORMAL)
End Sub
Public Sub ShowWindowInPictureBox_MAXIMIZE(hwndwindow As Long)
    Call ShowWindow(hwndwindow, SHOWMAXIMIZED_eSW)
End Sub
Public Sub HideWindowInPictureBox(hwndwindow As Long)
    Call ShowWindow(hwndwindow, WS_HIDE)
End Sub
Public Sub CloseWindowInPictureBox(hwndwindow As Long)
    SendMessage hwndwindow, WM_CLOSE, 0, 0
End Sub
Public Sub ResetParentToPictureBox(hwndwindow As Long)
    Call SetParent(hwndwindow, 0)
End Sub


6
Visual Basic 6 / Re:gif en systray
« en: Febrero 02, 2017, 02:56:11 pm »
muchas gracias NEBIRE lo tendré encuenta todo lo que me has dicho
gracias por enseñarme cosas nuevas siempre se aprende algo
un saludo

7
Visual Basic 6 / Re:gif en systray
« en: Febrero 02, 2017, 01:55:02 pm »

8
Visual Basic 6 / Re:gif en systray
« en: Febrero 01, 2017, 10:51:26 pm »
gracias NEBIRE por contestar.
habria alguna manera de convertir un archivo bmp en vbPicTypeIcon por que los stdpictures se pueden guardar como bmp y asi lo extraeria y  lo convertiria y luego lo mostraria.
e encontrado este modulo pero no lo entiendo mucho pone que convierte de bmp a ico pero con mask.
http://www.thevbzone.com/modBitmap.bas


un saludo

9
Visual Basic 6 / gif en systray
« en: Febrero 01, 2017, 03:28:25 pm »
hola a todos tengo la siguiente clase que me devuelve todas las imagenes y tiempos de un archivo gif.
Código: [Seleccionar]
Option Explicit
Private Declare Function CreateCompatibleBitmap Lib "gdi32.dll" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hdc As Long) As Long
Private Declare Function DeleteDC Lib "gdi32.dll" (ByVal hdc As Long) As Long
Private Declare Function SelectObject Lib "gdi32.dll" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As Long) As Long
Private Declare Function RedrawWindow Lib "user32.dll" (ByVal hwnd As Long, ByRef lprcUpdate As RECT, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
'Private Declare Function DrawIconEx Lib "user32.dll" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
'Private Declare Function DestroyIcon Lib "user32.dll" (ByVal hIcon As Long) As Long

Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (lpPictDesc As PICTDESC, riid As Any, ByVal fOwn As Long, ipic As IPicture) As Long

Private Type PICTDESC
    cbSize As Long
    pictType As Long
    hIcon As Long
    hPal As Long
End Type

' custom UDT - animated gif frame properties
Private Type AniGifProps
    aPic As StdPicture      ' the image itself
    aInterval As Integer    ' the gif-coded frame interval
    aTop As Long            ' the gif-coded top offset
    aLeft As Long           ' the gif-coded left offset
    aMisc As Long           ' could be remarks or other needed information
End Type
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type
Private updateRect As RECT


' collection of gif frames
Private aniFrames() As AniGifProps

' used to help prevent flicker during animation
Public picBkBuff As StdPicture
Private m_contador As Integer
Public ruta As String

Public Function LoadGif(aniPath As String) As Boolean
    On Error GoTo ErrHandler

    Dim fNum As Integer
    Dim MaxX As Long, MaxY As Long
    Dim MaxOffsetX As Long, MaxOffsetY As Long
    Dim imgSize As Long
    Dim imgHeader As String, fileHeader As String
    Dim buf$, picbuf$
    Dim imgCount As Integer
    Dim I&, J&, xOff&, yOff&, TimeWait&
    Dim GifEnd As String
   
    GifEnd = Chr(0) & Chr(33) & Chr(249)            ' flag indicating end of file
   
    fNum = FreeFile
    Open aniPath For Binary Access Read As fNum
        buf = String(LOF(fNum), Chr(0))
        Get #fNum, , buf                                            'Get GIF File into buffer
    Close fNum
   
    I = 1
    J = InStr(1, buf, GifEnd) + 1
    fileHeader = Left(buf, J)

    If Left$(fileHeader, 3) <> "GIF" Then
       MsgBox "This file is not an animated GIF file", vbInformation + vbOKOnly
       Exit Function
    End If
   
    cleargif
    ruta = aniPath
    I = J + 2
    Do
        J = InStr(I, buf, GifEnd) + 3
        If J > Len(GifEnd) Then
            fNum = FreeFile
            Open "temp.gif" For Binary As fNum
                picbuf = String(Len(fileHeader) + J - I, Chr(0))
                picbuf = fileHeader & Mid(buf, I - 1, J - I)
                Put #fNum, 1, picbuf
                imgHeader = Left(Mid(buf, I - 1, J - I), 16)
            Close fNum
            ReDim Preserve aniFrames(0 To imgCount)
            With aniFrames(imgCount)
                .aInterval = ((Asc(Mid(imgHeader, 4, 1))) + (Asc(Mid(imgHeader, 5, 1)) * 256)) * 10
                Set .aPic = LoadPicture("temp.gif")
                .aLeft = Val(Asc(Mid(imgHeader, 9, 1)) + (Asc(Mid(imgHeader, 10, 1)) * 256&))
                .aTop = Val(Asc(Mid(imgHeader, 9, 1)) + (Asc(Mid(imgHeader, 10, 1)) * 256&))
            End With
            imgCount = imgCount + 1
            I = J
            Kill "temp.gif"
        End If
    Loop Until J = 3

    If I < Len(buf) Then
        fNum = FreeFile
        Open "temp.gif" For Binary As fNum
            picbuf = String(Len(fileHeader) + Len(buf) - I, Chr(0))
            picbuf = fileHeader & Mid(buf, I - 1, Len(buf) - I)
            Put #fNum, 1, picbuf
            imgHeader = Left(Mid(buf, I - 1, Len(buf) - I), 16)
        Close fNum
        ReDim Preserve aniFrames(0 To imgCount)
        With aniFrames(imgCount)
            .aInterval = ((Asc(Mid(imgHeader, 4, 1))) + (Asc(Mid(imgHeader, 5, 1)) * 256)) * 10
            Set .aPic = LoadPicture("temp.gif")
            .aLeft = Val(Asc(Mid(imgHeader, 9, 1)) + (Asc(Mid(imgHeader, 10, 1)) * 256&))
            .aTop = Val(Asc(Mid(imgHeader, 9, 1)) + (Asc(Mid(imgHeader, 10, 1)) * 256&))
        End With
        Kill "temp.gif"
    End If

    For imgCount = 0 To UBound(aniFrames)
        With aniFrames(imgCount)
           
            If .aInterval > 60000 Then  ' no interval > 60000
                .aInterval = 60000
            ElseIf .aInterval = 0 Then  ' no zero intervals (use 100 as default)
                .aInterval = 100
            End If
           
            imgSize = ConvertHimetrix2Pixels(.aPic.Width, True) + Abs(.aLeft)
            If imgSize > MaxX Then MaxX = imgSize
            imgSize = ConvertHimetrix2Pixels(.aPic.Height, False) + Abs(.aTop)
            If imgSize > MaxY Then MaxY = imgSize
            If .aLeft < 0 Then
               If Abs(.aLeft) > MaxOffsetX Then MaxOffsetX = Abs(.aLeft)
            End If
            If .aTop < 0 Then
                If Abs(.aTop) > MaxOffsetY Then MaxOffsetY = Abs(.aTop)
            End If
           
        End With
    Next
   
    If MaxOffsetX > 0 Or MaxOffsetY > 0 Then
        For imgCount = 0 To UBound(aniFrames)
            With aniFrames(imgCount)
                .aLeft = .aLeft + MaxOffsetX
                .aTop = .aTop + MaxOffsetY
            End With
        Next
    End If
    m_contador = 0
    LoadGif = True
    Exit Function

ErrHandler:
    MsgBox "Error No. " & Err.Number & " when reading file", vbCritical
    If fNum Then Close #fNum
    m_contador = -1
    cleargif
    LoadGif = False
End Function
Public Function ConvertHimetrix2Pixels(vHiMetrix As Long, byWidth As Boolean) As Long
    If byWidth Then
        ConvertHimetrix2Pixels = vHiMetrix * 1440 / 2540 / Screen.TwipsPerPixelX
    Else
        ConvertHimetrix2Pixels = vHiMetrix * 1440 / 2540 / Screen.TwipsPerPixelY
    End If
End Function

Public Function ConvertPixels2Himetrix(vPixels As Long, byWidth As Boolean) As Long
    If byWidth Then
        ConvertPixels2Himetrix = vPixels / 1440 * 2540 * Screen.TwipsPerPixelX
    Else
        ConvertPixels2Himetrix = vPixels / 1440 * 2540 * Screen.TwipsPerPixelY
    End If
End Function
Private Sub CreateBackBuffImg(cX As Long, cY As Long, Form As Object)
    Dim bkBuffDC As Long, bkBuffBmp As Long, oldBmp As Long
    Dim destWidth As Long, destHeight As Long
   
    destWidth = Form.picAni.Width / Screen.TwipsPerPixelX
    destHeight = Form.picAni.Height / Screen.TwipsPerPixelY

    Form.picAni.Cls
    If Not picBkBuff Is Nothing Then Set picBkBuff = Nothing
    If cX > destWidth Then cX = destWidth
    If cY > destHeight Then cY = destHeight
   
    On Error Resume Next    ' want a message box if error occurs here
    With updateRect
        .Left = (destWidth - cX) \ 2
        .Top = (destHeight - cY) \ 2
        .Right = .Left + cX - 1
        .Bottom = .Top + cY - 1

        bkBuffDC = CreateCompatibleDC(gif.hdc)

        bkBuffBmp = CreateCompatibleBitmap(Form.hdc, cX, cY)
        oldBmp = SelectObject(bkBuffDC, bkBuffBmp)

        gif.picAni.Picture.Render bkBuffDC + 0, 0, 0, cX + 0, cY + 0, _
            Form.ScaleX(.Left, vbPixels, vbHimetric), _
            Form.ScaleY(destHeight - .Top, vbPixels, vbHimetric), _
            Form.ScaleX(cX, vbPixels, vbHimetric), _
            -Form.ScaleY(cY, vbPixels, vbHimetric), ByVal 0&
    End With
   
    If Err Then MsgBox Err.Description  'for testing only

    SelectObject bkBuffDC, oldBmp
    DeleteDC bkBuffDC

    Set picBkBuff = HandleToPicture(bkBuffBmp, True)
End Sub



Private Function HandleToPicture(ByVal hHandle As Long, isBitmap As Boolean) As Picture
On Error GoTo ExitRoutine

    Dim pic As PICTDESC
    Dim guid(0 To 3) As Long

    pic.cbSize = Len(pic)
    If isBitmap Then pic.pictType = vbPicTypeBitmap Else pic.pictType = vbPicTypeIcon
    pic.hIcon = hHandle

    guid(0) = &H7BF80980
    guid(1) = &H101ABF32
    guid(2) = &HAA00BB8B
    guid(3) = &HAB0C3000
    OleCreatePictureIndirect pic, guid(0), True, HandleToPicture

ExitRoutine:
End Function

'Public Function redraw(ByVal hwnd As Long, ByRef lprcUpdate As RECT)
'    RedrawWindow hwnd, lprcUpdate, ByVal 0, 1
'End Function
Public Sub cleargif()
    Erase aniFrames
End Sub

Public Function pic(index As Integer)
    Set pic = aniFrames(index).aPic
End Function
Public Function picc() As StdPicture
    Set picc = aniFrames(m_contador).aPic
End Function

Public Function picPicture() As Picture
    Set picPicture = HandleToPicture(aniFrames(m_contador).aPic, True)
End Function
Public Sub nextgif()
    If m_contador = UBound(aniFrames) Then m_contador = -1
     m_contador = m_contador + 1
End Sub

Public Function interval(index As Integer) As Integer
    interval = aniFrames(index).aInterval
End Function
Public Function contador() As Integer
    contador = m_contador
End Function
Public Function count() As Integer
    count = UBound(aniFrames)
End Function


Private Sub Class_Terminate()
    m_contador = -1
    cleargif
End Sub


Código: [Seleccionar]
Public gif As clsGif
Set gif = New clsGif
gif.LoadGif "ruta gif"

y tanto pic como picc devuelve un stdpicture
funciona perfectamente para un image control o picturebox
pero no me funciona en un systray claro esta que para hacer la prueba seria mostrar la primera imagen y luego ya con un timer mostrar las siguientes pero de eso ya me encargo yo.

un saludo

10
si jajaj no soy un experto pero se me da bien vb6 quiero cambiarme a .net
pero me resulta complicado haber si algun dia me pongo a ello.
todos mis códigos son en vb6 pero veo que ya poco a poco se esta quedando muy atrás.
un saludo

11
muchas gracias NEBIRE
al final se me ocurrio una forma mas sencilla pero tus opciones las mirare mas detenidamente que e visto buenas ideas.
mi solucion fue como devuelve un objeto primero verificar si es nothing y luego ya ejecutarlo.
Código: [Seleccionar]
If Not plugin("ToolTip") Is Nothing Then plugin("ToolTip").addtooltip Commandrefrescar.hWnd, "refrescar lista", "refrescar", 1, 1

un saludo y gracias

12
Hola  a todos.
tengo un problema tengo una funcion que retorna un object y si es nothing no deberia seguir la funcion que lo llamo.

Código: [Seleccionar]
Public Function plugin(nombre As String)
    On Error GoTo error1
    If m_plugins.Item(nombre).pluginisnothing Then
        MsgBox "plugin nothing"
        Set plugin = Nothing
    Else
        Set plugin = m_plugins.Item(nombre).plugin
    End If
    Exit Function
error1:
    Set plugin = Nothing
End Function


esa es mi funcion y yo la llamo asi
Citar
      plugin("ToolTip").addtooltip Commandrefrescar.hWnd, "refrescar lista", "refrescar", 1, 1

el objeto retornado contiene una funcion a la que invoco.
ya se que poniendo un simple on error resume next sobraría pero tengo que poner muchos y me gustaría que fueran en una sola linea.
y que si da error se cancele la llamada o no se ejecute la subrutina creo que se llama

un saludo

13
Visual Basic 6 / Re:Borrado selectivo de proyectos recientes
« en: Junio 08, 2016, 11:10:32 pm »
no tranquilo no pasa nada simplemente me dio por seguir probando por curiosidad jaja.
y eso de (alejamiento de la programación principalmente)
ya se que ocupa muchísimas horas y dolores de cabeza pero sin poder crear cosas yo no podría estar jaja.
un saludo y espero que te vuelva animar

14
Visual Basic 6 / Re:Borrado selectivo de proyectos recientes
« en: Junio 08, 2016, 10:44:03 pm »
a por cierto muy importante cuando hagas los cambios ten cerrado el editor vb6 porque al cerrar el ide se volverán añadir los recientes que tenia el guardados o se añadirá alguno mas que no quieras haz pruebas

15
Visual Basic 6 / Re:Borrado selectivo de proyectos recientes
« en: Junio 08, 2016, 10:39:33 pm »
hola ya haciendo pruebas me tome el tiempo de hacerte este programilla
te lista las claves que hay en HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0\RecentFiles
no se si habra alguna api que te devuelva todas las que hay por eso improvise y puse que listase todas del 1 al 100 por ejemplo,
luego te las añade a un listbox que hay simplemente tu ya sabras maneras para ordenarlo.
y luego el boton lo que hace es borra HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0\RecentFiles
y escribe todas las claves del listbox utilizando el indice de cada item del listbox como numero.

Código: [Seleccionar]
Private Sub Form_Load()
    Dim texto As String
    For i = 1 To 100
        texto = Registry_Read("HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0\RecentFiles\", i)
        If Not texto = "" Then List1.AddItem texto
    Next
End Sub
Private Sub Command1_Click()
    Registry_delete "HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0\RecentFiles\"
    Registry_write "HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0\RecentFiles\", ""
    For i = 0 To List1.ListCount - 1
        Registry_write "HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0\RecentFiles\" & (i + 1), List1.List(i)
    Next
End Sub
Private Function Registry_Read(Key_Path, Key_Name) As Variant
    On Error Resume Next
    Dim Registry As Object
    Set Registry = CreateObject("WScript.Shell")
    Registry_Read = Registry.RegRead(Key_Path & Key_Name)
End Function

Private Sub Registry_write(Key_Path, value)
    On Error Resume Next
    Dim Registry
    Set Registry = CreateObject("WScript.Shell")
    Registry.RegWrite Key_Path, value, "REG_SZ"
End Sub
Private Sub Registry_delete(Key_Path)
    On Error Resume Next
    Dim Registry As Object
    Set Registry = CreateObject("WScript.Shell")
    Registry.RegDelete (Key_Path)
End Sub


un saludo perdón esta echo deprisa y corriendo no se si habrá alguna manera de optimizar el codigo

Páginas: [1] 2 3