|
I am doing some "creative" syntax hilighting with VB.NET and RichEdit. Only problem is it shows the selection box! "NoHiglight" isn't going to work in this case because the text actually has to be selected to change the color. (I tried it anyway, didnt work)
Anyone got any ideas?
|
|
|
|
|
|
you'll have to use the LockWindowUpdate function from the User32.lib
The LockWindowUpdate function disables or enables drawing in the specified window. Only one window can be locked at a time.
Declare Function LockWindowUpdate Lib "user32" Alias "LockWindowUpdate" (ByVal hwndLock As Long) As Long
Applicable to VB4-32,5,6
Parameter Information
hWndLock
Specifies the window in which drawing will be disabled. If this parameter is NULL, drawing in the locked window is enabled.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero, indicating that an error occurred or another window was already locked.
Declare the function - usually in a .bas module
Declare Function LockWindowUpdate Lib "user32" Alias "LockWindowUpdate" (ByVal hwndLock As Long) As Long
Where your code is...
Private sub WhereEver()
LockWindowUpdate Rich1.hwnd
your code goes here...
LockWindowUpdate False
end sub
Hope this is useful
Budgieboy
|
|
|
|
|
I want to call the file properties dialog box, the one when you right clik in a file or in many files usind the explorer and them click ont the properties menu...
I heard about many ways, one is calling an api(the worst way, I think), other is add a reference to the shell32.dll, and i heard about something in the System.Diagnostics.Process...
Does anyone knows one of these ways or other ways?
Thanks in advance.
|
|
|
|
|
I'm new to vb.net and I was wondering if it would be possible to use regex on a treeview?
I haven't got any code but at least that makes for a quick read..
what I would like is to be able to traverse a treeview for a regex, then building a new treeview with the nodes found maintaining the original structure of the tree (parent - child)
inputs are extremely welcome
peace
How terrible is wisdom when it brings no profit to the wise
|
|
|
|
|
In a nutshell ...
Private Sub btnMatch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMatch.Click
targetTree.Nodes.Clear()
Dim Expression As New Regex(txtExpression.Text)
Dim Matches As MatchCollection
For Each node As TreeNode In sourceTree.Nodes
If Expression.IsMatch(node.FullPath) Then
targetTree.Nodes.Add(node.Clone)
End If
CheckNodes(Expression, node, targetTree)
Next
End Sub
Private Sub CheckNodes(ByVal expression As Regex, ByVal node As TreeNode, ByVal target As TreeView)
For Each child As TreeNode In node.Nodes
If expression.IsMatch(child.FullPath) Then
NodeParent(target, node).Nodes.Add(child.Clone)
End If
CheckNodes(expression, child, target)
Next
End Sub
Private Function NodeParent(ByVal target As TreeView, ByVal node As TreeNode) As TreeNode
If node.Parent Is Nothing Then
For Each Parent As TreeNode In target.Nodes
If Parent.Text = node.Text Then Return Parent
Next
Return target.Nodes.Add(node.Text)
End If
Return NodeParent(target, node.Parent).Nodes.Add(node.Text)
End Function
|
|
|
|
|
Hi,
I have a string variable and it has over 300000 chars.... it is like it:
text
text1
txt2
it has many lines, and so, I have to read one by one. I tryed to use System.IO.StreamReader, but it does not accept over 260 chars...
If someone has any ideas it would be very helpfulll
Thanks in advance
|
|
|
|
|
Maybe this isn't the best way to handle it, but how about using .Split() on the string, supplying the newline character?
Dim lines() as String = _
myBigString.Split(System.Environment.NewLine)
Dim i as integer
For i = 0 to lines.Length - 1
'--do something with the line
DoSomething(lines(i))
Next
|
|
|
|
|
Hi,
Yes it should works, but the problem is that I will make a copy of my big string, and it will use more memory. I am thinking about use your method, but them clear my big string...
I will try to get a better way...
Thanks, it could be usefull
|
|
|
|
|
How about using a StringReader then?
Dim sr as System.IO.StringReader = _
new System.IO.StringReader(myBigString)
Dim line as String
'--read the first line from the string
line = sr.ReadLine()
Do While Not (line Is Nothing)
'--do something with the line
DoSomething(line)
'--read the next line from the string
line = sr.ReadLine()
Loop
|
|
|
|
|
Yes... I tryed just with the StreamReader, and it does not work, I have not thinked about StringReader. So I will se it...
Thanks
|
|
|
|
|
Hi,
Since String are immutable, any changes you make to the String, like removing a line from it, will result in a copy of the string being created that includes the change you made, then the original string is abandoned and, later, cleaned up by the garbage collector.
Holding a 300K string in memory doesn't sound like a good use of resources. Why the large string?
RageInTheMachine9532
|
|
|
|
|
Hi,
I have a .txt file, and it is very big, my application needs to change this file at any time, and to open edit and save it will result in a long time token, so I think it is better to copy it to a variable, make the changes to the variable, and in the end of the program, it could write again.
I do not know if there is a way to rewrite the file just where it has changed, and do not write all the file again, them it will be much better.
If you could help me...
Thanks
|
|
|
|
|
What's in this file? Is it a text document? flat database? Worlds Largest Configuration (.INI) file?
Maybe there is a better way to do it, but it depends on the what the data is and what your doing to manipulate it.
RageInTheMachine9532
|
|
|
|
|
Hi,
It is a text document, so i read it, edit it and them it write again, but jsut write wher it has changed, the it wil be faster...
I do not know with there is a direct way to edit it, or if I have to put it in a variable anyway...
Any ideas...
|
|
|
|
|
OK. It looks like that a String() is the best method then. It sounds like the problem you have now is the speed at which the string is read from or written to the file. I've come up with a partial implementation of a text editor with some code that is the fastest text file reader/writer that I can come up with. It reads/writes 500K in less than 0.05 seconds on my machine.
Here's the code snippet for reading and writing the file:
Private Sub mnuFileOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileOpen.Click
If ofdOpenFile.ShowDialog = DialogResult.OK Then
fileName = ofdOpenFile.FileName
Dim openFile As New StreamReader(fileName)
txtEdit.Text = openFile.ReadToEnd()
openFile.Close()
End If
End Sub
Private Sub mnuFileSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileSave.Click
If Not fileName.Equals(String.Empty) Then
Dim saveFileWriter As StreamWriter = File.CreateText(fileName)
Dim strReader As New StringReader(txtEdit.Text)
saveFileWriter.Write(strReader.ReadToEnd)
saveFileWriter.Flush()
saveFileWriter.Close()
strReader.Close()
End If
End Sub
If you want the entire sample project, send me an email with an address to reply to.
RageInTheMachine9532
|
|
|
|
|
Has anyone else had problems with the Application.DoEvents statement? I have a VB.net written DLL that throws the ubiquitous "Object reference not set..." error on a couple of machines. I can't duplicate the error on my desk or on other machines.
When I put code in to trace down exactly which statement it's on when the error hits, it's a DoEvents statement. I mostly put those in to give the calling apps time to process other events, so they aren't all critical. So, in an attempt to narrow it down, I removed the offending statement. The error hit again but this time on the next DoEvents statement it found in the code.
This has got me completely puzzled. Normally, when something happens on one machine and not one all, I check to make sure any referenced DLL's are the same. They are. This DLL calls 2 COM objects and 1 .NET DLL and all of those references are identical in version.
I know the error normally means that someone forgot a "NEW" statement or an object was inadvertantly set to Nothing, but I can't find any object where that would make sense. If that was the case, the DLL wouldn't run cleanly anywhere, but it does run OK on some machines, including in the development environment.
Any ideas would be greatly appreciated.
|
|
|
|
|
Not sure why your application object isn't instantiated, but you could also try the tell the thread to whait a brief moment.
System.Threading.Thread.CurrentThread.Sleep(500)
|
|
|
|
|
Hi.....
i want to deploy my project by creating setup.Can you help me how to create setup which includes the dot net framework.Let me know the procedure how to include Dotnet FrameWork in my project's msi file.Let me know the procedure to deploy my project on system which does not have dotnet framework.How to install the required supports to run my vb .Net Program.
Thanks for your help.
Payal Sheth
|
|
|
|
|
Hi,
I'm new to programming and need help. I'm trying to design an application that will allow end users to search a diary for bookings; make a booking if available; and then update a database system.
I'm having difficulty in designing/coding the diary section of the application.
Any ideas and help would be much appreciated.
|
|
|
|
|
Hi Martyn. That is a very broad request for help. How new are you to programming in general, and to .NET programming in particular? Would you be helped at this point to get a list of recommended reading on the subject?
As you go along, if you get to a specific point in your coding that is causing difficulty, or have a question about a more specific area in your development, post it and I'm sure folks will try to help. It's just a tough thing to answer such a broad question, beyond offering links you could visit or recommendations for books, that sort of thing.
|
|
|
|
|
Hi
How to make property indexers in VB .NET...
Against my will, I am standing beside my own shadow!
-------------------
Therez No Place like ... 127.0.0.1
|
|
|
|
|
The following should work:
Public Property Notes(ByVal index As Integer) As String<br />
Get<br />
Return m_Notes(index)<br />
End Get<br />
Set(ByVal Value As String)<br />
m_Notes(index) = Value<br />
End Set<br />
End Property
The when you're using the property:
myClass.Notes(2) = "Some message!"
Hope this helps.
Dan Morris
|
|
|
|
|
he he he he....
I want to do
myClass(2) = "Some message!"
Anyway, thanks for your time... I appreciate it
fadee
-------------------
Therez No Place like ... 127.0.0.1
|
|
|
|
|
I think you want to assign a property as Default . Try this page on MSDN[^].
|
|
|
|