-
Scrolling to textbox bottom without focus ?
Hey,
I have a textbox control that functions as a log window for my application, and I've successfully made it scroll to the bottom automatically.
Unfortunately the function used gives the window focus (While I don't want that) I've tried using selStart with the textbox length, and I tried using the following API call:
Code:
SendMessage txtLog.hWnd, WMVSCROLL, SBBOTTOM, 0
Is there any other API call or anything that makes it scroll to the bottom without giving focus to it ?
Edit: Just changing the text of the textbox gives it focus apperently, is there any way to prevent this ?
Thanks for your time, Xeross
-
Re: Scrolling to textbox bottom without focus ?
Use this:
Code:
txtLog.Selstart = Len(txtLog.Text)
If you add vbCrLf to your log messages already, then you might wish to subtract 2 from the length.
The focus is obviously not given to the textbox as far as I have tried.
-
Re: Scrolling to textbox bottom without focus ?
It seems just adding text to it gives it focus somehow.
-
Re: Scrolling to textbox bottom without focus ?
Code:
With frm_log.txtLog
If .Text <> "" Then
.Text = .Text & vbNewLine
End If
.Text = .Text & "[" & cDay & "/" & UCase(MonthName(Month(Now), True)) & "/" & cYear & "][" & cHour & ":" & cMinute & ":" & cSecond & "] "
.Text = .Text & outStr
Call SendMessage(.hWnd, WMVSCROLL, SBBOTTOM, 0)
End With
Note it also gets focus without the sendMessage.
-
Re: Scrolling to textbox bottom without focus ?
I tried this in a form with a TextBox and a button:
Code:
Private Sub Form_Activate()
Command1.SetFocus
Text1.Text = "huhu"
End Sub
Putting text into the box does NOT set the focus to it. It must happen earlier.
-
Re: Scrolling to textbox bottom without focus ?
I found it now, I had a call in the log script that did frm_log.Show() which triggered it to get focus, I just added a check now if it's already visible and that fixed it.
The only problem remaining is that it tends to scroll back up to the top of the textbox and then back down when I add text (This happens in a very short timeperiod most of the time it's unnoticable) any way around this ?
Regards, Xeross
-
Re: Scrolling to textbox bottom without focus ?
I use a texbox for logging in quite a similar way.
Code:
txtlog.text = textlog.text + newtext$ + vbcrlf
txtLog.Selstart = Len(txtLog.Text)
It never scrolled up by itself. Keep the SelStart always at the end of the text. The SendMessage you are using does not influence the SelStart which is the actual cursor position. If this stays somewhere at the top it could be that it tends to scroll up again.
-
Re: Scrolling to textbox bottom without focus ?
I'm using the selStart again, but somehow I still get these jumps to the top though they are almost unnoticable.
-
Re: Scrolling to textbox bottom without focus ?
Strange... you could try finding out if other unwanted events occur, liek keydown, keypress, getfocus, by setting a msgbox instruction into the event handlers.
Does the jump occur, when you add the new text?
-
Re: Scrolling to textbox bottom without focus ?
It adds when adding new lines, replacing lines, or adding something to the current line.
-
Re: Scrolling to textbox bottom without focus ?
Okay. Another method of adding text to the textbox is inserting it at the cursorposition.
Code:
txtlog.Selstart=len(txtlog.text)
txtlog.SelText=NewText
You could try this instead of txtlog.text = txtlog.text + NewText
-
Re: Scrolling to textbox bottom without focus ?
That might work.
And I think I just figured out why it would flash back up and then down: When you set the contents the thing gets emptied (Causing the scroll-up) and then it gets filled again.
I'll test it tomorrow. thanks.
-
Re: Scrolling to textbox bottom without focus ?
Wof! Bad Wof! using + to concatinate strings. Bad Wof! :)
-
Re: Scrolling to textbox bottom without focus ?
-
Re: Scrolling to textbox bottom without focus ?
Shame, shame on me. :D There are always these blanks I have to type when using the &.
And you know, these days I completely neglect to Set my objevt variables to Nothing, at end of sub, even at Form_Unload(), too.
I hope I find forgiveness, when once in VB heaven. ;)
-
Re: Scrolling to textbox bottom without focus ?
Quote:
Originally Posted by
WoF
Shame, shame on me. :D There are always these blanks I have to type when using the &.
And you know, these days I completely neglect to Set my objevt variables to Nothing, at end of sub, even at Form_Unload(), too.
I hope I find forgiveness, when once in VB heaven. ;)
Or just GTFO of this crappy programming language and use a real one :P
-
Re: Scrolling to textbox bottom without focus ?
My, my. Hard words. What are YOU doing here, then?
You know, I can't. For professional reasons I have to stick to it. And I have come to love it, too. ;)
-
Re: Scrolling to textbox bottom without focus ?
Quote:
Originally Posted by
WoF
My, my. Hard words. What are YOU doing here, then?
You know, I can't. For professional reasons I have to stick to it. And I have come to love it, too. ;)
Hmm, well I am just starting to learn C++ and VB6 is the language I know like second best (PHP is my specialty and thats not useful for making programs), VB6 is just getting dated and it has all this compatibilty stuff I don't like. but if you need to stick to it for professional reasons I guess it's the best to get as good in it as possible.
-
Re: Scrolling to textbox bottom without focus ?
Right you are. That's what I'm trying to. :)
Sure I also start mingling with C# and looking into VB.NET, but I think I will not be able in near future to migrate the big application I have made in VB6 into one of those. I only hope it will still be supported furthermore by Microsoft operating systems.
-
Re: Scrolling to textbox bottom without focus ?
Ye that's the only problem, microsoft discontinuing the functioning of vb6 apps. I just love C++ because it's multi-platform and it's more advanced then vb6, just need to get the hang of all the complicated OOP stuff etc in C++
-
Re: Scrolling to textbox bottom without focus ?
For me, vb was my first language and my first love because of its rad environment. Then the shocking reality of C was the following semister and even though I know several other languages, I still use these various forums to keep my slowly dying love alive in my mind and don't bother with the rest...
-
Re: Scrolling to textbox bottom without focus ?
Boy, this is very moving. *sniff* ;)
Well, in the past I used to do at least one project each in Fortran Cobol, Pascel (respectively Delphi) and some other (Pl/I for instance, PLM, both completely died away). In VB6 I did my largest project yet. It grew over the years and over the years got more features and less bugs, and now I have to maintain this quality, still expanding it. I can't help loving it.
-
Re: Scrolling to textbox bottom without focus ?
Well here is to you and your race to retirement or should I say I hope you are able to retire before you are forced to upgrade your multiple year vb project to .h e l l :)
Good Luck
-
Re: Scrolling to textbox bottom without focus ?
Here's to you, too. :)
As long as I can get it to run in Windows 7 I shall be save for the next years, I expect.
Although it seems not too impossible to completely migrate to VB.NET within 8 or 12 Months (as I'm doing that all alone), I'd rather avoid this. Automatic migration would surely fail, so I'd have to rewrite it piece by piece.
The problem is, within this time I guess VB2008 is outdated again and Windows FlyFly is coming on strong, get the Beta to test it, old API functions no longer supported .Net Framework 7.0 guides you through everything and even programmers can not anymore do what they want. And then it's time to retire.
-
Re: Scrolling to textbox bottom without focus ?
VS2010 is a totally different animal. Take a look at the BETA
-
Re: Scrolling to textbox bottom without focus ?
Does that mean I can already stuff up my new VS2008 which I hardly ever touched to play with, yet?
-
Re: Scrolling to textbox bottom without focus ?
Not really. The editor is now WPF, so you can zoom and scroll easier. Adds a few features, like Net 4.0
-
Re: Scrolling to textbox bottom without focus ?
*gulp*
Until I get to know VS2008 better, VS2010 will be antiquated, I guess.
-
Re: Scrolling to textbox bottom without focus ?
Not even due until Feb, 2010, I think. Just hit Beta 2
-
Re: Scrolling to textbox bottom without focus ?
You think I should drop my new VS2008 for the 2010 beta version? I don't know.
-
Re: Scrolling to textbox bottom without focus ?
Side by side is the preferred method. I have VS08 and VB6 installed, and VHD of VS2010
-
Re: Scrolling to textbox bottom without focus ?
Quote:
Originally Posted by
dglienna
Not even due until Feb, 2010, I think. Just hit Beta 2
Further on, I think it's round about end of March, AFAIK
Quote:
Originally Posted by
WoF
You think I should drop my new VS2008 for the 2010 beta version? I don't know.
No. Why ¿ I still use VS 2003 and 2005, alongwith 2008. It actually gives you greater perspective about the .NET Framework when starting early with it. I guess I was just fortunate / lucky. I honestly don't see any harm in going on with 2008. The reason why I say so is that it is very very powerful, and the real chances of you ( or most VB.NET 'ers ) being forced into 2010 is slim, as you should just flow into it. :) That's my opinion of course
Quote:
Originally Posted by
WoF
Here's to you, too. :)
As long as I can get it to run in Windows 7 I shall be save for the next years, I expect.
Although it seems not too impossible to completely migrate to VB.NET within 8 or 12 Months (as I'm doing that all alone), I'd rather avoid this. Automatic migration would surely fail, so I'd have to rewrite it piece by piece.
The problem is, within this time I guess VB2008 is outdated again and Windows FlyFly is coming on strong, get the Beta to test it, old API functions no longer supported .Net Framework 7.0 guides you through everything and even programmers can not anymore do what they want. And then it's time to retire.
Correction, sorry WoF, forgive me :blush:
It is PopFly and not FlyFly
There is not .NET Framework 7.0 yet, 2010 is only .NET Framework 4.0.
I can Just imagine how powerful .NET Framework 7 would be in 2015, or whenever it will launch :D
Quote:
Originally Posted by
xeross
Ye that's the only problem, microsoft discontinuing the functioning of vb6 apps. I just love C++ because it's multi-platform and it's more advanced then vb6, just need to get the hang of all the complicated OOP stuff etc in C++
Yes, but VB6 applications are still supported in Windows 7.
Quote:
Originally Posted by
vb5prgrmr
For me, vb was my first language and my first love because of its rad environment. Then the shocking reality of C was the following semister and even though I know several other languages, I still use these various forums to keep my slowly dying love alive in my mind and don't bother with the rest...
It still is my favourite of favourites. VB6, for me, won't die :)
-
Re: Scrolling to textbox bottom without focus ?
@Hannes: Wow, there is actually the name PopFly coming up?
I didn't know that, really. Windows FlyFly and .NET 7.0 were just some fancy names I thought up, out of thin air, to illustrate fancy future products. It wasn't meant serious. :-)
-
Re: Scrolling to textbox bottom without focus ?
Quote:
Originally Posted by
WoF
I didn't know that, really. Windows FlyFly and .NET 7.0 were just some fancy names I thought up, out of thin air, to illustrate fancy future products. It wasn't meant serious. :-)
HAHA! From now on I will call you Nostradamus, sir! :)
What a funny coincident! :lol:
Here is some info on Microsoft PopFly :
http://en.wikipedia.org/wiki/Microsoft_Popfly
Very funky stuff! :thumb:
-
Re: Scrolling to textbox bottom without focus ?
Really, I never heared about that. I fancied Windows FlyFly to be the next funny sounding version after Windows 7, and that .Net was up to then coming to a 7.0 version. :-)
Just some joke.