Accueil > > > COULEUR MIRC ET SMILEY POUR RICHTEXTBOX VB.NET 2005
COULEUR MIRC ET SMILEY POUR RICHTEXTBOX VB.NET 2005
Information sur la source
Description
toutes les couleur mirc et et exemple de smiley a vous d'en rajouter a votre guise :) a mettre dans un module et a appeller addmsg(nom de la form ou se trouve a richtextbox , le texte a afficher , le pseudo de la personne qui a envoiye le message) voir capture je posterais bientot le script entier
Source
- Imports System.Drawing.Color
- Imports System.Text
- Imports System.Text.RegularExpressions
- Imports System.Runtime.InteropServices
- Imports System
- Imports System.Threading
- Module couleur
-
- Const WM_VSCROLL As Integer = &H115
- Const SB_BOTTOM As Integer = 7
- Declare Function SendMessage Lib "user32.dll" Alias "SendMessageW" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
-
- Public Function addmsg(ByVal salon As String, ByVal msg23 As String, Optional ByVal nickmessage As String = "") As Boolean
- Dim gras As Boolean = False
- Dim Couleur As String = "1"
- Dim CouleurArr As String = "0"
- Dim MyChar As String
- Dim MyChar2 As String
- Dim Co As String = ""
- Dim cntrl As Control
- Dim Rich As RichTextBox = Nothing
- Dim N_Form As Form
-
- Dim souligne As Boolean = False
- Dim arr As Boolean = False
- Dim carr As String = "0"
- For Each N_Form In Principale.MdiChildren
- If N_Form.Name = salon Then
- For Each cntrl In N_Form.Controls
- If TypeOf cntrl Is RichTextBox Then
- Rich = cntrl
- Exit For
- End If
- Next
- End If
- Next
- Try
- If nickmessage <> "" Then
- With Rich
- .SelectionStart = Len(Rich.Text)
- .SelectionProtected = False
- .SelectionStart = Len(Rich.Text) + 1
- .SelectionBackColor = White
- .SelectionColor = coul(Couleur)
- .SelectedText = vbNewLine & TimeOfDay & " : << " & nickmessage & " >> "
- .SelectionProtected = True
- End With
- Else
- With Rich
- .SelectionStart = Len(Rich.Text)
- .SelectionProtected = False
- .SelectionStart = Len(Rich.Text) + 1
- .SelectionColor = coul(Couleur)
- .SelectionBackColor = White
- .SelectedText = vbNewLine & TimeOfDay
- .SelectionProtected = True
- End With
- End If
-
-
-
- 'les smiley
- Dim longueur As Integer = Len(msg23)
- For X As Integer = 1 To longueur
- Dim debug As Integer = X
-
- MyChar2 = Mid(msg23, X, 2)
- Select Case MyChar2
- Case ":|"
- Clipboard.SetDataObject(New Bitmap(Application.StartupPath & "\Smiley\blaze.png"))
- Rich.SelectionProtected = False
- Rich.SelectionStart = Len(Rich.Text) - 1
- Rich.SelectedText = ""
- Rich.Paste()
- Rich.SelectionProtected = True
- Dim ms1 As String = Mid(msg23, 1, X - 1)
- Dim ms2 As String = Mid(msg23, X + 2, Len(msg23))
- msg23 = ms1 & ms2
-
- Case ":)"
- Clipboard.SetDataObject(New Bitmap(Application.StartupPath & "\Smiley\heureux.jpg"))
- Rich.SelectionProtected = False
- Rich.SelectionStart = Len(Rich.Text) - 1
- Rich.SelectedText = ""
- Rich.Paste()
- Rich.SelectionProtected = True
- Dim ms1 As String = Mid(msg23, 1, X - 1)
- Dim ms2 As String = Mid(msg23, X + 2, Len(msg23))
- msg23 = ms1 & ms2
-
-
- Case LCase("? ")
- Clipboard.SetDataObject(New Bitmap(Application.StartupPath & "\Smiley\ question.gif()"))
- Rich.SelectionProtected = False
- Rich.SelectionStart = Len(Rich.Text) - 1
- Rich.SelectedText = ""
- Rich.Paste()
- Rich.SelectionProtected = True
- Dim ms1 As String = Mid(msg23, 1, X - 1)
- Dim ms2 As String = Mid(msg23, X + 2, Len(msg23))
- msg23 = ms1 & ms2
-
- End Select
-
-
- 'traiment de chaque caractere
- MyChar = Mid(msg23, X, 1)
- Select Case MyChar
-
- Case Chr(3)
- Do While IsNumeric(Mid(msg23, X, 1)) Or Mid(msg23, X, 1) = "," Or Mid(msg23, X, 1) = Chr(3)
- Co = Co & Mid(msg23, X, 1)
- X = X + 1
- Loop
- Couleur = Replace(Co, Chr(3), "")
- If InStr(Couleur, ",") <> 0 Then
- CouleurArr = Mid(Couleur, InStr(Couleur, ",") + 1, Len(Couleur))
- Couleur = Mid(Couleur, 1, InStr(Couleur, ",", CompareMethod.Text) - 1)
- End If
- If Len(Couleur) > 2 Then
- Couleur = Mid(Couleur, 1, 2)
- X = X - 1
- End If
-
-
- If Len(CouleurArr) > 2 Then
- CouleurArr = Mid(CouleurArr, 1, 2)
- X = X - 1
- End If
- X = X - 1
- Co = ""
-
- Case Chr(2)
- gras = IIf(gras = False, True, False)
-
- Case Else
- If MyChar = Chr(1) Or MyChar = Chr(15) Or MyChar = Chr(31) Or MyChar = Chr(3) Or MyChar = Chr(2) Then MyChar = ""
- If Couleur = "" Then Couleur = "1"
- If CType(Couleur, Integer) > 15 Then Couleur = "1"
- If CouleurArr = "" Then CouleurArr = "0"
- If CType(CouleurArr, Integer) > 15 Then CouleurArr = "0"
-
- If gras = True Then
- Dim bfont As New Font(Rich.Font, FontStyle.Bold)
- With Rich
- .SelectionProtected = False
- .SelectionFont = bfont
- .SelectionStart = Len(Rich.Text) + 1
- .SelectionBackColor = coul(CouleurArr)
- .SelectionColor = coul(Couleur)
- .SelectedText = MyChar
- .SelectionProtected = True
- End With
- Else
- Dim bfont As New Font(Rich.Font, FontStyle.Regular)
- With Rich
- .SelectionProtected = False
- .SelectionFont = bfont
- .SelectionStart = Len(Rich.Text) + 1
- .SelectionBackColor = coul(CouleurArr)
- .SelectionColor = coul(Couleur)
- .SelectedText = MyChar
- .SelectionProtected = True
- End With
- End If
-
- End Select
- Next
- Dim Tfont As New Font(Rich.Font, FontStyle.Regular)
- With Rich
- .SelectionProtected = False
- .SelectionFont = Tfont
- .SelectionStart = Len(Rich.Text) + 1
- .SelectionBackColor = coul("0")
- .SelectionColor = coul("1")
- .SelectedText = ""
- .SelectionProtected = True
- End With
- SendMessage(Rich.Handle, WM_VSCROLL, SB_BOTTOM, 0)
-
- Catch ex As Exception
-
- Dim sfont As New Font(Rich.Font, FontStyle.Regular)
- With Rich
- .SelectionProtected = False
- .SelectionFont = sfont
- .SelectionStart = Len(Rich.Text) + 1
- .SelectionBackColor = coul("0")
- .SelectionColor = coul("1")
- .SelectedText = ""
- .SelectionProtected = True
- End With
- SendMessage(Rich.Handle, WM_VSCROLL, SB_BOTTOM, 0)
- End Try
- End Function
-
- Private Function coul(ByVal num As Integer) As Color
- Select Case num
- Case 0 : coul = Color.FromArgb(255, 255, 255)
- Case 1 : coul = Color.FromArgb(0, 0, 0)
- Case 2 : coul = Color.FromArgb(0, 0, 127)
- Case 3 : coul = Color.FromArgb(0, 127, 0)
- Case 4 : coul = Color.FromArgb(255, 0, 0)
- Case 5 : coul = Color.FromArgb(127, 0, 0)
- Case 6 : coul = Color.FromArgb(127, 0, 127)
- Case 7 : coul = Color.FromArgb(255, 127, 0)
- Case 8 : coul = Color.FromArgb(255, 255, 0)
- Case 9 : coul = Color.FromArgb(0, 255, 0)
- Case 10 : coul = Color.FromArgb(63, 127, 127)
- Case 11 : coul = Color.FromArgb(0, 255, 255)
- Case 12 : coul = Color.FromArgb(0, 0, 255)
- Case 13 : coul = Color.FromArgb(255, 0, 255)
- Case 14 : coul = Color.FromArgb(127, 127, 127)
- Case 15 : coul = Color.FromArgb(191, 191, 191)
- Case Else : coul = Color.FromArgb(0, 0, 0)
- End Select
-
- End Function
Imports System.Drawing.Color
Imports System.Text
Imports System.Text.RegularExpressions
Imports System.Runtime.InteropServices
Imports System
Imports System.Threading
Module couleur
Const WM_VSCROLL As Integer = &H115
Const SB_BOTTOM As Integer = 7
Declare Function SendMessage Lib "user32.dll" Alias "SendMessageW" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
Public Function addmsg(ByVal salon As String, ByVal msg23 As String, Optional ByVal nickmessage As String = "") As Boolean
Dim gras As Boolean = False
Dim Couleur As String = "1"
Dim CouleurArr As String = "0"
Dim MyChar As String
Dim MyChar2 As String
Dim Co As String = ""
Dim cntrl As Control
Dim Rich As RichTextBox = Nothing
Dim N_Form As Form
Dim souligne As Boolean = False
Dim arr As Boolean = False
Dim carr As String = "0"
For Each N_Form In Principale.MdiChildren
If N_Form.Name = salon Then
For Each cntrl In N_Form.Controls
If TypeOf cntrl Is RichTextBox Then
Rich = cntrl
Exit For
End If
Next
End If
Next
Try
If nickmessage <> "" Then
With Rich
.SelectionStart = Len(Rich.Text)
.SelectionProtected = False
.SelectionStart = Len(Rich.Text) + 1
.SelectionBackColor = White
.SelectionColor = coul(Couleur)
.SelectedText = vbNewLine & TimeOfDay & " : << " & nickmessage & " >> "
.SelectionProtected = True
End With
Else
With Rich
.SelectionStart = Len(Rich.Text)
.SelectionProtected = False
.SelectionStart = Len(Rich.Text) + 1
.SelectionColor = coul(Couleur)
.SelectionBackColor = White
.SelectedText = vbNewLine & TimeOfDay
.SelectionProtected = True
End With
End If
'les smiley
Dim longueur As Integer = Len(msg23)
For X As Integer = 1 To longueur
Dim debug As Integer = X
MyChar2 = Mid(msg23, X, 2)
Select Case MyChar2
Case ":|"
Clipboard.SetDataObject(New Bitmap(Application.StartupPath & "\Smiley\blaze.png"))
Rich.SelectionProtected = False
Rich.SelectionStart = Len(Rich.Text) - 1
Rich.SelectedText = ""
Rich.Paste()
Rich.SelectionProtected = True
Dim ms1 As String = Mid(msg23, 1, X - 1)
Dim ms2 As String = Mid(msg23, X + 2, Len(msg23))
msg23 = ms1 & ms2
Case ":)"
Clipboard.SetDataObject(New Bitmap(Application.StartupPath & "\Smiley\heureux.jpg"))
Rich.SelectionProtected = False
Rich.SelectionStart = Len(Rich.Text) - 1
Rich.SelectedText = ""
Rich.Paste()
Rich.SelectionProtected = True
Dim ms1 As String = Mid(msg23, 1, X - 1)
Dim ms2 As String = Mid(msg23, X + 2, Len(msg23))
msg23 = ms1 & ms2
Case LCase("? ")
Clipboard.SetDataObject(New Bitmap(Application.StartupPath & "\Smiley\ question.gif()"))
Rich.SelectionProtected = False
Rich.SelectionStart = Len(Rich.Text) - 1
Rich.SelectedText = ""
Rich.Paste()
Rich.SelectionProtected = True
Dim ms1 As String = Mid(msg23, 1, X - 1)
Dim ms2 As String = Mid(msg23, X + 2, Len(msg23))
msg23 = ms1 & ms2
End Select
'traiment de chaque caractere
MyChar = Mid(msg23, X, 1)
Select Case MyChar
Case Chr(3)
Do While IsNumeric(Mid(msg23, X, 1)) Or Mid(msg23, X, 1) = "," Or Mid(msg23, X, 1) = Chr(3)
Co = Co & Mid(msg23, X, 1)
X = X + 1
Loop
Couleur = Replace(Co, Chr(3), "")
If InStr(Couleur, ",") <> 0 Then
CouleurArr = Mid(Couleur, InStr(Couleur, ",") + 1, Len(Couleur))
Couleur = Mid(Couleur, 1, InStr(Couleur, ",", CompareMethod.Text) - 1)
End If
If Len(Couleur) > 2 Then
Couleur = Mid(Couleur, 1, 2)
X = X - 1
End If
If Len(CouleurArr) > 2 Then
CouleurArr = Mid(CouleurArr, 1, 2)
X = X - 1
End If
X = X - 1
Co = ""
Case Chr(2)
gras = IIf(gras = False, True, False)
Case Else
If MyChar = Chr(1) Or MyChar = Chr(15) Or MyChar = Chr(31) Or MyChar = Chr(3) Or MyChar = Chr(2) Then MyChar = ""
If Couleur = "" Then Couleur = "1"
If CType(Couleur, Integer) > 15 Then Couleur = "1"
If CouleurArr = "" Then CouleurArr = "0"
If CType(CouleurArr, Integer) > 15 Then CouleurArr = "0"
If gras = True Then
Dim bfont As New Font(Rich.Font, FontStyle.Bold)
With Rich
.SelectionProtected = False
.SelectionFont = bfont
.SelectionStart = Len(Rich.Text) + 1
.SelectionBackColor = coul(CouleurArr)
.SelectionColor = coul(Couleur)
.SelectedText = MyChar
.SelectionProtected = True
End With
Else
Dim bfont As New Font(Rich.Font, FontStyle.Regular)
With Rich
.SelectionProtected = False
.SelectionFont = bfont
.SelectionStart = Len(Rich.Text) + 1
.SelectionBackColor = coul(CouleurArr)
.SelectionColor = coul(Couleur)
.SelectedText = MyChar
.SelectionProtected = True
End With
End If
End Select
Next
Dim Tfont As New Font(Rich.Font, FontStyle.Regular)
With Rich
.SelectionProtected = False
.SelectionFont = Tfont
.SelectionStart = Len(Rich.Text) + 1
.SelectionBackColor = coul("0")
.SelectionColor = coul("1")
.SelectedText = ""
.SelectionProtected = True
End With
SendMessage(Rich.Handle, WM_VSCROLL, SB_BOTTOM, 0)
Catch ex As Exception
Dim sfont As New Font(Rich.Font, FontStyle.Regular)
With Rich
.SelectionProtected = False
.SelectionFont = sfont
.SelectionStart = Len(Rich.Text) + 1
.SelectionBackColor = coul("0")
.SelectionColor = coul("1")
.SelectedText = ""
.SelectionProtected = True
End With
SendMessage(Rich.Handle, WM_VSCROLL, SB_BOTTOM, 0)
End Try
End Function
Private Function coul(ByVal num As Integer) As Color
Select Case num
Case 0 : coul = Color.FromArgb(255, 255, 255)
Case 1 : coul = Color.FromArgb(0, 0, 0)
Case 2 : coul = Color.FromArgb(0, 0, 127)
Case 3 : coul = Color.FromArgb(0, 127, 0)
Case 4 : coul = Color.FromArgb(255, 0, 0)
Case 5 : coul = Color.FromArgb(127, 0, 0)
Case 6 : coul = Color.FromArgb(127, 0, 127)
Case 7 : coul = Color.FromArgb(255, 127, 0)
Case 8 : coul = Color.FromArgb(255, 255, 0)
Case 9 : coul = Color.FromArgb(0, 255, 0)
Case 10 : coul = Color.FromArgb(63, 127, 127)
Case 11 : coul = Color.FromArgb(0, 255, 255)
Case 12 : coul = Color.FromArgb(0, 0, 255)
Case 13 : coul = Color.FromArgb(255, 0, 255)
Case 14 : coul = Color.FromArgb(127, 127, 127)
Case 15 : coul = Color.FromArgb(191, 191, 191)
Case Else : coul = Color.FromArgb(0, 0, 0)
End Select
End Function
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
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
|