|
is there a way to have atleast 2 deferent colors of text in one textbox?
this is for a chat server/client project and I want deferent colors for messages coming from the server ect...
thanks for the help
|
|
|
|
|
use RichTextBox and its SelectionColor property.
|
|
|
|
|
The TextBox doesn't support this. You'd have to come up with your own version of a Textbox control to do this. Or, like the other poster said, use RichTextBox instead. It supports the functionality you're looking for.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
this is what i came up with but it doesent work
<br />
Friend Sub DisplayText(ByVal text As String)<br />
Try<br />
<br />
frmB.txtpbchat.SelectionColor = System.Drawing.Color.Navy<br />
frmB.txtpbchat.Text = text & Environment.NewLine & frmB.txtpbchat.Text<br />
<br />
Catch ex As Exception<br />
MessageBox.Show(ex.ToString)<br />
<br />
End Try<br />
End Sub<br />
|
|
|
|
|
fo0lish wrote:
frmB.txtpbchat.Text = text & Environment.NewLine & frmB.txtpbchat.Text
First, don't use string concatentation. Use the .AppendText() method of the RichTextBox. Second, position the insertion point to the end of the text before you call .AppendText() . If the insertion point is anywhere else in the text, the color won't be applied correctly.
This is an example:
RichTextBox1.SelectionStart = RichTextBox1.TextLength
RichTextBox1.SelectionColor = System.Drawing.Color.Blue
RichTextBox1.AppendText(text & Environment.NewLine & frmB.txtpbchat.Text)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I use API funcion -- StretchBlt -- to capture screen in VB 6.0 and succeed.
When I copy the code into VB.net, capture failed, nothing happened.
Here is some of the code:
Picture1.Scale(1.5F)
w = Picture1.Width
h = Picture1.Height
hdcScreen = GetDC(0)
r = StretchBlt(Picture1.Handle, 0, 0, w, h, hdcScreen, xSrc, ySrc, wSrc, hSrc, SRCCOPY)
Please give me some samples?
Thanks!
|
|
|
|
|
First, why are you using StretchBlt instead of BitBlt? Are you recaling the image for magnification purposes?
What does your code look like in VB.NET? We need to see the Declaration you used to import the StretchBlt function. Also, what are the variables you used in this code snippet defined as? 99.999% of problems calling API functions are caused by having an incorrect Declare statement and passing parameters incorrectly.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I do not know how to use BitBlt, only know StretchBlt function.
Here is the declaration:
Private Declare Ansi Function StretchBlt Lib "gdi32" (ByVal hDC 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
|
|
|
|
|
I am afraid the code is too long.
Sub CaptureScreen(ByVal Picture1 As PictureBox, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal wSrc As Integer, ByVal hSrc As Integer)
Dim w As Long
Dim h As Long
Dim hdcScreen As Long
Dim r As Long
Dim hMemDC As Long
'Dim bmp As Bitmap
Try
'bmp = New Bitmap(wSrc, hSrc)
'Picture1.Scale(1.5F)
w = Picture1.Width
h = Picture1.Height
hdcScreen = GetDC(0)
'hMemDC = CreateCompatibleDC(bmp.GetHbitmap)
hMemDC = GetDC(Picture1.Handle)
r = StretchBlt(hMemDC, 0, 0, w, h, hdcScreen, xSrc, ySrc, wSrc, hSrc, SRCCOPY)
Trace.WriteLine("Picture1.Handle=" + Picture1.Handle.ToString + " hMemDC=" + hMemDC.ToString + ",w=" + w.ToString + ",h=" + h.ToString)
Trace.WriteLine("hdcScreen=" + hdcScreen.ToString)
Trace.WriteLine("xSrc=" + xSrc.ToString + ",ySrc=" + ySrc.ToString + ",wSrc=" + wSrc.ToString + ",hSrc=" + hSrc.ToString)
Trace.WriteLine("r=" + r.ToString + vbCrLf)
Catch ex As Exception
MsgBox(ex.ToString, vbQuestion, "CaptureScreen")
End Try
End Sub
|
|
|
|
|
First, I didn't appreciate the "1" vote. All I asked you was why you were using StretchBlt and to see the RELEVANT parts of your code and I told you which parts those were.
Second, BitBlt is no different than StrechBlt. Actually, it's a bit simpler to use since there aren't as many parameters.
Third, the SDK documenation on both StretchBlt and BitBlt describe their parameters as HDC, which is just a 32-bit value that should be passed as an IntPtr, and int's, which in VB.NET are Integer types, not Long types.
The corrected Declare statement should look like this:
Private Declare Auto Function StretchBlt Lib "gdi32" ( _
hDC As IntPtr, x As Integer, y As Integer, _
nWidth As Integer, nHeight As Integer, _
hSrcDC As IntPtr, xSrc As Integer, ySrc As Integer, _
nSrcWidth As Integer, nSrcHeight As Integer, dwRop As Integer) _
As Integer
BTW: Parameters are passed ByVal by default. You don't need to specify it on every parameter.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i want to synchronize two databases having the same schema at different locations. any body help me.
thanks
|
|
|
|
|
Access, mySQL, SQL Server, Oracle, ... ? Which database type?
Oracle and SQL Server has their own replication services that can do this for you. The others, you'll have to write the replicator yourself.
If your going to write it yourself, are your records timestamped? If not, you'll find it VERY difficult to know which records are more recent that the ones in the other database. You'll actually have to create another table in the database to hold the replication tracking information for each record.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i want to synchronize two databases having the same schema at different locations. any body help me.
Aman
|
|
|
|
|
hi All
I want to send print to the printer port in vb.net character by character (one character at a time ), not the whole file.
the purpose is like :
for i = 1 to 15
next
value of i shloud be transferred to the printer port at each execution of the FOR LOOP:
the value of i of the for loop that is executed 15 times should be printed.
print should be in this format:
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15 (means value of i)
any body help me please. i need it urgently.
thanks in advance.
Bye
|
|
|
|
|
|
I have been killing myself with this and getting nowhere.
I have an Access DB with a table for clients, among others. I am trying to use a stored procedure (query) to insert a new client. Here is my code for this part:
Public Sub addCustomer()
'Grab the contents of each field
Dim CustNumVal As String = Me.tbxCustNum.Text
Dim CustNameVal As String = Me.cbxCustName.Text
Dim CustContactVal As String = Me.tbxCustContact.Text
Dim CustAdd1Val As String = Me.tbxCustAdd1.Text
Dim CustAdd2Val As String = Me.tbxCustAdd2.Text
Dim CustCityVal As String = Me.tbxCustCity.Text
Dim CustStateVal As String = Me.tbxCustState.Text
Dim CustZipVal As String = Me.tbxCustZip.Text
Dim CustPhoneVal As String = Me.tbxCustPhone.Text
Dim CustFaxVal As String = Me.tbxcustFax.Text
Dim CustEmailVal As String = Me.tbxCustEmail.Text
'Create Command Params
objCommand = New OleDb.OleDbCommand
objCommand.Connection = objConnection
objCommand.CommandType = CommandType.StoredProcedure
objCommand.Parameters.Add("@CustNum", OleDb.OleDbType.Integer, 50, CustNumVal)
objCommand.Parameters.Add("@CustName", OleDb.OleDbType.Char, 50, CustNameVal)
objCommand.Parameters.Add("@CustContact", OleDb.OleDbType.Char, 50, CustContactVal)
objCommand.Parameters.Add("@CustAdd1", OleDb.OleDbType.Char, 50, CustAdd1Val)
objCommand.Parameters.Add("@CustAdd2", OleDb.OleDbType.Char, 50, CustAdd2Val)
objCommand.Parameters.Add("@CustCity", OleDb.OleDbType.Char, 2, CustCityVal)
objCommand.Parameters.Add("@CustState", OleDb.OleDbType.Char, 60, CustStateVal)
objCommand.Parameters.Add("@CustZip", OleDb.OleDbType.Integer, 50, CustZipVal)
objCommand.Parameters.Add("@CustPhone", OleDb.OleDbType.Char, 50, CustPhoneVal)
objCommand.Parameters.Add("@CustFax", OleDb.OleDbType.Char, 50, CustFaxVal)
objCommand.Parameters.Add("@CustEmail", OleDb.OleDbType.VarChar, 50, CustEmailVal)
objCommand.CommandText = "EXECUTE usp_AddCustomer"
objConnection.Open()
objCommand.ExecuteNonQuery()
objConnection.Close()
'Change the style of the drop down list
Me.cbxCustName.DropDownStyle = ComboBoxStyle.DropDownList
'Revert the controls back to read only
Me.tbxCustAdd1.ReadOnly = True
Me.tbxCustAdd2.ReadOnly = True
Me.tbxCustCity.ReadOnly = True
Me.tbxCustContact.ReadOnly = True
Me.tbxCustEmail.ReadOnly = True
Me.tbxCustNum.ReadOnly = True
Me.tbxCustPhone.ReadOnly = True
Me.tbxcustFax.ReadOnly = True
Me.tbxCustState.ReadOnly = True
Me.tbxCustZip.ReadOnly = True
'Hide the buttons
Me.btnAction.Visible = False
Me.btnCancelNew.Visible = False
'Clear and fill the Data Set
DsCustInfo.Clear()
daCustInfo.Fill(DsCustInfo)
'Set the record number to the new record
Dim newRecID As Integer
newRecID = Me.BindingContext(DsCustInfo, "custinfo").Count
Me.BindingContext(DsCustInfo, "custinfo").Position = newRecID
'Cleanup
CustNumVal = Nothing
CustNameVal = Nothing
CustContactVal = Nothing
CustAdd1Val = Nothing
CustAdd2Val = Nothing
CustCityVal = Nothing
CustStateVal = Nothing
CustZipVal = Nothing
CustPhoneVal = Nothing
CustFaxVal = Nothing
CustEmailVal = Nothing
objConnection.Close()
End Sub
The variables, strConnectionString, objConnection and objCommand are delcared at the top of the form as global variables as such:
Inherits System.Windows.Forms.Form
Public strConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\user\My Documents\Visual Studio Projects\" & _
"OnBase Configurator\db1.mdb;"
Public objConnection As New OleDb.OleDbConnection(strConnectionString)
Public objCommand As New OleDb.OleDbCommand
No matter what I do, I keep getting the following error:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
Someone please help me or shoot me. Either one is fine right now.
Jay Davis
|
|
|
|
|
just use
objCommand.CommandText = "usp_AddCustomer"
|
|
|
|
|
I tried that to no avail.
I also put the execute in a try...catch block and got a more precise error.
An unhandled exception of type 'System.ArgumentException' occurred in microsoft.visualbasic.dll
Additional information: Argument 'Prompt' cannot be converted to type 'String'.
Is this a dbtype mismatch?
Jay Davis
|
|
|
|
|
More Info....
Here is the query in Access
It is named usp_AddCustomer
INSERT INTO CustInfo ( CustNum, CustName, CustContact, CustAdd1, CustAdd2, CustCity, CustState, CustZip, CustPhone, CustFax, CustEmail )
SELECT [@CustNum] AS Expr1, [@CustName] AS Expr2, [@CustContact] AS Expr3, [@CustAdd1] AS Expr4, [@CustAdd2] AS Expr5, [@CustCity] AS Expr6, [@CustState] AS Expr7, [@CustZip] AS Expr8, [@CustPhone] AS Expr9, [@CustFax] AS Expr10, [@CustEmail] AS Expr11;
Jay Davis
|
|
|
|
|
More Info....
I have modified the structure as follows
Try
objCommand = New OleDb.OleDbCommand
objCommand.Connection = objConnection
objCommand.CommandType = CommandType.StoredProcedure
objCommand.Parameters.Add("@CustNum", OleDb.OleDbType.Variant, 50, "99999")
objCommand.Parameters.Add("@CustName", OleDb.OleDbType.Char, 50, "Test1")
objCommand.Parameters.Add("@CustContact", OleDb.OleDbType.Char, 50, "Test User")
objCommand.Parameters.Add("@CustAdd1", OleDb.OleDbType.Char, 50, "123 Your Street")
objCommand.Parameters.Add("@CustAdd2", OleDb.OleDbType.Char, 50, "Apt C")
objCommand.Parameters.Add("@CustCity", OleDb.OleDbType.Char, 50, "Your City")
objCommand.Parameters.Add("@CustState", OleDb.OleDbType.Char, 2, "OH")
objCommand.Parameters.Add("@CustZip", OleDb.OleDbType.Char, 50, "99999")
objCommand.Parameters.Add("@CustPhone", OleDb.OleDbType.Char, 50, "1234567890")
objCommand.Parameters.Add("@CustFax", OleDb.OleDbType.Char, 50, "1234567891")
objCommand.Parameters.Add("@CustEmail", OleDb.OleDbType.VarChar, 50, "test@test.com")
objCommand.CommandText = "usp_AddCustomer"
objConnection.Open()
objCommand.ExecuteNonQuery()
Catch OleDbExceptionErr As OleDbException
MsgBox(OleDbExceptionErr.ToString)
End Try
I am now just trying to do hard coded strings, and when I run it with the try...catch block, I get teh following error:
System.Data.OleDb.OleDbException: Parameter [@CustNum] has no default value.
Jay Davis
|
|
|
|
|
Just to add my 2 cents...
First, forget everything you know about real SQL. Access/Jet doesn't support a lot of it.
Access/Jet doesn't support named parameters. You CAN name them for a bit of clarity when you read the SQL statement, but the names are not used. There parameters you add must be supplied in the same order that they appear in the SQL statement. This also means you can't skip parameters. If a parameter in your statement can be blank, you have to supply it as a blank, null, or 0 value.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Is there some sample code?
Thanks!
|
|
|
|
|
Just don't do it. Direct Show is incredibly buggy. USe the Windows Media Player control instead.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hello,
Any ideas on how i could dynamically add a detail section to a crystal reports object at run-time, the new details section would also need to have a sub report in it, but that is another matter.
any help much appreciated.
Thanks,
Kristian
|
|
|
|
|
Down the line of code i get one error (EventArgs.pPacket.Data(I)) pPacket is not a member of system.eventArgs
thispacket = ""
For I = 0 To e.pPacket.DataSize - 1
thispacket = thispacket & Chr(EventArgs.pPacket.Data(I))
Next
-----------------------------------------------------------------------------
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With lvpackets
.Columns.Add("Form", .Width / 3, HorizontalAlignment.Left)
.Columns.Add("To", .Width / 3, HorizontalAlignment.Left)
.Columns.Add("Size", .Width / 3, HorizontalAlignment.Left)
.View = View.Details
End With
End Sub
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnstart.Click
Me.AxPacketXCtrl1.Start()
End Sub
Private Sub axpacketxctrl1_OnPacket(ByVal eventsender _
As System.Object, ByVal e As _
AxPacketXLib._IPktXPacketXCtrlEvents_OnPacketEvent) _
Handles AxPacketXCtrl1.OnPacket
Dim I As Short
Dim thispacket As String
Dim sourceip As String
Dim destip As String
Dim item As New ListViewItem
thispacket = ""
For I = 0 To e.pPacket.DataSize - 1
thispacket = thispacket & Chr(EventArgs.pPacket.Data(I))
Next
If e.pPacket.Data(14) = 69 And e.pPacket.Data(23) = 6 Then
sourceip = e.pPacket.Data(26) & "." & _
e.pPacket.Data(27) & "." & + _
e.pPacket.Data(28) & "." & + _
e.pPacket.Data(29)
destip = e.pPacket.Data(30) & "." & _
e.pPacket.Data(31) & "." & + _
e.pPacket.Data(32) & "." & + _
e.pPacket.Data(33)
item.SubItems(0).Text = sourceip
item.SubItems.Add(destip)
item.SubItems.Add(e.pPacket.DataSize)
lvpackets.Items.Add(item)
End If
End Sub
End Class
|
|
|
|
|