Letractively / lazarus-br

Automatically exported from code.google.com/p/lazarus-br
3 stars 0 forks source link

Illegal type conversion in Win32WSRichBox (Win 7 x 64) #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Reproduce operating environment

2. Attempt to compile exRichEdit

- What is the expected output? 

Successful build.

- What do you see instead?

Illegal type conversion.  Fatal error.

What version of the product are you using? On what operating system?

Laz 1.1, FPC Version 2.6.0, SVN Revision: x86_64-win64-win32/win 64
Windows 7 x64
lazrichedit.lpk 1.5, SVN revision 254, November 28, 2011
At revision: 286

Please provide any additional information below.

I changed these lines in Win32WSRichBox:

161    Stream := TStream(dwCookie^);
       Stream := TStream(dwCookie);

175    s := TStream(dwCookie^);
       s := TStream(dwCookie);

And this line in RichOle:

129    Result:= BOOL(SendMessage(RichEdit, EM_SETOLECALLBACK, 0, 
longint(OleInterface)));

       Result:= BOOL(SendMessage(RichEdit, EM_SETOLECALLBACK, 0, longint(@OleInterface)));

Then it builds. But it throws an "External: SIGSEGV" error on execution.  I 
haven't figured out how to debug the run-time error.

Marty

Original issue reported on code.google.com by martin.x...@gmail.com on 16 Jun 2012 at 5:07

GoogleCodeExporter commented 9 years ago
OK.  It's the line I changed in RichOle that throws the SIGSEGV error.  

From http://www.freepascal.org/docs-html/user/userse63.html

 Hint: Conversion between ordinals and pointers is not portable
    If you typecast a pointer to a longint (or vice-versa), this code will not compile on a machine using 64 bits addressing. 

So I've modified these two functions in RichOle:

function RichEdit_SetOleCallback(RichEdit: HWnd; OleInterface: 
IRichEditOleCallback): BOOL;
begin
  Result:= BOOL(SendMessage(RichEdit, EM_SETOLECALLBACK, 0, Int64(OleInterface)));
end;

function RichEdit_GetOleInterface(RichEdit: HWnd; out OleInterface: 
IRichEditOle): BOOL;
begin
  Result:= BOOL(SendMessage(RichEdit, EM_GETOLEINTERFACE, 0, Int64(OleInterface)));
end;

It built and executed OK.  I haven't done much testing yet, but it's a big step 
forward.  :o)

Original comment by martin.x...@gmail.com on 16 Jun 2012 at 6:07

GoogleCodeExporter commented 9 years ago
Hi,

and tx to reply me.

I desinstalled the win64 version, and with the win32 version, I could install 
the lzRichEdit component.

I got a lot of warnings, about the conversion of Dword, but it's installed.

Otherwise, how can I get the first visible line with this component ?

Original comment by neshiqot...@gmail.com on 17 Jun 2012 at 3:29

GoogleCodeExporter commented 9 years ago
I think if you Google RichEdit+"get first visible line", you will find lots of 
hints.

https://www.google.com/search?q=RichEdit+%22get+first+visible+line%22&ie=utf-8&o
e=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-beta

It's not something I've done myself.

Original comment by martin.x...@gmail.com on 17 Jun 2012 at 5:46

GoogleCodeExporter commented 9 years ago
Stumbled on this while searching for something else:

http://forums.codeguru.com/archive/index.php/t-344721.html

Sounds like what you want.

Note: when the owner comes back here, we will get busted for thread drift.  
This is not an all-purpose forum, but a place for him to get notes about bugs.  
:o)

Original comment by martin.x...@gmail.com on 17 Jun 2012 at 5:58

GoogleCodeExporter commented 9 years ago
OK, TX

Of course, I googled before posting, just adding also Lazarus+RichEdit.
Then the search is much smaller.

Btw, this code FirstLine := RichEdit.Perform(EM_GETFIRSTVISIBLELINE, 0, 0);

was working with a Delphi2005 TRE, and don't work with the present Lazarus RE.

EM_GETFIRSTVISIBLELINE isn't found by Laz compiler, like in the code you give 
me, since it's a C++ code.

Original comment by sagnot.m...@gmail.com on 17 Jun 2012 at 6:54

GoogleCodeExporter commented 9 years ago
Oops.  Sorry about the C++ reference.  

If you think it's a bug in LazRichEdit, it's time to punch the "New Issue" 
button in the upper-left corner of this page.  (I'm frazzled right now with 
trying to get some old RichEditURL routines to work.  As with your case, they 
worked with Delphi x32, but fail now with Lazarus x64.  I'm not convinced it is 
a LazRichEdit bug.  I seem to be all alone in my frustration.  I'm not ready to 
pose the question in a forum because I don't have it well-defined ...).

Original comment by martin.x...@gmail.com on 17 Jun 2012 at 8:25

GoogleCodeExporter commented 9 years ago
Adding windows in the uses, that works good.

But a topline property, like in the Synedit, would be great.

Original comment by sagnot.m...@gmail.com on 17 Jun 2012 at 10:06