Recent

Author Topic: RichMemo.PaintTo not working  (Read 2512 times)

kupferstecher

  • Sr. Member
  • ****
  • Posts: 437
RichMemo.PaintTo not working
« on: April 09, 2020, 04:14:32 pm »
Hello,

in my programm i need to capture a screenshot of each component, including a TRichMemo. For all components it works well, also panels containing subcontrols, but when a RichMemo is captured, than the text is missing and only the background can be seen. This is under Windows. Under Linux with qt it works correctly.

See attached screenshot and minimum example.

I looked into the PaintTo-function, seems a WM_PRINT is used for the capturing.

Does anyone know, where the problem could be?

Thanks!


--
Windows 7 / LinuxMint 19.2
FPC 3.0.4
Lazarus 2.0.6

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2609
    • havefunsoft.com
Re: RichMemo.PaintTo not working
« Reply #1 on: April 14, 2020, 03:56:08 am »
seems like Windows RICHEDIT doesn't make things easier.

The default implementation of WM_PRINT won't work (it's only good to draw borders)
Additional work is required to call EM_FORMATRANGE

please try r7381
« Last Edit: April 14, 2020, 04:39:17 am by skalogryz »
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

kupferstecher

  • Sr. Member
  • ****
  • Posts: 437
Re: RichMemo.PaintTo not working
« Reply #2 on: April 14, 2020, 11:08:09 am »
Hello skalogryz,

thanks a lot!

I just tried and PaintTo works now for the RichMemo directly. Unfortunately, it still doesn't work when a parent component is captured (e.g. a TPanel containing the RichMemo).

See attached screenshot and project.

Regards

winni

  • Hero Member
  • *****
  • Posts: 2421
Re: RichMemo.PaintTo not working
« Reply #3 on: April 14, 2020, 11:42:46 am »
Hi!

Sometime it is necessary to insert an

Application.ProcessMessages

before shooting the screenshot.
The component needs some time to draw it's contents.

If that does not help there is a global workaround for all visible components:

* Make a screenshot of the screen
* Get the topleft and bottomright coordinates of your component
* Convert them with clientToScreen
* Create a TBitmap  of that size
* Do a canvas.copyrect from the screenshot to your TBitmap

Winni

kupferstecher

  • Sr. Member
  • ****
  • Posts: 437
Re: RichMemo.PaintTo not working
« Reply #4 on: April 14, 2020, 12:47:48 pm »
Hello Winni,

the text content of the Edit and RichMemo are set at application start or when editing. The PaintTo on the other hand is called in the button-click-handler, so there should be enough idle time for the application to finish drawing.

The screenshot of the whole screen is not possible in my case, as the captured component isn't neccessarily visible when captured.

I also tried the BitBLT-Function, but when using it (heavily) the program crashes time by time with strange effects on the Windows taskbar (this is not related to the RichMemo component).

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2609
    • havefunsoft.com
Re: RichMemo.PaintTo not working
« Reply #5 on: April 14, 2020, 08:33:07 pm »
please try r7383
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

kupferstecher

  • Sr. Member
  • ****
  • Posts: 437
Re: RichMemo.PaintTo not working
« Reply #6 on: April 14, 2020, 09:36:24 pm »
I just tried, its the same result as with r7381. Works when PaintTo is called directly from the RichMemo (Richmemo1.PaintTo), but not, when called through the parent Panel (Panel1.PaintTo).

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2609
    • havefunsoft.com
Re: RichMemo.PaintTo not working
« Reply #7 on: April 15, 2020, 12:14:49 am »
are you sure you don't have any local changes to the richmemo package?
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

kupferstecher

  • Sr. Member
  • ****
  • Posts: 437
Re: RichMemo.PaintTo not working
« Reply #8 on: April 15, 2020, 12:29:38 am »
I downloaded and installed the package twice to be sure. Also I deleted the lib folder of the project. Tomorrow I'll try again.

kupferstecher

  • Sr. Member
  • ****
  • Posts: 437
Re: RichMemo.PaintTo not working
« Reply #9 on: April 15, 2020, 12:44:27 pm »
Now I tried again, actually the old package was used, more to that below.

The Memo content works now!
There is still an issue with the vertical scroll bar (see attached screenshot), the horizontal one seems to work.
This time I didn't attach a demo project, its enough to change the ScrollBars setting to ssVertical to see the problem. It occurs in both cases, when the PaintTo is called directly and when its called in the parent control.

--
About the installation, its a bit strange. The package richmemopackage.lpk is needed, but can't be installed. The package richmemo_design.lpk in the subdirectory 'ide' requires the richmemopackage and recognizes it once it was opened in Lazarus. After uninstalling the old version of richmemo_design.lpk and reinstalling it, it still used the old version of richmemopackage.lpk. Then I deleted the richmemopackage.lpk, and tried to install richmemo_design.lpk -> richmemopackage.lpk missing. After just opening the correct richmemopackage.lpk in 'menue/package/open package file', the richmemo_design.lpk could be installed.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2609
    • havefunsoft.com
Re: RichMemo.PaintTo not working
« Reply #10 on: April 15, 2020, 01:51:22 pm »
About the installation, its a bit strange.
you need to have both installed.
Your project actually needs "richmemopackage.lpk" to compile.
But richmemo_design.lpk needs to be installed in IDE, in order to be able to edit RichEdit on the form.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

kupferstecher

  • Sr. Member
  • ****
  • Posts: 437
Re: RichMemo.PaintTo not working
« Reply #11 on: April 15, 2020, 03:54:19 pm »
Yes, i understand. Its just that the runtime package can't be installed explicitely. But thats not related to the RichMemo topic, perhaps I open an other topic for that. At least now I know how to install it properly.

kupferstecher

  • Sr. Member
  • ****
  • Posts: 437
Re: RichMemo.PaintTo not working
« Reply #12 on: April 23, 2020, 08:03:08 pm »
Hello skalogryz,

did you have a look at the scrollbar issue? I tried to understand the sources, but my knowledge seems to be not enough. The scrollbars get overlapped by one of the background colors white or blue, but only in text lines. Below the text lines the scrollbar is visible. (Perhaps, thats why the horizontal scrollbar is working). So there could be some wrong dimensions?

 

TinyPortal © 2005-2018