write Text to Form

Tylor

New member
Joined
Aug 20, 2014
Messages
4
Location
South Africa, Johannesburg
Programming Experience
Beginner
Good afternoon guys.

This is my first post on VBdotnet
I have recently started using Visual Studio 2012 to learn some VB.net

I am currently developing an app in order to get more proficient at VS.

I would like to be able to print text to the screen and systematically/automatically remove it as well after a certain time period.
An example would be the opening lines in Star Wars.(A long, long time ago..)

I did first try using labels, But as I need this text to appear a line at a time and then erase itself before the next line is written.
I have a total of 5 lines I would like to print,one after the other once the form loads.

This text background however needs to be transparent as I have a form background that I prefer not having a big white chunk taken out of.

I did read however that someone mentioned a user to "Create your own window. It doesn't have to be visible, use the Form.TransparencyKey property"

But I am still super fresh with VB.net hence I feel pretty much like a fool.

My current VS is just the basic installation with no extra add-ons installed, Not sure there Is an extension available to attend to my requirements.
 
I think that the best solution is probably to use GDI+ to draw the text directly onto the form surface. The TransparencyKey property is definitely irrelevant because that's about making parts of the form transparent so that you can see through it. You would override the OnPaint method of your form and call e.Graphics.DrawString to draw the text.

Exactly how you decide what text to draw and where depends on exactly the effect you want. The opening text in Star Wars scrolls up continuously. Do you want that same effect or something different? You need to be specific because the code is going to change depending on the details.
 
Hi jmcilhinney

When it comes to the effect I want, I will be open to either the continuous scrolling or a line by line scroll.
Whichever one would be easier to set up and maintain.

I read a bit about GDI+. Are there any additional programs I need to use it?
On Mirosoft's site It mentions DesignSurface.
Just thought I'd first ask here in case there might be a simpler or more on topic tool to use.
 
GDI+ is something you can do right in VS too. Just override the OnPaint method and draw the text yourself using the graphics object.
It's extremely similar to printing stuff in the PrintDocument.
 
Here's basically what you would do:

1. Declare a field to store the location of the text to be drawn.
2. Override the OnPaint method of the form.
3. Use e.Graphics.DrawString to draw the text at the specified location.
4. Add a Timer.
5. In the Tick event handler, decrement the field and call Refresh on the form.

Now, each time the Timer raises a Tick event, the form will be repainted and the text redrawn higher up. Eventually, the text will scroll off the top of the form and you can Stop the Timer. You can experiment with the Interval of the Timer and the amount you change the text location to get the speed and smoothness you want.
 
Morning JuggaloBrotha

I went to read up on Overriding the GDI+ OnPaint method in VB.net, managed to find 2 decent web results for this.
This seems to be exactly what I am looking form.
Thank you guys so much.I am going to use this now and see what I can produce.
 
Back
Top