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

    [vb6]insetire Una Barra Colorata In Un Form

    Salve ragazzi qualcuno sa come inserire una barra simile a quella che ho allegato in un Form riuscendo a sfumare i colori.Grazie
    Immagini allegate Immagini allegate

  2. #2
    Per il gradiente puoi usare l'Api GdiGradientFillRect.
    Esempio (adattato dall'Api Guide)
    codice:
    Private Type TRIVERTEX
        x As Long
        y As Long
        Red As Integer 'Ushort value
        Green As Integer 'Ushort value
        Blue As Integer 'ushort value
        Alpha As Integer 'ushort
    End Type
    Private Type GRADIENT_RECT
        UpperLeft As Long  'In reality this is a UNSIGNED Long
        LowerRight As Long 'In reality this is a UNSIGNED Long
    End Type
    Const GRADIENT_FILL_RECT_H As Long = &H0 'In this mode, two endpoints describe a rectangle. The rectangle is
    'defined to have a constant color (specified by the TRIVERTEX structure) for the left and right edges. GDI interpolates
    'the color from the top to bottom edge and fills the interior.
    Const GRADIENT_FILL_RECT_V  As Long = &H1 'In this mode, two endpoints describe a rectangle. The rectangle
    ' is defined to have a constant color (specified by the TRIVERTEX structure) for the top and bottom edges. GDI interpolates
    ' the color from the top to bottom edge and fills the interior.
    Const GRADIENT_FILL_TRIANGLE As Long = &H2 'In this mode, an array of TRIVERTEX structures is passed to GDI
    'along with a list of array indexes that describe separate triangles. GDI performs linear interpolation between triangle vertices
    'and fills the interior. Drawing is done directly in 24- and 32-bpp modes. Dithering is performed in 16-, 8.4-, and 1-bpp mode.
    Const GRADIENT_FILL_OP_FLAG As Long = &HFF
    Private Declare Function GdiGradientFillRect Lib "gdi32" Alias "GdiGradientFill" (ByVal hdc As Long, pVertex As TRIVERTEX, ByVal dwNumVertex As Long, pMesh As GRADIENT_RECT, ByVal dwNumMesh As Long, ByVal dwMode As Long) As Long
    Private Function LongToUShort(Unsigned As Long) As Integer
        'A small function to convert from long to unsigned short
        LongToUShort = CInt(Unsigned - &H10000)
    End Function
    Private Sub Form_Load()
        'KPD-Team 2001
        'URL: http://www.allapi.net/
        'E-Mail: KPDTeam@Allapi.net
        'API uses pixels
        Me.ScaleMode = vbPixels
        Me.AutoRedraw = True
    End Sub
    Private Sub picture1_Paint()
        Dim vert(1) As TRIVERTEX
        Dim gRect As GRADIENT_RECT
        'from black
        With vert(0)
            .x = 0
            .y = 0
            .Red = LongToUShort(&HFF00&)
            .Green = LongToUShort(&HFF00&)
            .Blue = LongToUShort(&HFF00&)
            .Alpha = 1&
        End With
        'to red
        With vert(1)
            .x = Me.ScaleWidth
            .y = Me.ScaleHeight
            .Red = LongToUShort(&HFF00&)
            .Green = LongToUShort(&HFF00&)
            .Blue = 0&
            .Alpha = 0&
        End With
        gRect.UpperLeft = 0
        gRect.LowerRight = 1
        GdiGradientFillRect Picture1.hdc, vert(0), 2, gRect, 1, GRADIENT_FILL_RECT_H
    End Sub
    E' sufficiente inserire una PictureBox sul Form (Picture1) e incollare il codice di cui sopra.

    Ciauz

    CHico

  3. #3
    Semplicemente grazie mille, sei come si dice in questi casi.
    MITICO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!

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.