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 - Virgil Tracy

Páginas: [1] 2 3 4 5
1
Visual Basic 6 / Re:Como programar Msgbox textbox en blanco
« en: Enero 09, 2018, 05:13:12 am »
Código: (vb) [Seleccionar]
Private Function bFailOnVerify() As Boolean

If TxtNombre.Text = "" Then
   MsgBox "Nombre esta vacio", vbInformation
   TxtNombre.SetFocus

   bFailOnVerify = True
   Exit Function
End If

bFailOnVerify = False

End Function

Private Sub Guardar()

If bFailOnVerify Then
   Exit Sub
End If

db.dbUpdate ...

End Sub



Yo ocupo esta estructura cuando grabo en base de datos, una funcion bFailOnVerify() que devuelve Verdadero si falla algo o Falso si todo está bien.  :P

3
Visual Basic 6 / Re:Rellenar con FloodFill usando GDI+ en VB6
« en: Febrero 17, 2017, 02:20:53 pm »
¿ Y usando path ?  :P

Código: (VB) [Seleccionar]
Option Explicit


Private Declare Function CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Dest As Any, Src As Any, ByVal cb As Long) As Long
Private Declare Function GdiplusStartup Lib "gdiplus" (token As Long, inputbuf As GDIPlusStartupInput, Optional ByVal outputbuf As Long = 0) As Long
Private Declare Function GdiplusShutdown Lib "gdiplus" (ByVal token As Long) As Long
Private Declare Function GdipCreateFromHDC Lib "gdiplus" (ByVal hDC As Long, graphics As Long) As Long
Private Declare Function GdipSetSmoothingMode Lib "gdiplus" (ByVal graphics As Long, ByVal SmoothingMd As SmoothingMode) As Long
Private Declare Function GdipDeleteGraphics Lib "gdiplus" (ByVal graphics As Long) As Long
Private Declare Function GdipCreatePath Lib "gdiplus" (ByVal brushmode As FillMode, path As Long) As Long
Private Declare Function GdipAddPathLine Lib "gdiplus" (ByVal path As Long, ByVal x1 As Single, ByVal y1 As Single, ByVal x2 As Single, ByVal y2 As Single) As Long
Private Declare Function GdipFillPath Lib "gdiplus" (ByVal graphics As Long, ByVal Brush As Long, ByVal path As Long) As Long
Private Declare Function GdipDrawPath Lib "gdiplus" (ByVal graphics As Long, ByVal pen As Long, ByVal path As Long) As Long
Private Declare Function GdipCreateSolidFill Lib "gdiplus" (ByVal argb As Long, Brush As Long) As Long
Private Declare Function GdipCreatePen1 Lib "gdiplus" (ByVal color As Long, ByVal Width As Single, ByVal unit As GpUnit, pen As Long) As Long
Private Declare Function GdipDeleteBrush Lib "gdiplus" (ByVal Brush As Long) As Long
Private Declare Function GdipDeletePen Lib "gdiplus" (ByVal pen As Long) As Long
Private Declare Function GdipDeletePath Lib "gdiplus" (ByVal path As Long) As Long


Private Type GDIPlusStartupInput
    GdiPlusVersion                      As Long
    DebugEventCallback                  As Long
    SuppressBackgroundThread            As Long
    SuppressExternalCodecs              As Long
End Type



Private Enum FillMode
   FillModeAlternate        ' 0
   FillModeWinding          ' 1
End Enum

Private Enum GpUnit  ' aka Unit
   UnitWorld      ' 0 -- World coordinate (non-physical unit)
   UnitDisplay    ' 1 -- Variable -- for PageTransform only
   UnitPixel      ' 2 -- Each unit is one device pixel.
   UnitPoint      ' 3 -- Each unit is a printer's point, or 1/72 inch.
   UnitInch       ' 4 -- Each unit is 1 inch.
   UnitDocument   ' 5 -- Each unit is 1/300 inch.
   UnitMillimeter ' 6 -- Each unit is 1 millimeter.
End Enum

' Quality mode constants
Private Enum QualityMode
   QualityModeInvalid = -1
   QualityModeDefault = 0
   QualityModeLow = 1       ' Best performance
   QualityModeHigh = 2      ' Best rendering quality
End Enum

Private Enum SmoothingMode
   SmoothingModeInvalid = QualityModeInvalid
   SmoothingModeDefault = QualityModeDefault
   SmoothingModeHighSpeed = QualityModeLow
   SmoothingModeHighQuality = QualityModeHigh
   SmoothingModeNone
   SmoothingModeAntiAlias
End Enum

Dim GdipToken As Long

Private Sub Form_Click()
Dim pGraphics As Long
Dim path As Long
Dim crSolid As Long
Dim penOutLine As Long

Call GdipCreateFromHDC(Me.hDC, pGraphics)
Call GdipSetSmoothingMode(pGraphics, SmoothingModeHighQuality)

Call GdipCreatePath(FillModeAlternate, path)
Call GdipAddPathLine(path, 50, 50, 300, 50)
Call GdipAddPathLine(path, 300, 50, 200, 200)
Call GdipAddPathLine(path, 200, 200, 50, 150)
Call GdipAddPathLine(path, 50, 150, 50, 50)

Call GdipCreateSolidFill(ConvertColor(vbBlue, 100), crSolid)
Call GdipCreatePen1(ConvertColor(vbBlue, 255), 0.8, UnitWorld, penOutLine)

Call GdipFillPath(pGraphics, crSolid, path)
Call GdipDrawPath(pGraphics, penOutLine, path)


Call GdipDeleteBrush(crSolid)
Call GdipDeletePen(penOutLine)
Call GdipDeletePath(path)

Me.Refresh

Call GdipDeleteGraphics(pGraphics)

End Sub

Private Sub Form_Load()

InitGDI

Me.ScaleMode = vbPixels
Me.AutoRedraw = True
Me.BackColor = vbWhite

End Sub

Private Sub Form_Unload(Cancel As Integer)

TerminateGDI

End Sub








Private Function ConvertColor(color As Long, alpha As Long) As Long
Dim argb(0 To 3) As Byte

argb(3) = CByte(alpha)
argb(0) = ((color \ &H10000) And &HFF) 'blue
argb(1) = ((color \ &H100) And &HFF) 'green
argb(2) = (color And &HFF) 'red
CopyMemory ConvertColor, argb(0), 4&

End Function


'Inicia GDI+
Private Sub InitGDI()
    Dim GdipStartupInput As GDIPlusStartupInput
    GdipStartupInput.GdiPlusVersion = 1&
    Call GdiplusStartup(GdipToken, GdipStartupInput, ByVal 0)
End Sub
 
'Termina GDI+
Private Sub TerminateGDI()
    Call GdiplusShutdown(GdipToken)
End Sub


5
Visual Basic 6 / Re:Copiar y Rotar Graficos con GDI+ en VB6
« en: Enero 06, 2017, 01:05:21 pm »
¿ Y que es lo que quieres hacer ?, en este ejemplo basado de uno de codeproject, cada frame de la rotacion del pie se dibuja completo en un buffer y luego se copia en el usercontrol, lo que da la sensacion de que esta rotando, el control dibuja pie 2d y 3d






http://www.mediafire.com/file/dbjcqyma8in01e0/PieControl.rar

Para trabajar gdiplus en vb6 utilizo una clase wrapper de psc, que te permite usar gdiplus casi con la misma sintaxis de .net

GpGDIPlus Wrapper v1.0---Using GDI+ From VB
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=45451&lngWId=1

6
Visual Basic 6 / Re:Diagrama de red
« en: Septiembre 28, 2016, 12:22:37 pm »
Buscando entre mis cosas encontre el diagrama de red que guarda y recupera de una base de datos, el código está más ordenado que el original

http://www.mediafire.com/file/d6ab69mk1238bt0/DiagramaRedbd.rar

Tambien encontre este diagrama que hice para un salon de té, pero que no se concreto nada, asi que lo guarde y no lo use más, esta en formato Isométrico, para dibujar las sillas y mesas, en la cuadricula se hace click izquierdo y comienza la secuencia de imagenes, con click derecho se borra imagen

http://www.mediafire.com/file/9jgms5z0z7470dv/DiagramaIso.rar













7
Visual Basic 6 / Re:cómo hacer transparente PictureBox ?
« en: Junio 21, 2016, 11:25:21 pm »
Lavolpe hace tiempo creo un truco para hacer un picturebox transparente

http://www.vbforums.com/showthread.php?601310-VB6-Fake-Transparency-for-PictureBox

Código: (VB) [Seleccionar]
Option Explicit

Private Type POINTAPI
    X As Long
    Y As Long
End Type
Private Declare Function SetViewportOrgEx Lib "gdi32.dll" (ByVal hDC As Long, ByVal nX As Long, ByVal nY As Long, ByRef lpPoint As POINTAPI) As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
Private Declare Function ScreenToClient Lib "user32.dll" (ByVal hWnd As Long, ByRef lpPoint As POINTAPI) As Long
Private Declare Function ClientToScreen Lib "user32.dll" (ByVal hWnd As Long, ByRef lpPoint As POINTAPI) As Long
Private Const WM_PAINT As Long = &HF&

Private Sub Command1_Click()
    Dim vPt As POINTAPI
    With Picture1
       ClientToScreen .hWnd, vPt ' convert 0,0 to screen coords
       ScreenToClient .Container.hWnd, vPt ' convert that to container's coords
       SetViewportOrgEx .hDC, -vPt.X, -vPt.Y, vPt ' offset the picbox DC
       SendMessage .Container.hWnd, WM_PAINT, .hDC, ByVal 0& ' tell VB to repaint
       SetViewportOrgEx .hDC, vPt.X, vPt.Y, vPt ' reset picbox DC
       If .AutoRedraw = True then .Refresh
   End With
End Sub

8
Visual Basic 6 / Re:recibir parámetros
« en: Abril 24, 2016, 08:07:37 am »
Command$ devuelve todos los comandos en una sola linea, te faltaba separarlos usando un caracter delimitador, como en split()

Código: (VB) [Seleccionar]
Option Explicit

Public Sub Main()
Dim i As Integer, a

a = GetCommandLine()

For i = 1 To UBound(a)
    MsgBox a(i), vbInformation
Next

End Sub

'/// esta funcion me parece que es del guille
'/// se parece a la funcion split(),
'/// usa como delimitadores de commandos el espacio, el tab, o la coma
'///
Public Function GetCommandLine(Optional nMaxArgs As Integer = 10)
Dim c As String, cLíneaComando As String, nLen As Integer
Dim bArgIn As Boolean, i As Integer, nNroArgs As Integer

ReDim ArgArray(nMaxArgs)

nNroArgs = 0
bArgIn = False

cLíneaComando = Command()
nLen = Len(cLíneaComando)

For i = 1 To nLen

    c = Mid(cLíneaComando, i, 1)
   
    'Comprueba espacio o tabulación.
    If (c <> " " And c <> vbTab And c <> ",") Then
   
       If Not bArgIn Then
         
         If nNroArgs = nMaxArgs Then
            Exit For
         End If
         
         nNroArgs = nNroArgs + 1
         bArgIn = True
       
       End If
       
       ArgArray(nNroArgs) = ArgArray(nNroArgs) & c
       
    Else
       
       bArgIn = False
   
    End If

Next

ReDim Preserve ArgArray(nNroArgs)

GetCommandLine = ArgArray()

End Function


9
Usando el diseñador de consultas de access para un entre fechas 04-12-2015 y 31-12-2015

Código: (SQL) [Seleccionar]
SELECT Codigo, Fecha
FROM Movimiento_Pesaje
WHERE [Fecha] Between #12/4/2015# And #12/31/2015#

10
Cerrar Form después de cierto tiempo de inactividad
http://leandroascierto.com/foro/index.php?topic=1435.0

11
¿ Tienes activados los temas de windows ?

Leandro tiene una clase que usando los temas de windows pone imagenes a los botones

http://leandroascierto.com/blog/clsimagecontrols/

Aqui te dejo un ejemplo para crear el archivo de recursos con el manifest incrustado para asi tener los temas de windows activados usando InitCommonControls()

http://www.mediafire.com/download/dfv31ta1crq3ci3/manif.rar

12
Visual Basic 6 / Re:Herramientas y utilidades para VB6
« en: Agosto 18, 2015, 09:01:58 pm »

13
Visual Basic 6 / Diagrama de red
« en: Agosto 14, 2015, 09:07:54 am »



Diagrama de red

Cada punto del diagrama puede ser selecionado y ser movido en el diagrama, si tuviese enlaces asociados, se moveran junto con el punto.
Para crear el diagrama se utilizan tres metodos, AddImagen, AddPoint y AddLink

AddImagen: Agrega imagenes al diagrama, que despues seran usadas en cada punto, cada imagen es unica, es decir hay una imagen de wifi, una imagen de servidor, etc. Las imagenes del ejemplo son archivos PNG de 64x64, y la imagen de seleccion es de 72x72.

AddPoint: Agrega puntos al diagrama, las coordenadas x,y corresponden al centro de la imagen, para calcular left,top de la imagen se utilizan las formulas left=x-(ancho imagen/2), top=y-(alto imagen/2), pueden haber muchos puntos con la misma imagen, el texto es opcional y es mostrado al pie de la imagen.

AddLink: Agrega enlaces entre puntos al diagrama, los enlaces se dibujan en forma de flechas con la direccion desde el punto inicial hasta el punto de destino, cada enlace tiene un color independiente, el color corresponde a cualquiera de la enumeracion colors, por ejemplo colors.Gold, colors.DarkBlue etc. o puede ser creado usando la funcion ColorARGB(), cada parametro de la funcion es un canal de color, los valores van desde 255 hasta 0, Alpha corresponde a la transparencia, un valor 255 crea un color solido, un valor menor crea un color transparente. Red, Green, Blue son equivalentes a los parametros de la funcion RGB() de vb6, por ejemplo ColorARGB(150, 166, 210, 230) crea un color celeste con transparencia.

http://www.mediafire.com/download/2bghgmzhrokzad2/DiagramaRed.rar


14
Visual Basic 6 / Re:Dibujar Varios Cuadrados
« en: Agosto 07, 2015, 05:18:33 am »
Estas usando posiciones fijas para los puntos del rectangulo, para x2,y2 usa posiciones relativas a x1,y1 mas un ancho y un alto
Para el texto puedes usar TextOut, DrawText
Instala el API-Guide, donde encontraras todas las definiciones de las apis mas ejemplos de como usarlas, en Herramientas y Utilidades para VB6 en este foro la puedes encontrar  :D

Código: (vb) [Seleccionar]
Option Explicit

Private Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function RoundRect Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
Private Declare Function CreatePen Lib "gdi32.dll" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hdc As Long) As Long
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long

Private Sub Form_Load()

    Me.ScaleMode = vbPixels
    Me.AutoRedraw = True
   
    Dim i As Integer
    For i = 0 To 2
        drawArea Me.hdc, i
    Next i
   
End Sub

Private Sub drawArea(ByRef DEShdc As Long, ByVal i As Integer)
    Dim hPen        As Long
    Dim hBrush      As Long
    Dim OldBrush    As Long
    Dim OldPen      As Long

   
    hPen = CreatePen(0, 1, &H3C5AD7)
    hBrush = CreateSolidBrush(&H86E5&)
   
    OldBrush = SelectObject(DEShdc, hBrush)
    OldPen = SelectObject(DEShdc, hPen)
   
    Dim x As Long
    Dim y As Long
    Dim cText As String
   
    x = 1
    y = 20 + (100 * i)
   
    'TextOut usa ForeColor como color de texto
    'y Font como fuente de texto
    cText = "UN TEXTO"
    TextOut DEShdc, x, y - 15, cText, Len(cText)
   
    'x1,y1
    '  *---------+
    '  |         |
    '  |         h
    '  |         |
    '  +----w----*
    '          x2,y2
    'x2 = x1 + w
    'y2 = y1 + h
    '
    'x1,y1 y x2,y2 son los puntos de la diagonal del rectangulo
    'x1 + ancho rectangulo es x2
    'y1 + alto rectangulo es y2
    RoundRect hdc, x, y, x + 20, y + 50, 8, 8
   
    Call SelectObject(DEShdc, OldPen)
    Call SelectObject(DEShdc, OldBrush)
   
    DeleteObject hPen
    DeleteObject hBrush
   
End Sub

15
Visual Basic 6 / Re:Descargar Crystal Report 9 o Crystal Report 9.2
« en: Mayo 19, 2015, 09:23:10 pm »
Crystal Report 9.2 en ingles, nunca lo encontre en castellano  :(

el numero de serie esta dentro del comprimido

http://www.mediafire.com/download/wroohii819rc0lp/Crystal92.rar

Páginas: [1] 2 3 4 5