[VB Express Edition] User control troubles
Moderator: MaxCoderz Staff
- driesguldolf
- Extreme Poster
- Posts: 395
- Joined: Thu 17 May, 2007 4:49 pm
- Location: $4080
- Contact:
[VB Express Edition] User control troubles
I am currently making some sort of textbox usercontrol to support additional stuff like syntax coloring, highlithing, error marking and stuff but as you migh have guessed microsoft's in the way
Some weird stuff that happens:
- When I change the font property in the form designer suddenly the scroll bars are moved! (not sure how this is posible because the scroll bars are only affected when the control is resized)
- I think that the textrenderer.measuretext routine isn't so accurate because sometimes I can't scroll far enought to the right to show all the text (this happens only with specific fonts tough) (not sure how to explain this, I hope it's clear enough)
Some weird stuff that happens:
- When I change the font property in the form designer suddenly the scroll bars are moved! (not sure how this is posible because the scroll bars are only affected when the control is resized)
- I think that the textrenderer.measuretext routine isn't so accurate because sometimes I can't scroll far enought to the right to show all the text (this happens only with specific fonts tough) (not sure how to explain this, I hope it's clear enough)
Last edited by driesguldolf on Tue 12 Jun, 2007 8:30 pm, edited 1 time in total.
- driesguldolf
- Extreme Poster
- Posts: 395
- Joined: Thu 17 May, 2007 4:49 pm
- Location: $4080
- Contact:
Some more specific stuff about no2:
For clearity:
private contents() as string
private realheight as integer=me.height-horizscroll.height
private realwidth as integer=me.width-vertscroll.width
But actually I've no idea of the things commented
But that's the fun of vbc++ just try it and see if it works and don't ask questions if it does...
For clearity:
private contents() as string
private realheight as integer=me.height-horizscroll.height
private realwidth as integer=me.width-vertscroll.width
Code: Select all
Public Sub ValidateStuff()
Dim x As Integer
VisibleLines = Math.Floor(Realheight / Font.Height)
VertScroll.Enabled = False
If VisibleLines < Contents.Length Then
VertScroll.Maximum = Contents.Length - 2 ''(Why -2? Dunno, it just works)
If VisibleLines < 1 Then VisibleLines = 1
VertScroll.Enabled = True
VertScroll.LargeChange = VertScroll.Maximum / (Contents.Length / VisibleLines) ''(Another guess of mine could be the source of all troubles)
End If
x = LargestLine()
HorizScroll.Enabled = False
If x > RealWidth Then
HorizScroll.Maximum = x + VertScroll.Width
HorizScroll.Enabled = True
HorizScroll.LargeChange = HorizScroll.Maximum / (x / RealWidth) ''(This is probabely where it goes wrong)
End If
End Sub
Private Function LargestLine(Optional ByRef n As Integer = 0) As Integer
Dim l As Integer = Contents.Length - 1
Dim x As Integer
For n = n To l
x = TextRenderer.MeasureText(Contents(n), Font).Width
If x > LargestLine Then LargestLine = x
Next
End Function
But that's the fun of vbc++ just try it and see if it works and don't ask questions if it does...
Last edited by driesguldolf on Tue 12 Jun, 2007 8:23 am, edited 1 time in total.
- benryves
- Maxcoderz Staff
- Posts: 3089
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
Re: [VB Express Edition C++] User control troubles
Automatic Scaling in Windows Forms - forms and their controls can change size when the font is changed. This might be related to your problem.driesguldolf wrote: - When I change the font property in the form designer suddenly the scroll bars are moved! (not sure how this is posible because the scroll bars are only affected when the control is resized)
I've only used Graphics.MeasureString myself, and it has been entirely accurate in all cases thus far. The only issue I can think of is that it (by default) takes into account a little extra padding for overhanging characters and so returns a slightly too-wide value. Pass StringFormat.GenericTypographic to prevent this.- I think that the textrenderer.measuretext routine isn't so accurate because sometimes I can't scroll far enought to the right to show all the text (this happens only with specific fonts tough) (not sure how to explain this, I hope it's clear enough)
Edit: What exactly is VBC++? The language would be VB8.
- driesguldolf
- Extreme Poster
- Posts: 395
- Joined: Thu 17 May, 2007 4:49 pm
- Location: $4080
- Contact:
Yep that was the problem, autoscalemode = "Font" thanksbenryves wrote:Automatic Scaling in Windows Forms - forms and their controls can change size when the font is changed. This might be related to your problem.driesguldolf wrote:- When I change the font property in the form designer suddenly the scroll bars are moved! (not sure how this is posible because the scroll bars are only affected when the control is resized)
Weird, it is sometimes to wide and sometimes too small (drawed a string and underlined it with the measurestring thingie) but the graphics.measurestring works perfect thanksbenryves wrote:I've only used Graphics.MeasureString myself, and it has been entirely accurate in all cases thus far. The only issue I can think of is that it (by default) takes into account a little extra padding for overhanging characters and so returns a slightly too-wide value. Pass StringFormat.GenericTypographic to prevent this.driesguldolf wrote:- I think that the textrenderer.measuretext routine isn't so accurate because sometimes I can't scroll far enought to the right to show all the text (this happens only with specific fonts tough) (not sure how to explain this, I hope it's clear enough)
One more question: I cannot use it directely (graphics.measurestring(...)) it gives me an error (non shared member requires object reference stuff) I have a workaround tough
Is it called VB8? Didn't knew that, I actually invented VBC++, it means Visual Basic [express edition] C++benryves wrote:Edit: What exactly is VBC++? Smile The language would be VB8.
I don't think I get the joke but couldn't think of a better namekv83 wrote:Hehe... VBC++ Laughing It just sounds so... funny (no offence)
hmmm....
Maybe I shouldn't quote so much text (after all I just post the same text) it just wastes valuable space... But it looks professional and hides the fact that I'm a complete newb at VBEDC++
- benryves
- Maxcoderz Staff
- Posts: 3089
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
To emphasise kv's point - C++ is a language. VB is another, completely different, language.
VB6 was the last "classic" VB. VB7, which targeted .NET 1.0/.NET 1.1, is a different language underneath, but retains VB6 syntax for compatibility. It has a much cleaner object-orientated layout than VB6 attempted, and changes the way errors were handled.
VB8 is much the same as VB7, but adds support for .NET 2.0 constructs (eg generics).
To confuse issues, Microsoft released .NET 3.0 with a number of new classes in the framework's class library, but no new language features - so VB9 will target .NET 3.5, and adds a number of new language features (check my Orcas post in Off Topic).
VB6 was the last "classic" VB. VB7, which targeted .NET 1.0/.NET 1.1, is a different language underneath, but retains VB6 syntax for compatibility. It has a much cleaner object-orientated layout than VB6 attempted, and changes the way errors were handled.
VB8 is much the same as VB7, but adds support for .NET 2.0 constructs (eg generics).
To confuse issues, Microsoft released .NET 3.0 with a number of new classes in the framework's class library, but no new language features - so VB9 will target .NET 3.5, and adds a number of new language features (check my Orcas post in Off Topic).
A Graphics object can have a number of transformations applied to it at runtime, so it makes sense to keep things relating to the size and position of elements as an instance member. Use CreateGraphics()?driesguldolf wrote:One more question: I cannot use it directely (graphics.measurestring(...)) it gives me an error (non shared member requires object reference stuff)
- driesguldolf
- Extreme Poster
- Posts: 395
- Joined: Thu 17 May, 2007 4:49 pm
- Location: $4080
- Contact:
Ah forgot about him thanksbenryves wrote:Use CreateGraphics()?
Hmmm alot more troubles have arisen, so this just has to wait until I'm more experienced
Maybe I'll write an on-calc compiler with a simple userinterface for quick and small programs... Really Z80 is alot easier than VB8 plus no one has ever written an on calc compiler (not that I know of)
- tr1p1ea
- Maxcoderz Staff
- Posts: 4141
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: I cant seem to get out of this cryogenic chamber!
- Contact:
People have indeed written on-calc assemblers. You can find one here:
http://www.ticalc.org/archives/files/fi ... 39241.html
Perhaps you could ask the author of that for some pointers.
http://www.ticalc.org/archives/files/fi ... 39241.html
Perhaps you could ask the author of that for some pointers.
- calc84maniac
- Regular Member
- Posts: 112
- Joined: Wed 18 Oct, 2006 7:34 pm
- Location: The ex-planet Pluto
- Contact:
- driesguldolf
- Extreme Poster
- Posts: 395
- Joined: Thu 17 May, 2007 4:49 pm
- Location: $4080
- Contact:
They look nice, I was thinking of an APP with it's own IDE. I thought of adding help to every intruction and stuff (lots of memory needed), but it has to wait until Puzzle Action is finished (points at signature)tr1pea1 wrote:People have indeed written on-calc assemblers. You can find one here:
http://www.ticalc.org/archives/files/fi ... 39241.html
Perhaps you could ask the author of that for some pointers.
I think I will wait for that, there are so many languages and I have no idea wich one is the best, it also takes a while to really know a language and I don't want to have wasted my time on a crappy language.kv83 wrote:If you're using VB Express atm, i advice you to step over to C# asap Smile
- benryves
- Maxcoderz Staff
- Posts: 3089
- Joined: Thu 16 Dec, 2004 10:06 pm
- Location: Croydon, England
- Contact:
It took me all of half an hour to make the switch and feel comfortable with it. C# has a terser, cleaner syntax than VB. (Admittedly, VB can do some things that C# can't, but C# can do more important things that VB can't).driesguldolf wrote:I think I will wait for that, there are so many languages and I have no idea wich one is the best, it also takes a while to really know a language and I don't want to have wasted my time on a crappy language.kv83 wrote:If you're using VB Express atm, i advice you to step over to C# asap Smile