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
SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning
|