begin process at 2010 02 10 08:48:08
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Message Box

 > TEXTE DÉFILANT DANS LE STYLE BANNIÈRE (OCX)

TEXTE DÉFILANT DANS LE STYLE BANNIÈRE (OCX)


 Information sur la source

Note :
2 / 10 - par 1 personne
2,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Message Box Classé sous :défilant, bannière, textedéfilant Niveau :Initié Date de création :05/04/2006 Vu / téléchargé :10 309 / 1 136

Auteur : by2k

Ecrire un message privé
Commentaire sur cette source (2)
Ajouter un commentaire et/ou une note

 Description

Après plusieurs semaines de recheche, j'ai enfin trouver un code qui me permet à partir d'un fichier de faire défiler du texte avec un départ à droite, gauche, haut ou bas.
Appelé sous forme d'un OCX, il est facilement paramètrable et consomme très peu de ressource.
Je représise tout de même que le code d'origine n'est pas de moi.

Source

  • 'Créer un module nommé modBanner et coller le code suivant :
  • '
  • '
  • Option Explicit
  • Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, _
  • ByVal x As Long, ByVal y As Long, _
  • ByVal nWidth As Long, ByVal nHeight As Long, _
  • ByVal hSrcDC As Long, ByVal xSrc As Long, _
  • ByVal ySrc As Long, ByVal dwRop As Long) As Long
  • Public Const SRCCOPY = &HCC0020
  • '
  • '#################################################################################################"
  • '
  • 'Puis créer un contrôle utilisateur nommé textBanner et coller le code suivant :
  • '
  • '
  • Option Explicit
  • Private banX&, banY&, banHeight&, banWidth&
  • Private m_Scrolltext As String
  • Private m_backColor As OLE_COLOR, m_foreColor As OLE_COLOR
  • Private m_speed As Integer
  • Private m_scrollMode As Integer
  • Dim retVal As Long
  • Private WithEvents m_Font As StdFont
  • Private Sub setDim(vNewValue As Variant)
  • On Error GoTo err
  • picBuffer.Height = picBuffer.TextHeight(vNewValue) + 5
  • picBuffer.Width = picBuffer.TextWidth(vNewValue) + 10
  • picBuffer.Cls
  • Exit Sub
  • err:
  • Resume Next
  • End Sub
  • Public Property Get scrollText() As Variant
  • scrollText = m_Scrolltext
  • End Property
  • Public Property Let scrollText(ByVal vNewValue As Variant)
  • On Error GoTo err
  • m_Scrolltext = " " & vNewValue & " "
  • banX = picBanner.ScaleLeft
  • banY = picBanner.ScaleTop
  • picBanner.Cls
  • banHeight = picBuffer.ScaleHeight
  • banWidth = picBuffer.ScaleWidth
  • Call setDim(vNewValue)
  • picBuffer.Print vNewValue
  • Exit Property
  • err:
  • Resume Next
  • End Property
  • Public Sub scrollOn()
  • Timer1.Enabled = True
  • End Sub
  • Public Sub scrollOff()
  • Timer1.Enabled = False
  • End Sub
  • Private Sub picBanner_Click()
  • Timer1.Enabled = Not (Timer1.Enabled)
  • End Sub
  • Private Sub Timer1_Timer()
  • banHeight = picBuffer.ScaleHeight
  • banWidth = picBuffer.ScaleWidth
  • retVal = BitBlt(picBanner.hDC, banX, banY, _
  • banWidth, banHeight, _
  • picBuffer.hDC, 0, 0, SRCCOPY)
  • picBanner.Refresh
  • Select Case scrollMode
  • Case 0:
  • banX = banX - 1
  • If banX < 0 - banWidth Then
  • banX = picBanner.ScaleLeft + picBanner.ScaleWidth
  • End If
  • Case 1:
  • banX = banX + 1
  • If banX > picBanner.ScaleLeft + picBanner.ScaleWidth Then
  • banX = 0 - banWidth
  • End If
  • Case 2:
  • banY = banY - 1
  • If banY < (0 - picBuffer.ScaleHeight) Then
  • banY = picBanner.ScaleTop + picBanner.ScaleHeight
  • End If
  • Case 3:
  • banY = banY + 1
  • If banY > (picBanner.ScaleTop + picBanner.ScaleHeight) Then
  • banY = 0 - picBuffer.Height
  • End If
  • End Select
  • End Sub
  • Private Sub UserControl_Initialize()
  • Set m_Font = New StdFont
  • Set UserControl.font = m_Font
  • picBanner.ZOrder 0
  • picBanner.ScaleMode = vbPixels
  • UserControl.ScaleMode = vbPixels
  • picBuffer.ScaleMode = vbPixels
  • picBuffer.AutoRedraw = True
  • picBanner.AutoRedraw = True
  • backColor = vbBlue
  • foreColor = vbYellow
  • picBuffer.font = "Arial"
  • picBanner.font = "Arial"
  • speed = 30
  • scrollMode = 0
  • picBuffer.font.Bold = True
  • picBuffer.font.Size = 10
  • scrollText = "Scrolling Banner Control : Please place your own text inside here."
  • picBuffer.Print scrollText
  • End Sub
  • Public Property Get backColor() As OLE_COLOR
  • backColor = m_backColor
  • End Property
  • Public Property Let backColor(ByVal vNewValue As OLE_COLOR)
  • On Error GoTo err
  • m_backColor = vNewValue
  • picBuffer.Cls
  • picBuffer.backColor = vNewValue
  • picBanner.backColor = vNewValue
  • picBuffer.Print scrollText
  • PropertyChanged "backColor"
  • Exit Property
  • err:
  • Resume Next
  • End Property
  • Public Property Get foreColor() As OLE_COLOR
  • foreColor = m_foreColor
  • End Property
  • Public Property Let foreColor(ByVal vNewValue As OLE_COLOR)
  • On Error GoTo err
  • m_foreColor = vNewValue
  • picBuffer.Cls
  • picBuffer.foreColor = vNewValue
  • picBanner.foreColor = vNewValue
  • picBuffer.Cls
  • picBuffer.Print scrollText
  • PropertyChanged "foreColor"
  • Exit Property
  • err:
  • Resume Next
  • End Property
  • Private Sub UserControl_Paint()
  • picBuffer.font.Size = m_Font.Size
  • Call setDim(scrollText)
  • picBuffer.Print scrollText
  • End Sub
  • Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  • On Error GoTo err
  • speed = PropBag.ReadProperty("speed", "")
  • font = PropBag.ReadProperty("font", "")
  • scrollText = PropBag.ReadProperty("scrollText", "")
  • backColor = PropBag.ReadProperty("backColor", "")
  • foreColor = PropBag.ReadProperty("foreColor", "")
  • Exit Sub
  • err:
  • Resume Next
  • End Sub
  • Private Sub UserControl_Resize()
  • If UserControl.Height > 5000 Then
  • UserControl.Height = 5000
  • ElseIf UserControl.Width > 19000 Then
  • UserControl.Width = 19000
  • End If
  • picBanner.Width = UserControl.ScaleWidth
  • picBanner.Height = UserControl.ScaleHeight
  • End Sub
  • Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  • On Error GoTo err
  • PropBag.WriteProperty "speed", speed, "default"
  • PropBag.WriteProperty "font", font, "default"
  • PropBag.WriteProperty "scrollText", scrollText, "default"
  • PropBag.WriteProperty "backColor", backColor, "default"
  • PropBag.WriteProperty "foreColor", foreColor, "default"
  • Exit Sub
  • err:
  • Resume Next
  • End Sub
  • Public Property Get font() As StdFont
  • Set font = m_Font
  • End Property
  • Public Property Let font(ByVal vNewValue As StdFont)
  • With m_Font
  • .Bold = vNewValue.Bold
  • .Italic = vNewValue.Italic
  • .Name = vNewValue.Name
  • .Size = vNewValue.Size
  • End With
  • PropertyChanged "font"
  • picBuffer.font = m_Font
  • picBanner.Cls
  • Call setDim(scrollText)
  • picBuffer.Print scrollText
  • End Property
  • Private Sub m_Font_FontChanged(ByVal PropertyName As String)
  • Set UserControl.font = m_Font
  • Call setDim(scrollText)
  • picBanner.Cls
  • picBuffer.Print scrollText
  • Refresh
  • End Sub
  • Public Property Get speed() As Variant
  • speed = m_speed
  • End Property
  • Public Property Let speed(ByVal vNewValue As Variant)
  • If vNewValue > 0 And vNewValue < 51 Then
  • m_speed = vNewValue
  • Timer1.Interval = 51 - vNewValue
  • ElseIf vNewValue = "" Then
  • m_speed = 30
  • Timer1.Interval = 51 - 30
  • Else
  • err.Raise vbObjectError + 512, , "Speed out of range (1-50)" & vNewValue
  • End If
  • End Property
  • Public Property Get scrollMode() As Variant
  • scrollMode = m_scrollMode
  • End Property
  • Public Property Let scrollMode(ByVal vNewValue As Variant)
  • If vNewValue >= 0 Or vNewValue <= 4 Then
  • m_scrollMode = vNewValue
  • End If
  • End Property
  • '
  • '#################################################################################################"
  • '
  • 'Pour la mise en forme voir le ZIP
  • '
  • '
  • '
'Créer un module nommé modBanner et coller le code suivant :
'
'
Option Explicit

Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, _
                                    ByVal x As Long, ByVal y As Long, _
                                    ByVal nWidth As Long, ByVal nHeight As Long, _
                                    ByVal hSrcDC As Long, ByVal xSrc As Long, _
                                    ByVal ySrc As Long, ByVal dwRop As Long) As Long
                                    
Public Const SRCCOPY = &HCC0020

'
'#################################################################################################"
'

'Puis créer un contrôle utilisateur nommé textBanner et coller le code suivant :
'
'
Option Explicit
Private banX&, banY&, banHeight&, banWidth&
Private m_Scrolltext As String
Private m_backColor As OLE_COLOR, m_foreColor As OLE_COLOR
Private m_speed As Integer
Private m_scrollMode As Integer
Dim retVal As Long
Private WithEvents m_Font As StdFont

Private Sub setDim(vNewValue As Variant)
    On Error GoTo err
    
    picBuffer.Height = picBuffer.TextHeight(vNewValue) + 5
    picBuffer.Width = picBuffer.TextWidth(vNewValue) + 10
    picBuffer.Cls
    
    Exit Sub
    
err:
    Resume Next
End Sub

Public Property Get scrollText() As Variant
    scrollText = m_Scrolltext
End Property

Public Property Let scrollText(ByVal vNewValue As Variant)
    On Error GoTo err
    
    m_Scrolltext = " " & vNewValue & " "
    
    banX = picBanner.ScaleLeft
    banY = picBanner.ScaleTop
    
    picBanner.Cls
    
    banHeight = picBuffer.ScaleHeight
    banWidth = picBuffer.ScaleWidth
    
    Call setDim(vNewValue)
    
    picBuffer.Print vNewValue
    
    Exit Property
err:
    Resume Next
End Property

Public Sub scrollOn()
    Timer1.Enabled = True
End Sub

Public Sub scrollOff()
    Timer1.Enabled = False
End Sub

Private Sub picBanner_Click()
    Timer1.Enabled = Not (Timer1.Enabled)
End Sub

Private Sub Timer1_Timer()

    banHeight = picBuffer.ScaleHeight
    banWidth = picBuffer.ScaleWidth
    
    retVal = BitBlt(picBanner.hDC, banX, banY, _
                                banWidth, banHeight, _
                picBuffer.hDC, 0, 0, SRCCOPY)
    
    picBanner.Refresh
    Select Case scrollMode
        Case 0:
                banX = banX - 1
                    If banX < 0 - banWidth Then
                        banX = picBanner.ScaleLeft + picBanner.ScaleWidth
                    End If
        Case 1:
                banX = banX + 1
                If banX > picBanner.ScaleLeft + picBanner.ScaleWidth Then
                    banX = 0 - banWidth
                End If
        Case 2:
                banY = banY - 1
                If banY < (0 - picBuffer.ScaleHeight) Then
                    banY = picBanner.ScaleTop + picBanner.ScaleHeight
                End If
        Case 3:
                banY = banY + 1
                If banY > (picBanner.ScaleTop + picBanner.ScaleHeight) Then
                    banY = 0 - picBuffer.Height
                End If
    End Select
End Sub

Private Sub UserControl_Initialize()
    Set m_Font = New StdFont
    Set UserControl.font = m_Font

    picBanner.ZOrder 0
    picBanner.ScaleMode = vbPixels
    UserControl.ScaleMode = vbPixels
    picBuffer.ScaleMode = vbPixels
    picBuffer.AutoRedraw = True
    picBanner.AutoRedraw = True
    backColor = vbBlue
    foreColor = vbYellow
    
    picBuffer.font = "Arial"
    picBanner.font = "Arial"
    
    speed = 30
    scrollMode = 0
    picBuffer.font.Bold = True
    picBuffer.font.Size = 10
    
    scrollText = "Scrolling Banner Control : Please place your own text inside here."
    picBuffer.Print scrollText
End Sub


Public Property Get backColor() As OLE_COLOR
    backColor = m_backColor
End Property

Public Property Let backColor(ByVal vNewValue As OLE_COLOR)
    On Error GoTo err
    
    m_backColor = vNewValue
    
    picBuffer.Cls
    picBuffer.backColor = vNewValue
    picBanner.backColor = vNewValue
    picBuffer.Print scrollText
    
    PropertyChanged "backColor"
    
    Exit Property
    
err:
    Resume Next
End Property

Public Property Get foreColor() As OLE_COLOR
    foreColor = m_foreColor
End Property

Public Property Let foreColor(ByVal vNewValue As OLE_COLOR)
    On Error GoTo err
    
    m_foreColor = vNewValue
    
    picBuffer.Cls
    picBuffer.foreColor = vNewValue
    picBanner.foreColor = vNewValue
    picBuffer.Cls
    picBuffer.Print scrollText
    
    PropertyChanged "foreColor"
    Exit Property
    
err:
    Resume Next
End Property

Private Sub UserControl_Paint()
    picBuffer.font.Size = m_Font.Size
    
    Call setDim(scrollText)
    
    picBuffer.Print scrollText
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    On Error GoTo err
    
    speed = PropBag.ReadProperty("speed", "")
    font = PropBag.ReadProperty("font", "")
    scrollText = PropBag.ReadProperty("scrollText", "")
    backColor = PropBag.ReadProperty("backColor", "")
    foreColor = PropBag.ReadProperty("foreColor", "")
    
    Exit Sub
    
err:
    Resume Next
End Sub

Private Sub UserControl_Resize()
    If UserControl.Height > 5000 Then
        UserControl.Height = 5000
    ElseIf UserControl.Width > 19000 Then
        UserControl.Width = 19000
    End If

    picBanner.Width = UserControl.ScaleWidth
    picBanner.Height = UserControl.ScaleHeight
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    On Error GoTo err
    
    PropBag.WriteProperty "speed", speed, "default"
    PropBag.WriteProperty "font", font, "default"
    PropBag.WriteProperty "scrollText", scrollText, "default"
    PropBag.WriteProperty "backColor", backColor, "default"
    PropBag.WriteProperty "foreColor", foreColor, "default"
    
    Exit Sub
    
err:
    Resume Next
End Sub

Public Property Get font() As StdFont
    Set font = m_Font
End Property

Public Property Let font(ByVal vNewValue As StdFont)
    With m_Font
       .Bold = vNewValue.Bold
       .Italic = vNewValue.Italic
       .Name = vNewValue.Name
       .Size = vNewValue.Size
    End With
    PropertyChanged "font"
    picBuffer.font = m_Font
    
    picBanner.Cls
    Call setDim(scrollText)
    
    picBuffer.Print scrollText
End Property

Private Sub m_Font_FontChanged(ByVal PropertyName As String)
    Set UserControl.font = m_Font

    Call setDim(scrollText)
    
    picBanner.Cls
    picBuffer.Print scrollText
   Refresh
End Sub

Public Property Get speed() As Variant
    speed = m_speed
End Property

Public Property Let speed(ByVal vNewValue As Variant)
    If vNewValue > 0 And vNewValue < 51 Then
        m_speed = vNewValue
        Timer1.Interval = 51 - vNewValue
    ElseIf vNewValue = "" Then
        m_speed = 30
        Timer1.Interval = 51 - 30
    Else
        err.Raise vbObjectError + 512, , "Speed out of range (1-50)" & vNewValue
    End If
End Property

Public Property Get scrollMode() As Variant
    scrollMode = m_scrollMode
End Property

Public Property Let scrollMode(ByVal vNewValue As Variant)
    If vNewValue >= 0 Or vNewValue <= 4 Then
        m_scrollMode = vNewValue
    End If
End Property


'
'#################################################################################################"
'

'Pour la mise en forme voir le ZIP
'
'
'


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources de la même categorie

Source avec Zip Source avec une capture Source .NET (Dotnet) MESSAGE BOX A CHOIX MULTIPLE par mafieulemouton
Source avec Zip Source avec une capture Source .NET (Dotnet) MSGBOX MULTILINGUE par Blodox
Source avec Zip Source avec une capture AUTRE PETITE FAQ par JLB59
Source avec Zip Source avec une capture INDEXER LE TEXTE D'UN LISTBOX (POUR UNE FAQ PAR EXEMPLE) par JLB59
Source avec Zip ERROR MESSAGE : ENVOYER DES MESSAGE D'ERREUR EN MSGBOX AVEC ... par Alucard49000

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture Source .NET (Dotnet) LABEL ACTIF (DÉFILEMENT, CLIGNOTANT, FIXE) ET GRADIENT VB200... par claudetom
Source avec Zip Source avec une capture BARRE À GAUCHE DÉFILANTE par rimas10
BANNIÉRE POUR LABEL par kimo
Source avec Zip FORCER QQ UN À CLIQUER SUR VOTRE BANNIÈRE DE PUB par programme35

Commentaires et avis

Commentaire de origamiste le 18/04/2006 16:58:18

Bonjour by2k,

Je voulais simplement dire que votre code source est intéressant. Je suis débutant (je n'ai même pas fini ma formation), il me permet donc d'approfondir mes connaissances. Alors bravo et merci...
Origamiste

Commentaire de JLB59 le 03/07/2006 12:06:08

Bonjour By2k,

Je suis certain que ton prg est opérationnel, mais moi, je n'arrive pas à le faire fonctionner.

Je charge l'ocx, c'est OK, mais lorsque j'exécute j'ai le msg "Format de fichier incorrect".

C'est dû à quoi et y a-t-il une solution ?

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

Gagner du fric avec les affilieurs [ par Maxxx ] Salut tt le monde !!!g besoin d'aide à propos des composants inet et winsockEn fait je veux faire un prog capable de lancer des affilieurs ( comme qua Comment faire un text défilant (scroller) [ par joeygrondin ] Salut,j'aimerais savoir comment on faite un texte défilant avec un contrôle utilisateur.Merci. Netteté d'un GIF [ par monopheme ] Bonjour !J'ai créé ma bannière puis je l'ai convertie en GIF mais le problême est que l'image n'est pas belle du tout, je veux dire, ça ne ressemble p rollover texte défilant [ par minipo ] BON c'est super m&#233;ga con c'que j'demande et j'suis dessus depuis au moins une semaine et ca me gave s&#233;rieux: <span style="font-family: Texte défilant [ par by2k ] Bonjour &#224; tous, je (tente) code en VB6. Je suis &#224; la recherche d'une bout de code me permettant de faire d&#233;filer un texte de fa&#231;o Texte défilant sans limitation ? [ par by2k ] Bonjour &#224; tous, Je code en VB6. Je souhaiterais faire d&#233;filer un texte provenant d'une fichier (txt), pouvant &#233;volu&#233;, le simpleme Texte défilant Excel [ par peisinoe ] Bonjour,Votre site m'a déjà bien aidé, mais voilà, je bloque depuis qq jours sur un problème. J'ai cherché partout, personne n'a la réponse: Je voudra Text défilant [ par erriyadimounir ] Bjr à tous,C mounir,j un mini-projet en vb et j besoin d'utiliser un texte défilant,j aucune idée comment le faire,si quelqu'un peut m'aider pour que Graphique défilant dans pictureBox ? [ par rapido6 ] Bonjour a Tous,J'utilise une pictureBox qui me permet de dessiner un graphique par rapport un timer.Donc le graphique (courbe) dépasse le pictureBox


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,671 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales