|
Thanks for the reply.
When the application loses focus (e.g. I go to MS word or whatever) and then return to the application, the window is completely blank and an hourglass is displayed when the mouse is on any part of the window with the exception of the close button. I have broken the app into pieces and I am sure that the piece that is running should complete in a few minutes, but it never does.
Jim
|
|
|
|
|
OK. If your app never repaints (you get a white window for instance), you have to place Application.DoEvents() in you automation loop so your app can actually process the WM_PAINT messages that are being sent to your app and repaint the screen:
Dim Index as Integer
For Index = 0 to 10000
'.
'... Do some processing here...
'.
' Let our app respond to other messages here, like repaint our forms...
Application.DoEvents()
Next
RageInTheMachine9532
|
|
|
|
|
Thanks again. I will give that a try.
Jim
|
|
|
|
|
Language - Visual Basic.Net (home edition, or the non-proffessional at any rate)
Okay, I have a problem with three parts.
Part the first: I want to be able to save certain settings of a program to a text file. Now, I know how to create a text file and write to it, but I need to be able to read specific lines from it, and I'm not really sure how to do that.
Part the second: I need to find the bin folder (or whatever folder the program is running in) at runtime, so that I can figure out where the text file is.
Part the third: I need to know how to confirm whether or not that text file already exists.
Any help at all would be greatly appreciated. Thanks!
|
|
|
|
|
RandomGuy85 wrote:
Part the first: I want to be able to save certain settings of a program to a text file. Now, I know how to create a text file and write to it, but I need to be able to read specific lines from it, and I'm not really sure how to do that.
Pretty much the same way that you write to the file. First, how are you writing to the file? There are different classes and methods for File I/O and I'd like to match the technique with what your already doing. A sample of your code would help.
Part the second: I need to find the bin folder (or whatever folder the program is running in) at runtime, so that I can figure out where the text file is.
You can get the path to the executable from Application.StartupPath. The only problem with what you are doing is that every user that saves setting from your application will overwrite the previous users settings. A better choice would be to use the path stored in Application.UserAppDataPath.
Part the third: I need to know how to confirm whether or not that text file already exists.
Easy enough...You can use File.Exists(filepath) to see if the file exists or not.
This is a good excersize in reading/writing files...but there is another way to do application settings without them. SaveSetting and GetSetting will allow you to read and write settings to the registry without having to handle files at all.
RageInTheMachine9532
|
|
|
|
|
Using the registry is not the ".NET Way", for what it's worth. Also, I believe you need additional CAS permissions to do so that are not required when using isolated storage.
Charlie
Here I am. Love me.
|
|
|
|
|
Charlie Williams wrote:
Using the registry is not the ".NET Way", for what it's worth. Also, I believe you need additional CAS permissions to do so that are not required when using isolated storage.
The '.NET Way'?? Are you talking about XML config files?
The Save/GetSetting write their information to the CurrentUser Key of the registry. Unless the desktop load has been severely restricted, no out of the ordinary permissions are required by the code or user to use these functions.
RageInTheMachine9532
|
|
|
|
|
I simply meant that Microsoft recommends against using the registry when there are other options available. Certainly, there is nothing wrong with using the registry to store app information on a Windows machine, but if you intend to port your app to other platforms (not that it's realistic to do so now, but that's one of the stated goals of .net in the first place, right?) you'll have to come up with a different way of doing it.
GetSetting requires registry permissions. This isn't a problem with a locally installed app, but apps run over an intra/internet do not have this permission by default.
If neither of those two issues apply to a given situation, then register away.
Charlie
Here I am. Love me.
|
|
|
|
|
as topic, how to select the text in richtextbox and copy them to clipboard to be ready to paste in other document?
|
|
|
|
|
Are you selecting the text in code or is a user doing it?
If your doing it, use the Select method of the RichTextBox:
RichTextBox1.Select() ' selects everything in the RichTextBox
RichTextBox1.Select( start, length ) ' selects everthing starting at position 'start' for 'length' characters
After the selection is made all you have to do to get it on the Clipboard is this:
Clipboard.SetDataObject(RichTextBox1.SelectedRtf) or if you want just the text (without the formatting):
Clipboard.SetDataObject(RichTextBox1.SelectedText)
RageInTheMachine9532
|
|
|
|
|
thank you for replying me!! i tried out ur solution and it works!!
however the output actually is not my expectation..
for example, the text in my richtext box is like following:
hello!
how are u?
i am fine...
after i copy these 3 lines of texts into clipboard using
Clipboard.SetDataObject(RichTextBox1.SelectedText)
then paste it into notepad, the output is following:
hello!how are u?i am fine...
the 3 lines text become one line and all the text were combined?!
what i actually expect is the same format as in the multiline richtextbox...
can u figure out another solution for me??
i really appreciate ur help...
thank you very much!!
|
|
|
|
|
Easy! Replace every copy of ControlChars.Lf with ControlChars.CrLf before you set the DataObject on the Clipboard:
Dim strText As String
strText = RichTextBox1.SelectedText.Replace(ControlChars.Lf, ControlChars.CrLf)
Clipboard.SetDataObject(strText, True)
BTW: The 'True' in the SetDataObject just means that the data is to be left on the clipboard if your app quits.
RageInTheMachine9532
|
|
|
|
|
thanks man!! it works!!
by the way do u know how create a floating pop up menu when i right click in the richtextbox??
wat i actually wan to do is create a copy command in the popup menu when user selected the text and right click...
|
|
|
|
|
ClipBoard.Clear
ClipBoard.SetText rtfText1.SelRTF ,vbCFRTF
|
|
|
|
|
By dafault form1 is the active form . How can we change the active form
to form 2 such that after closing form1 our application wont be closed.
neha
|
|
|
|
|
Are you saying that you'll have multiple forms open at the same time and that the user can close any of them and still keep the app running? Sounds like a job for seperate apps to me but I don't know all the details about what your doing...
Ummm...You might want to try having either a Main function that declares and shows all the forms, or you might want to do the same thing in a hidden form. You can then go into the Project Properties and change the startup object to either Main or the hidden form. Now, you'r also going to have to handle the Close events of these forms so your Main or hidden form knows that all of your visible forms are closed so it knows when to quit.
RageInTheMachine9532
|
|
|
|
|
Thanks for the reply , but in my appln there are 7 forms & once I start executing the appln , My main startup form appears. ok. Now once I go from this startup form to form2 , I would like to close the startup form(form1).
when I close the startup form (form1) then my application gets closed.
So for this can u suggest any remedy so that I can transfer the active control from form1(startup) to form2 & can close startup form??
|
|
|
|
|
Then you might want to try something like Me.Hide() on your main form. Or Form1.Hide() when you enter the Activate code on Form2.
RageInTheMachine9532
|
|
|
|
|
Currently Iam doing that only but then when Iam closing the main form ie
form2 then my application is not getting closed. ie I am required to go to
the close button from the VB menu to stop execution of the application.
I dont know how far u can understand what I mean to say !!
|
|
|
|
|
Now it sounds like your first form is a splash screen.
What ever form is your startup form CANNOT be closed unless you want your entire app to be closed with it. Your startup form does NOT have to be visible when you app starts. You can start your app with Form1.Visible=False and have it Form2.Show, Form3.Show, whatever... But! You have to keep track of which Forms are open in your main form (Form1) and determine when Form1 either shows itself to be closed or closes on its own.
RageInTheMachine9532
|
|
|
|
|
I think there is a problem with your design assumptions and how Windows Forms apps work. It would appears that you think your application can stay open so long as there is ANY form in your app open:
Application
|
|
+-------+-------+-------+-------+
| | | | |
Form1 Form2 Form3 Form4 Form5
This is just not the case. Your application depends on a main class, or Form, that is the central hub of your application. Something like this:
Application
|
Form1
|
+-------+-------+-------+-------+
| | | | |
Form2 Form3 Form4 Form5 Form6
| |
Form7 Form8
Only when Form1 is closed can your application close, and in opposite terms, only so long as Form1 is open, even if its not visible, can your app stay open.
In the latter example, Form2 can be your splash screen, Forms 3-6 can be options dialogs, editors, print previews, subsections of your app, whatever, ... But in all cases, Form1 MUST keep track of which forms are open and closed.
RageInTheMachine9532
|
|
|
|
|
Thanks ,, Thanks a lot ..
My doubt is completely cleared...
Thanks for explaining it so nicely ...
Now I will implement this in my application.
If I have any doubts later then again I will write back.
|
|
|
|
|
Does anyone know how to show method or property descriptions for a particular class in Visual Studio's code-view? I do the following but it doesn't work:
Imports System.ComponentModel
Public Class JobSeeker
...
<Description("asdfasdf asdf asdf asdf")> _
Shared Sub delete(ByVal Name As String)
...
End Sub
End class
I want to be able to see the descriptions of my own methods when I'm calling them.
Microsoft says the description will show (if you use DescriptionAttribute) when you CLICK on the property, my guess is this is only for visual components, because in code-view you don't click on properties...
any ideas guys? your input will be greatly appreciated.
Regards,
Mesrop
|
|
|
|
|
the DescriptionAttribute is just shown in the propertywindow( at the lower border). i think you like to see the description by intelisense...so if you know how to do this let me know
|
|
|
|
|
You need a 3rd party extension to Visual Studio for this to work. VB.NET can't output the XML file needed for Intellisense to show you the description. Currently, i don't know of any extension that will do this for VB. The C++ and C# compilers WILL do this though.
The Description attribute only work in the properties window...
RageInTheMachine9532
|
|
|
|