This is weird...
Try to put a delay in instead of the MsgBox
see what happens.Code:'top of form
Private Declare Sub Sleep Lib "kernel32" (ByVal ms as Long)
'in your code instead of MsgBox
Sleep 1000 'wait 1 second
Printable View
This is weird...
Try to put a delay in instead of the MsgBox
see what happens.Code:'top of form
Private Declare Sub Sleep Lib "kernel32" (ByVal ms as Long)
'in your code instead of MsgBox
Sleep 1000 'wait 1 second
i will try it tommorow in office, but do you think this is good to sleep for 1 second? if it works :(
not working with sleep API, but works onmousemove()
Try shorter delay times if 1 second seems to much. You can find the minimum required delay by trial.
Or just a thought: try a DoEvents instead of the sleep. Maybe that helps already.
What do you mean by onmousemove() ? I don't understand... sorry.
this code is working on mousemove event on RTB like in Win98SE
but i want it to work onCode:Private Sub RTB_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim f&
Dim h%
h = Me.TextHeight("A")
Do
RichBox.SelStart = 0
RichBox.SelStart = Len(RichBox.Text)
f = SendMessage(RichBox.hWnd, EM_GETFIRSTVISIBLELINE, 0&, 0&)
If f > 0 Then RichBox.Height = RichBox.Height + h * f
Loop While f > 0
End Sub
i tried it with sleep API instead of msgbox but does not works :cry:Code:Private Sub RTB_Change()
End Sub
Ok. Let's see if the Change() event fires at all.
Put a Beep command in and then type something. You should hear an acoustic signal every time the contents of the box changes. If the event fires, then put the code you postet into the event.
On the other hand, I see something in the code, which makes me wonder if there is some other error:
Your event handler has the name of RTB_Change(). That makes me think, the name of your RichTextBox is RTB.
BUT in your loop you are adressing a control named RichBox (as was a parameter in my original code as I recall).
Maybe there is the problem. Replace RichBox by RTB?Code:Do
RichBox.SelStart = 0
RichBox.SelStart = Len(RichBox.Text)
f = SendMessage(RichBox.hWnd, EM_GETFIRSTVISIBLELINE, 0&, 0&)
If f > 0 Then RichBox.Height = RichBox.Height + h * f
Loop While f > 0
this is not the problem actully i wrote this manully did not copy it from the code window
this is my real project codeCode:Private Sub RTB_Change()
End Sub
Code:Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const EM_GETFIRSTVISIBLELINE = &HCE
Private Sub RTBQUE_Change()
Dim f As Long
Dim h As Long
h = Me.TextHeight("A")
Do
RTBQUE.SelStart = 0
RTBQUE.SelStart = Len(RTBQUE.Text)
f = SendMessage(RTBQUE.hwnd, EM_GETFIRSTVISIBLELINE, 0&, 0&)
If f > 0 Then RTBQUE.Height = RTBQUE.Height + h * f
Loop While f > 0
End Sub
only this line is not working
Code:RTBQUE.Height = RTBQUE.Height + h * f
if f = SendMessage(RTBQUE.hwnd, EM_GETFIRSTVISIBLELINE, 0&, 0&)
returns a 0, then your line
RTBQUE.Height = RTBQUE.Height + h * f
will also return 0
Put a breakpoint on the sendmessage line, and see what f is once its been executed.
f is also returning 0 in Win98 but it does not return 0 in XP or other OS. I have same copy of example in both OS
I would rather check again in your Win98 if the RICHTX32.ocx is really the same as in XP.
I reported how I replaced it in my Win98 which turned out not to be Win98SE. In my system RICHTX32.ocx was in the windows\system folder...
Please check if your Win98SE does not have a RICHTX32.ocx in the windows\system32 folder.
If it has, replace this with the one from your XP in the same way I described before.
unregister the existing, typing regsvr32 richtx32.ocx /u
copy the XP one to system32
register the new one, typing regsvr32 richtx32.ocx
i did everything you said before of replacing .ocx but that is not working with my Win98SE, richtx32.ocx is located in System folder.
I will try to get access to a Win98SE system at the weekend.
Otherwise I'm at my wit's end, or so it seems... :ehh:
this will not work in Win98SE if the code is just written on RTB_Change() and Rtb is being changed at form_load(), But on the other hand if you call Rtb_change() on Form_Load() or Form_Activate() then you will see code will show Rtb(S) last line, but will not change the height of RTB. Thanks WoF for being with this thread and for your great help :D
You're welcome. *phew* Finally a result.
Because I can't get to a working Win98Se installation currently. Everybody has upgraded to at least WinXP, see? :D