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

    [VB.NET] Percentuale nella Progress Bar

    Ho creato manualmente una progressbar da una PictureBox. Volendo ora disegnare la % raggiunta, mi chiedevo come si fa a draware un testo di un colore che quando viene "raggiunto" dalla progressbar diventa di colore dello sfondo.

    Non so se mi sono spiegato, spero di si

    Se si, come faccio??

  2. #2
    vuoi fare a colori invertiti insomma?
    DYNAMIC+ [ E-mail ]

    Secondo me non si può fare!

  3. #3
    proprio così

  4. #4
    Originariamente inviato da gygabyte017
    proprio così
    ti suggerisco di usare la api "BitBlt" (o simili) e utilizzare una funzione raster invertente
    DYNAMIC+ [ E-mail ]

    Secondo me non si può fare!

  5. #5
    Ho cercato su google, ma non ho trovato niente di interessante, ne non la dichiarazione della funzione BitBlt. Ma come si usa? Potresti farmi un esempietto sapendo che Bar è la PictureBox e io disegno tutto nell'evento paint?

    Public Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Integer) As Integer


    Eccovi il codice:
    codice:
      Private Sub Bar_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Bar.Paint
        'dal verde al giallo
        Dim DRed As Integer = ColorB.R - ColorA.R
        Dim DGreen As Integer = ColorB.G - ColorA.G
        Dim DBlue As Integer = ColorB.B - ColorA.B
        ' pos:100=x:width-1 -> x=pos*(width-1)/100
        Dim max As Integer = Position * (Bar.Width - 1) / 100
    
        Dim XRed As Double = DRed / max
        Dim XGreen As Double = DGreen / max
        Dim XBlue As Double = DBlue / max
    
        Dim i As Integer
        Dim ared As Double = ColorA.R
        Dim agreen As Double = ColorA.G
        Dim ablue As Double = ColorA.B
        Dim penna As Pen = New Pen(Color.FromArgb(ared, agreen, ablue))
    
        For i = 0 To max - 1
    
          penna.Color = Color.FromArgb(Math.Round(ared), Math.Round(agreen), Math.Round(ablue))
          e.Graphics.DrawLine(penna, i, 0, i, Bar.Height - 1)
    
          If DRed <> 0 Then
            ared += XRed
          End If
          If DGreen <> 0 Then
            agreen += XGreen
          End If
          If DBlue <> 0 Then
            ablue += XBlue
          End If
        Next
        e.Graphics.DrawRectangle(Pens.Black, 0, 0, Bar.Width - 1, Bar.Height - 1)
        e.Graphics.DrawString(Position.ToString & " %", New Font("Arial", 8), Brushes.Blue, Bar.Width / 2 - 2, Bar.Height / 2 - 2)
    
        Bar.Invalidate()
    
      End Sub

  6. #6
    up e... domandina aggiuntiva... come mai la 1^ riga da un errore?
    codice:
    Dim DRed As Integer = ColorB.R - ColorA.R

  7. #7
    up. ho letto che pisogna fare un xor ma non ho capito come. Aiutatemi graazie

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.