Solved

how do i send color format and bold and size

Posted on 2004-08-11
8
295 Views
Last Modified: 2008-01-09
VB:
--------------------------------------------------------------------------------
Option Explicit

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
   
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
    (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _
    ByVal lpsz2 As String) As Long
   
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
    (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
   
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" _
    (ByVal hwnd As Long) As Long
   
Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
   
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Private Const WM_KEYDOWN = &H100
Private Const WM_SETTEXT = &HC

Private lhWnd(1) As Long
Private palLong As Long
Private palGroupName As String
Private palStatusBar As Long
Private palStatusText As String
Private palLastJoined As String
Private palTextBox As Long
Private isRunning As Boolean

Private Sub Form_Load()

    With Timer1
        .Enabled = False
        .Interval = 1
    End With
   
    Command1.Caption = "Start Greeter"
    Text1.Text = "***-Welcome  %sn-***"
    isRunning = False
   
     With RichTextBox1
        .SelBold = True
        .SelColor = vbRed
           .SelFontSize = 12
            End With
           RichTextBox1.SelText = Text1.Text

End Sub

Private Sub Command1_Click()

    If isRunning = True Then
   
        Command1.Caption = "Start Greeter"
             isRunning = False
                Timer1 = False
    Else
   
        Command1.Caption = "Stop Greeter"
             isRunning = True
                Timer1 = True
    End If

End Sub

Private Sub Timer1_Timer()

    Dim I As Integer
    Dim NickName As String
    Dim GreetMSG As String
     
       
    lhWnd(0) = FindWindow("#32770", vbNullString) 'Find Group Window
    lhWnd(1) = FindWindowEx(lhWnd(0), 0&, "#32770", vbNullString) 'Find Group Child Win
    palStatusBar = FindWindowEx(lhWnd(0), 0&, "msctls_statusbar32", vbNullString)
    palGroupName = String(GetWindowTextLength(lhWnd(0)) + 1, Chr$(0))
    GetWindowText lhWnd(0), palGroupName, Len(palGroupName)
    palTextBox = FindWindowEx(lhWnd(1), 0&, "richedit20a", vbNullString)
    palTextBox = FindWindowEx(lhWnd(1), palTextBox, "richedit20a", vbNullString)
   
    If InStr(1, LCase(palGroupName), LCase(" GROUP")) Then 'Verify Group
 
        If isRunning = True Then
       
            palLong = SendMessageLong(palStatusBar, WM_GETTEXTLENGTH, 0&, 0&) 'Get Text Length
            palStatusText = String(palLong + 1, " ") 'Create Buffer
            Call SendMessageByString(palStatusBar, WM_GETTEXT, palLong + 1, palStatusText) 'Get Text
            palStatusText = Left(palStatusText, palLong) 'Remove Blanks
   
            I = InStr(1, palStatusText, "joined") - 13 'Check for Join Messages
           
            If I < 0 Then Exit Sub 'If no join message then GET OUT!
           
            NickName = Mid(palStatusText, 8, I) 'Get the Nickname
             On Error Resume Next
AppActivate "Group - Voice Conference"
On Error Resume Next
            If palLastJoined <> NickName Then 'Check if not joined already
                palLastJoined = NickName 'Remember the last Nickname joined
               
                GreetMSG = Replace(Text1.Text, "%sn", NickName) 'Replace %sn with The NickName
               On Error Resume Next
AppActivate "Group - Voice Conference"
On Error Resume Next
                Call SendMessageByString(palTextBox, WM_SETTEXT, 0&, GreetMSG) 'Set Text in Box
                Call SendMessageLong(palTextBox, WM_KEYDOWN, 13, 0&) 'Press Enter
               
            End If
        End If
    End If
End Sub
its an autogreeter for a chat called paltalk
0
Comment
Question by:torrment53
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
8 Comments
 
LVL 3

Expert Comment

by:Belthazor
ID: 11784460
hi,
i dont think this is gonna work at all: The chat client has its own 'bold' and 'color' handling, and you cant format your text like the program does. If there are any buttons to do this, you could try pressing them with keydown messages.

Belthazor
0
 
LVL 1

Author Comment

by:torrment53
ID: 11786785
i know it can be done other ppl are doing it only thing is when its in a string its harder when i us richtextbox i can use formatting but when the text is sent from a string im not sure how to do it
0
 
LVL 1

Author Comment

by:torrment53
ID: 11963912
i figured it out works good now
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 1

Author Comment

by:torrment53
ID: 11964008
commondialogue control richtextbox and picture box with command buttons in it heres the code all togeather
vb:
Option Explicit

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
   
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
    (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _
    ByVal lpsz2 As String) As Long
   
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
    (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
   
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" _
    (ByVal hwnd As Long) As Long
   
Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
   
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const WM_GETTEXT = &HD
Private Const WM_GETTEXTLENGTH = &HE
Private Const WM_KEYDOWN = &H100
Private Const WM_SETTEXT = &HC

Private lhWnd(1) As Long
Private palLong As Long
Private palGroupName As String
Private palStatusBar As Long
Private palStatusText As String
Private palLastJoined As String
Private palTextBox As Long
Private isRunning As Boolean

Private Sub cmda1_Click()
REB1.SelFontSize = 8
End Sub

Private Sub cmda2_Click()
REB1.SelFontSize = 10
End Sub

Private Sub cmda3_Click()
REB1.SelFontSize = 12
End Sub

Private Sub cmdb_Click()
If REB1.SelBold = True Then
    REB1.SelBold = False
Else
    REB1.SelBold = True
End If
End Sub

Private Sub cmdcolor_Click()
cd1.ShowColor
REB1.SelColor = cd1.Color
End Sub

Private Sub cmdi_Click()
If REB1.SelItalic = True Then
    REB1.SelItalic = False
Else
    REB1.SelItalic = True
End If
End Sub

Private Sub cmdsnd_Click()
    Dim I As Integer
    Dim NickName As String
    Dim GreetMSG As String
     
       
    lhWnd(0) = FindWindow("#32770", vbNullString) 'Find Group Window
    lhWnd(1) = FindWindowEx(lhWnd(0), 0&, "#32770", vbNullString) 'Find Group Child Win
    palStatusBar = FindWindowEx(lhWnd(0), 0&, "msctls_statusbar32", vbNullString)
    palGroupName = String(GetWindowTextLength(lhWnd(0)) + 1, Chr$(0))
    GetWindowText lhWnd(0), palGroupName, Len(palGroupName)
    palTextBox = FindWindowEx(lhWnd(1), 0&, "richedit20a", vbNullString)
    palTextBox = FindWindowEx(lhWnd(1), palTextBox, "richedit20a", vbNullString)
    If InStr(1, LCase(palGroupName), LCase(" GROUP")) Then 'Verify Group
        NickName = " Python"
        GreetMSG = REB1.TextRTF
        Call SendMessageByString(palTextBox, WM_SETTEXT, 0&, GreetMSG) 'Set Text in Box
        Call SendMessageLong(palTextBox, WM_KEYDOWN, 13, 0&) 'Press Enter
    End If
End Sub



Private Sub cmdu_Click()
If REB1.SelUnderline = True Then
    REB1.SelUnderline = False
Else
    REB1.SelUnderline = True
End If
End Sub


Private Sub Form_Load()

    With Timer1
        .Enabled = False
        .Interval = 1
    End With
   
    Command1.Caption = "Start Greeter"
    REB1.Text = "***-Welcome  %sn-***"
    isRunning = False
   
           

End Sub

Private Sub Command1_Click()

    If isRunning = True Then
   
        Command1.Caption = "Start Greeter"
             isRunning = False
                Timer1 = False
    Else
   
        Command1.Caption = "Stop Greeter"
             isRunning = True
                Timer1 = True
    End If

End Sub



Private Sub REB1_Change()

End Sub

Private Sub Timer1_Timer()

    Dim I As Integer
    Dim NickName As String
    Dim GreetMSG As String
     
       
    lhWnd(0) = FindWindow("#32770", vbNullString) 'Find Group Window
    lhWnd(1) = FindWindowEx(lhWnd(0), 0&, "#32770", vbNullString) 'Find Group Child Win
    palStatusBar = FindWindowEx(lhWnd(0), 0&, "msctls_statusbar32", vbNullString)
    palGroupName = String(GetWindowTextLength(lhWnd(0)) + 1, Chr$(0))
    GetWindowText lhWnd(0), palGroupName, Len(palGroupName)
    palTextBox = FindWindowEx(lhWnd(1), 0&, "richedit20a", vbNullString)
    palTextBox = FindWindowEx(lhWnd(1), palTextBox, "richedit20a", vbNullString)
   
    If InStr(1, LCase(palGroupName), LCase(" GROUP")) Then 'Verify Group
 
        If isRunning = True Then
       
            palLong = SendMessageLong(palStatusBar, WM_GETTEXTLENGTH, 0&, 0&) 'Get Text Length
            palStatusText = String(palLong + 1, " ") 'Create Buffer
            Call SendMessageByString(palStatusBar, WM_GETTEXT, palLong + 1, palStatusText) 'Get Text
            palStatusText = Left(palStatusText, palLong) 'Remove Blanks
   
            I = InStr(1, palStatusText, "joined") - 13 'Check for Join Messages
           
            If I < 0 Then Exit Sub 'If no join message then GET OUT!
           
            NickName = Mid(palStatusText, 8, I) 'Get the Nickname
         
            If palLastJoined <> NickName Then 'Check if not joined already
                palLastJoined = NickName 'Remember the last Nickname joined
               
                GreetMSG = Replace(REB1.TextRTF, "%sn", NickName) 'Replace %sn with The NickName
               
                Call SendMessageByString(palTextBox, WM_SETTEXT, 0&, GreetMSG) 'Set Text in Box
                Call SendMessageLong(palTextBox, WM_KEYDOWN, 13, 0&) 'Press Enter
               
            End If
        End If
    End If
End Sub


0
 
LVL 1

Author Comment

by:torrment53
ID: 12396506
plz close ? i gave my own answer and sorry im not positive about how to go about ending a ? thanks
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12689633
PAQed with points refunded (400)

modulo
Community Support Moderator
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question