|
-
May 11th, 2011, 01:07 AM
#1
Thread Starter
Lively Member
-
May 11th, 2011, 03:58 AM
#2
Re: Drawing/Overlaying Text Directly to screen
try this:
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim gr As Graphics = Graphics.FromHwnd(New IntPtr(0))
gr.DrawString("text on screen", New Font(Me.Font.FontFamily, 25, FontStyle.Regular), Brushes.Red, 50, 50)
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 12th, 2011, 03:05 AM
#3
Thread Starter
Lively Member
Re: Drawing/Overlaying Text Directly to screen
Hmmm this code seems to do nothing :O
-Josh
-
May 12th, 2011, 04:08 AM
#4
Re: Drawing/Overlaying Text Directly to screen
 Originally Posted by jduncanator
Hmmm this code seems to do nothing :O
-Josh
Hm, I had that trouble too. Paul, is there something we missed here?
Meanwhile, Josh, there is an alternative that might suit your purposes -- show a transparent, borderless form with the text on it. Here's an example which you could code on a form with a button Button1:
Code:
Private WithEvents TextForm As New Form
Private Zipper As New FontFamily("Zipper")
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
With TextForm
.BackColor = Color.DimGray
.TransparencyKey = Color.DimGray
.FormBorderStyle = Windows.Forms.FormBorderStyle.None
.ShowInTaskbar = False
.WindowState = FormWindowState.Maximized
.Opacity = 0
.Show(Me)
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Static showText As Boolean
showText = Not showText
If showText Then TextForm.Opacity = 0.99 Else TextForm.Opacity = 0
End Sub
Private Sub TextForm_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles TextForm.Paint
e.Graphics.DrawString("text on screen 12345", New Font(Zipper, 30, FontStyle.Bold), Brushes.Red, 50, 50)
End Sub
A few notes:
1. You could also use your main form this way. Many of the properties shown here in the Load sub could be set in Designer.
2. It's a good idea to make the transparent form an Owned Form of the one underneath. In the example above, it's done by the argument in TextForm.Show(Me). You can also set the Form.Owner property in code. Making the transparent form TopMost is not a good substitute.
3. Anti-aliasing is a problem with transparent forms. The smoothing pixels show up in the form's TransparencyKey colour on curves and diagonals of the text where the colour contrasts with the background. One way to deal with this is to choose a font without curves or diagonals - for example Zipper which I downloaded free from www.FontRiver.com. Alternatively, set Graphics.TextRenderingHint to SingleBitPerPixelGridFit.
4. Form Opacity is my favourite way to switch visibility. Using 0.99 instead of 1 for the maximum opacity gives a smoother result.
BB
-
May 12th, 2011, 05:21 AM
#5
Thread Starter
Lively Member
Re: Drawing/Overlaying Text Directly to screen
thanks someone told me about this, and yes its a possability but not ideal as some of the programs it will be running over will be full screened
-Josh
-
May 12th, 2011, 07:23 AM
#6
Re: Drawing/Overlaying Text Directly to screen
 Originally Posted by jduncanator
Hmmm this code seems to do nothing :O
-Josh
on my PC it writes directly on the screen, but it's erased as soon as the desktop refreshes. that's probably the problem...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 14th, 2011, 07:08 PM
#7
Re: Drawing/Overlaying Text Directly to screen
 Originally Posted by jduncanator
Hey guys,
Ok Ill cut straight to the point  I know this could be to do with DirectX or something but ill post it here for now. What I would like to know is how to Draw text directly to the screen - effectively overlapping anything underneath it - but have it out side a form area! I would really like to have no user interface at all if possible  I know what I wanted after recently using FRAPs. To get an Idea of what i need here is a screen shot of it in action (FRAPs):
-image snipped-
(See the top left corner).
Thanks for any help what so ever xD
-Josh
What I think FRAPS is doing is injecting some code to write the FPS of the program in a specified corner (which is configurable in the application), so they're probably using some DirectX and hooking code to do so...just a bit of possible insight for you.
-
May 14th, 2011, 07:18 PM
#8
Re: Drawing/Overlaying Text Directly to screen
To confirm, drawing over a full screen DirectX overlay is a very different kettle of fish to drawing onto the desktop. To handle a DirectX overlay you really need access to that process and do it from there. I don't know how but I imagine it will involve a certain amount of hacky API such as WriteProcessMemory and luck.
Edit: directX overlays in windowed mode are much easier, see advice above.
Last edited by Milk; May 14th, 2011 at 07:32 PM.
Reason: if only I could construct a english sentance
W o t . S i g
-
May 15th, 2011, 02:41 AM
#9
Thread Starter
Lively Member
Re: Drawing/Overlaying Text Directly to screen
Ok heres the deal, I need to write a program that will overlay on top of all the windows, I'm stuffing the full screen crap, this program will mainly be used for writing information over the top of a flash game running in a browser, makeing a transparent form, at the moment, is out of the picture, and would really love for something that is able to do it either running in the background or not... Also I have a question, if a program has a transparent form running over a flash game (running around 30-40fps) surely this would have a hit on the system??
-Josh
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|