Accueil > > > TEXTE DÉFILANT DANS LE STYLE BANNIÈRE (OCX)
TEXTE DÉFILANT DANS LE STYLE BANNIÈRE (OCX)
Information sur la source
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
'
'
'
Sources de la même categorie
Commentaires et avis
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éga con c'que j'demande et j'suis dessus depuis au moins une semaine et ca me gave sérieux: <span style="font-family:
Texte défilant [ par by2k ]
Bonjour à tous, je (tente) code en VB6. Je suis à la recherche d'une bout de code me permettant de faire défiler un texte de faço
Texte défilant sans limitation ? [ par by2k ]
Bonjour à tous, Je code en VB6. Je souhaiterais faire défiler un texte provenant d'une fichier (txt), pouvant évolué, 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
|
Derniers Blogs
UNE JOLIE-HORLOGE ET PAS QU'UN PEU !UNE JOLIE-HORLOGE ET PAS QU'UN PEU ! par neodante
Pour les possesseurs d'iPhone, ça y est Bijin Tokei - qui se traduit littéralement en Français par " Jolie Horloge " - est arrivé et GRATUITEMENT s'il vous plaît ! Après la version Tokyo, Hokkaido, night club, racing, Gal, "pour les mademoiselles'", . voi...
Cliquez pour lire la suite de l'article par neodante TECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICESTECHDAYS PARIS 2010 : CONNECTEZ VOS DONNéES à SHAREPOINT 2010 AVEC LES BUSINESS CONNECTIVITY SERVICES par ROMELARD Fabrice
Animé par: Gaetan Bouveret et Julien Chomarat Business Connectivity Services (BCS) est dans SharePoint 2010 la version 2 de Business Data Catalog (BDC dans SharePoint 2007). Il s'agit de la solution permettant de visualiser des données provenan...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE[DIVERS] SUIVRE VOS SéRIES PRéFéRéS SUR LA TOILE par orion
Comme de nombreux geek, je suis un grand amateur de série TV et je rate régulièrement des épisodes de mes séries préférés. Une solution s'offre à vous avec ce merveilleux site : Tv Gorge - www.tvgorge.com Moteur de recherche à l'appui, vous pouvez ...
Cliquez pour lire la suite de l'article par orion TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
VB.NET ET COMBOBOXVB.NET ET COMBOBOX par minouthebreaker
Cliquez pour lire la suite par minouthebreaker
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|