Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

158 Neutral

About h0-0t

  • Rank
  1. Under the advice of one of the members of these boards, I've revised a project I am working on to use a user control that uses GDI+ to paint onto itself as a text window. Right now I can type multiple lines of text no problem. The problem comes when the text goes outside of the bounds of the user control. I have no clue how to make scroll bars appear when this happens since it isn't actual text but GDI+ painted text. My code for the control is as follows...it's under it's first revision as I type this so it'll be sloppy and likely poorly done. Imports System.Drawing.Drawing2D Imports System.Text Public Class GDIPLUSTEXTBOX Inherits UserControl Dim g As Graphics Dim fnt As New Font("Courier New", 10) Dim s(65536) As System.String Dim A As Integer Dim LineNumber As Integer = 0 Private Sub GDIPLUSTEXTBOX_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress If (e.KeyChar.ToString = Chr(13)) Then s(LineNumber) = String.Concat(s(LineNumber), e.KeyChar.ToString()) LineNumber = (LineNumber + 1) Me.Refresh() Else s(LineNumber) = String.Concat(s(LineNumber), e.KeyChar.ToString()) Me.Refresh() End If End Sub Private Sub GDIPLUSTEXTBOX_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'later End Sub Private Sub GDIPLUSTEXTBOX_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint g = e.Graphics For A = 0 To LineNumber g.DrawString(s(A), fnt, New SolidBrush(Color.Red), 5, 5 + 16 * A) Next A End Sub End Class As I've said on many of my posts, I've been out of programming for a long time and this is my first time using VB.Net.
  2. Quote:Original post by benryves I've written a class that inherits from Control and use GDI+ for painting. I don't have the first clue about writing my own controls -.- Are there any good resources you know of offhand that I could look at for this kind of thing? I googled for a few hours and came up empty.
  3. Alright thanks for all your help :) I'm downloading MSVB.NET 2005 Express right now...it's about time I get rid of this crappy MSVB6....so old :(
  4. hmm Is there any chance you could show me some sample code for this or would that be asking too much seeing it IS your code? I've been out of programming for a while now so I'm pretty rusty as I'm sure you've noticed lol
  5. The guy who is who is working on this with me said something about a picturebox and GDI...not sure if that's what you're getting at as far as writing your own text control.
  6. Does anyone know where I might be able to get my hands on a copy of the source for a similar source formatter like the on this forum uses in the BB script?
  7. lol that explains it... I had been using "code" instead of "source"... So tired
  8. not sure why it went that big...
  9. Full code(keep in mind this was a fast job and really sloppy): Dim cLastChar As Integer Dim gIndents As Integer Dim gCharCount As Integer Dim gLineCount As Integer Private Sub Form_Load() Dim lines As String Dim chrs As String RTF.Font = "Courier New" RTF.Font.Size = 10 gIndents = 0 gCharCount = 0 gLineCount = 1 chrs = " chrs" lines = " line" gLines.Caption = gLineCount & lines gChars.Caption = gCharCount & chrs End Sub Private Sub RTF_KeyPress(KeyAscii As Integer) Dim i As Integer If KeyAscii = 8 Then If gCharCount > 0 Then gCharCount = gCharCount - 1 End If End If If KeyAscii = 13 Then gLineCount = gLineCount + 1 End If If KeyAscii > 32 And KeyAscii < 127 Then cLastChar = KeyAscii gCharCount = gCharCount + 1 End If If (cLastChar = 123 And KeyAscii = 13) Then gIndents = gIndents + 1 ElseIf (cLastChar = 125 And KeyAscii = 13) Then If gIndents > 0 Then gIndents = gIndents - 1 SendKeys ("{BACKSPACE 3}") SendKeys ("{}}") SendKeys ("{ENTER}") End If End If If KeyAscii = 13 And gIndents > 0 Then For i = 1 To gIndents SendKeys ("{TAB}") Next i End If If gLineCount > 1 Then lines = " lines" Else lines = " line" End If If gCharCount = 1 Then chrs = " chr" Else chrs = " chrs" End If gLines.Caption = gLineCount & lines gChars.Caption = gCharCount & chrs End Sub
  10. I have something kinda silly going on at the end (admittedly it was just to boast to my gf that I've actually done something useful in the last month lol) If (cLastChar = 123 And KeyAscii = 13) Then gIndents = gIndents + 1 ElseIf (cLastChar = 125 And KeyAscii = 13) Then If gIndents > 0 Then gIndents = gIndents - 1 SendKeys ("{BACKSPACE 3}") SendKeys ("{}}") SendKeys ("{ENTER}") End If End If See, this makes it work for the first ideal situation I mentioned, but kills it for the rest lol... My main problem arises from my lack of knowledge of RTB attributes and my (approx) 1 year of programming LOA. I have a feeling if I could remember how to go "go back to beginning of last line, sendkey DELETE, go back to end of where I should be after hitting enter" that it would work...
  11. That sounds similar to what I was doing. I was going to try and parse the entire file at once since one of the old programs I used to use had that, but I decided on the fly was the best approach. What I have in the first revision is as follows: A global counter for Indents that increases everytime LastChar = { and is SUPPOSED to decrease everytime LastChar = }. If Indents = 0, of course we don't want it to subtract.
  12. I posted earlier regarding changing the font colour of certain keywords in a richtext box, and I got a good response to that...but now I have a new problem :( I am trying to emulate popular editors as best I can when it comes to the code view. To do so effectively, I need to figure out how to make it so my RTB auto indents code typed into it. Is there an efficient/quick way to do this or is it a long, mind-numbing experience? So far I can handle indents as I go down, but reversing this is a different story. If I do: function FOO( arg ) { echo 'BAR'; } it acts as though it is working fine. HOWEVER If I try to do something like function FOO( arg ) { If(x = y) { } <- it messes up here } Have any of you ever made something like this? If so, could you please shed some light on this topic for me?
  13. h0-0t

    Colour-coded Code?

    Thank you very much :) Wow I can't believe I forgot about RTF....must be the tired and student food talking :P
  14. -----This program is being written in visual basic 6----- --(I know the software is old and crappy, but I'm poor)-- I am setting out to work on a small code window for a map editor I am making. The code window will be for scripting, which will be built right into the maps. My question is, how would I go about creating a text area similar to the work area in, say, VS or codeview in Dreamweaver (or similar applications)? That is, the area where you type would be able to change the colour of certain keywords while leaving the rest alone. I've never tried anything like this before, so any help would be appreciated. Thank you in advance. -Kris
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!