-
Code not running Win98
hi all,
once i ask one of my problem in this thread
http://www.codeguru.com/forum/showth...RSTVISIBLELINE
this thread was Resolved but now the problem is, Im using this code
Code:
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
in home i have installed WinXP but in office i have Win98 installed, the problem is in my home this code is running good as i want, but in my office this code is not running.
Is it due to WIN98? And pls tell me how can i run this code in Win98 also, i have to distribute this project. :(
-
Re: Code not running Win98
Maybe Win98 has an older RichTextBox control.
Compare the files RICHTX32.ocx of both operating systems.
You find them in c:\windows\system32 folder. I guess the Win98 one might be older.
To try it, unregister the old ocx, (keep a copy of RICHTX32.ocx as .old to be able to restore matters).
To unregister type regsvr32 /u richtx32.ocx at the dos prompt
copy the newer richtx32.ocx to the windows\system32 folder of your win98 system
Register it: type regsvr32 richtx32.ocx at the dos prompt.
If all was successful you might try your app now in win98.
If you make an installation package using the PDWizard, it will include the new ocx in the package anyway. When installing on Win98 I think the user will be asked if the newer file is to be installed or the older one to be kept. So if your proof has been successful, an installation would be possible on Win98 system.
-
Re: Code not running Win98
i will check it tommorw in office. thanks WoF
-
1 Attachment(s)
Re: Code not running Win98
i hve matched both ocx but they are same, im also uploading them
-
Re: Code not running Win98
Ok, so we obviously are at the wrong end.
The SendMessage() function resides in the user32.dll, maybe this is the traitor.
But replacing the user32.dll sounds a little dangerous to me, since a lot of other functions in Windows OS relate on it.
You could try to replace the dll on an experimental base with the new one from WinXP, but keep the old one in case you have to switch back.
You need not register the dll, simply replace it in the system32 folder.
On the other hand: what exactly is the error?
I remember the problem. You resize a RTB until the first line is visible.
So check what f = SendMessage(RichBox.hWnd, EM_GETFIRSTVISIBLELINE, 0&, 0&) returns with the debugger.
-
Re: Code not running Win98
You don't want to replace the file. They're not the same.
-
Re: Code not running Win98
Thought so. :rolleyes:
Better to go deeper into debugging to find out what's going wrong.
-
Re: Code not running Win98
I think the rtb is different as well, even if you replace it. It doesn't install.
-
Re: Code not running Win98
WoF, if you tell me then i will try to replace the User32.dll from XP to 98. there is no error in the code i have just set the height of RTB to 255 at design time and its height is changes itself by the code you gave me. it works fine in XP but in 98 it does not change its height itself by the above written code.
i will replace the user32 if you tell me to do it in your next post because im afraid to do it :(
dglienna,
did you mean that both ocx files are not same?
actully i did not replaced ocx file from XP to 98, i just checked their properties and version and all, i found everything same even size. thats y i thought they are same. i also downloaded richtx32.ocx from internet and found that one similar to the both of 98 and XP.
i dont know what to do
-
Re: Code not running Win98
-
Re: Code not running Win98
Shall i change SendMessage to SendNotifyMessage Or SendMessageCallback?
in XP code is working fine with these three API functions. shall i try this on 98 also?
-
Re: Code not running Win98
i changed SendMessage to SendNotifyMessage And SendMessageCallback in 98 but still the same problem :cry:
-
Re: Code not running Win98
i got this in MSDN, may be it has some hint
Code:
EM_GETFIRSTVISIBLELINE
This message is sent by an application to determine the uppermost visible line in an edit control.
EM_GETFIRSTVISIBLELINE wParam = 0; lParam = 0;
Parameters
This message has no parameters.
Return Values
The return value is the zero-based index of the uppermost visible line in a multiline edit control. For single-line edit controls, the return value is the zero-based index of the first visible character.
Requirements
Runs on Versions Defined in Include Link to
Windows CE OS 1.0 and later Winuser.h
Note This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.
-
1 Attachment(s)
Re: Code not running Win98
i tried the code in a new project as trial basis on Win98, and it is working, but why it is not working in my real project?
i tell you what problem it is having, i have this code in the Change event of RTB, and in RTB im putting data from another form on Form_Load event, and change event of RTB is Fired but code does not executes, if i type something in RTB then code executes and also code executes if i put above code on CommandButton and click it, but i dont want to click anything, i want it to work on Change Event.
this is the problem i have found yet. Pls solve this :(
-
Re: Code not running Win98
The code in this zip file... is it the code that does not work on Win98?
If so, I'll take it home tonight, where I still have an old Win98 computer and try it.
-
Re: Code not running Win98
yes this is the code you gave me on other thread, and im using this code in my real project and this is working in XP, but not working in 98
pls take this to home and solve this issue :(
-
Re: Code not running Win98
Right.
I went to my old Win98 system, where I found RICHTX32.OCX in windows\system (not in system32).
It is a completely different file. So I opened a Command window and cd'd to \windows\system.
Then regsvr32 richtx32.ocx /u to unregister the old one
ren richtx32.ocx richtx32.old to keep it in case of problems
Then copy the new richtx32.ocx to c:\windows\system
Then regsvr32 richtx32.ocx to successfully register the new ocx
After that your little testprogram worked like a charm.
Check out what Win98 you have. Mine wasn't even Win98SE. So if you have SE, things might be different, but still I think the RICHTX32.ocx is to be replaced in much the same manner as I described.
-
Re: Code not running Win98
WoF,
you gave me some releaf by saying it worked in your Win98 by replacing the ocx, i will do all the steps tommorow. And then i will tell you, what do you mean by Win98SE?
-
Re: Code not running Win98
It was called Windows 98 Second Edition, or short Win98 SE.
There were lots of improvements implemented. I think Networking was more reliable, and whatnot...
There might be differences even in some ocx files, I'm not sure.
But replacing the RICHTX32.ocx should work in SE, too, if it worked in Win98.
-
Re: Code not running Win98
They went from the RTB 2.0 to the RTB 3.0 Specifications. That's the difference, if you want to look them up.
-
Re: Code not running Win98
Quote:
Originally Posted by WoF
Right.
I went to my old Win98 system, where I found RICHTX32.OCX in windows\system (not in system32).
It is a completely different file. So I opened a Command window and cd'd to \windows\system.
Then regsvr32 richtx32.ocx /u to unregister the old one
ren richtx32.ocx richtx32.old to keep it in case of problems
Then copy the new richtx32.ocx to c:\windows\system
Then regsvr32 richtx32.ocx to successfully register the new ocx
After that your little testprogram worked like a charm.
Check out what Win98 you have. Mine wasn't even Win98SE. So if you have SE, things might be different, but still I think the RICHTX32.ocx is to be replaced in much the same manner as I described.
i did everything you said but it is not working in my Win98 :cry: first i unregistered richtx32.ocx by the command you wrote. then rename it to .old after that copy new richtx32.ocx from XP to c:\windows\system and then registered new .ocx using command regsvr32 richtx32.ocx, but my sample program still not working as expected :( . Does it mean my Win98 is Win98SE?
if it is then how to know it is SE
-
Re: Code not running Win98
Right click on My Computer, select Properties. It should say after a few seconds down near the bottom of the window above the memory.
WinSE is second edition, so it should be more advanced than Win98
-
Re: Code not running Win98
yes David,
it is Second Edition, in properties it show
Code:
Microsoft Windows 98
Second Edition
4.10.2222 A
what to do now, but why this code is not working in Change event if RTB is changed on Form_Load event? It works if i type something in RTB and also works if i put this code on and also works on RTB_Mousemove event.
-
Re: Code not running Win98
Does it really work on Win XP at Form_Load()?
Seems to me, it would not work because at Form_Load() the RTB is not yet visible and therefore the code does not grip. So you'd have to make a workaround. If it works if you type in the Box, it is proven that the code is ok.
-
Re: Code not running Win98
yes it is working at form_load on XP because i have this code on this event.
Code:
Private Sub Form_Load()
rtb.Text = rtb.Text + "something"
End Sub
yes code is ok but something strange happening in SE, this code works in my Win98 on mousemove event. shall i move my mouse pointer on RTB on Form_Load(), or i should check this code on Gotfocus?
-
Re: Code not running Win98
You say the relevant code is in the RTB_Change() event?
We can try and move the code from Form_Load() to the Form_Activate event then.
Code:
Private Sub Form_Activate()
Static PassedYet as Boolean
If Not PassedYet Then
RTB.Text = RTB.Text + "something"
PassedYet = True
End If
End Sub
The Static variable is to make sure we execute the code only once, because Form_Activate() can be called everytime the Form regaines Focus.
-
Re: Code not running Win98
still not working code is
Code:
Private Sub Form_Activate()
Static PassedYet as Boolean
If Not PassedYet Then
RTB.Text = RTB.Text + "something"
PassedYet = True
End If
End Sub
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
i think we should move the mouse poiner to Rtb_mousemove on form_load
-
Re: Code not running Win98
Why not simply Call RTBQE_Change in Form_Load() or Form_Activate()?
-
Re: Code not running Win98
-
Re: Code not running Win98
i tried Call RTBQUE_Change() on Form_Load() And Form_Activate() it does not increase the height of the RTB but it moves the code to the Last line. if i use anyother code in place of above required code that code works on Rtb_Change only this code is not working as explected, But it works only on one Condition if i have a msgbox on the first line of RTBQ_CHANGE like
Code:
Private Sub RTBQUE_Change()
MsgBox "Something" 'If this msgbox is removed then code will not work in Win98 if this msgbox is not removed then this code works in Win98 in all expected manner
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&)
MsgBox "F = " & f
If f > 0 Then rtbque.Height = rtbque.Height + h * f
Loop While f > 0
End Sub
-
Re: Code not running Win98
This is weird...
Try to put a delay in instead of the MsgBox
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
see what happens.
-
Re: Code not running Win98
i will try it tommorow in office, but do you think this is good to sleep for 1 second? if it works :(
-
Re: Code not running Win98
not working with sleep API, but works onmousemove()
-
Re: Code not running Win98
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.
-
Re: Code not running Win98
this code is working on mousemove event on RTB like in Win98SE
Code:
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
but i want it to work on
Code:
Private Sub RTB_Change()
End Sub
i tried it with sleep API instead of msgbox but does not works :cry:
-
Re: Code not running Win98
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).
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
Maybe there is the problem. Replace RichBox by RTB?
-
Re: Code not running Win98
this is not the problem actully i wrote this manully did not copy it from the code window
Code:
Private Sub RTB_Change()
End Sub
this is my real project code
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
-
Re: Code not running Win98
only this line is not working
Code:
RTBQUE.Height = RTBQUE.Height + h * f
-
Re: Code not running Win98
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.
-
Re: Code not running Win98
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
-
Re: Code not running Win98
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
-
Re: Code not running Win98
i did everything you said before of replacing .ocx but that is not working with my Win98SE, richtx32.ocx is located in System folder.
-
Re: Code not running Win98
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:
-
Re: Code not running Win98
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
-
Re: Code not running Win98
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
-
Re: Code not running Win98
i think we can drop this issue here, because now a days no one is using 98
-
Re: Code not running Win98
Right. I fully agree. :) Glad to hear that.
-
Re: Code not running Win98
sorry WoF for late reply,
yes this topic is now closed