Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paint into device context via PrintTo or WM_PRINT #632

Open
Deeem2031 opened this issue Jul 12, 2016 · 5 comments
Open

Paint into device context via PrintTo or WM_PRINT #632

Deeem2031 opened this issue Jul 12, 2016 · 5 comments
Labels
Bug Pull Requests Invited There are no current plans to address the issue, but we would be happy if someone supplies a PR.

Comments

@Deeem2031
Copy link

Hello, i'm trying to use the virtual-treeview and paint a copy of it (and other controls) into a panel.
To accomplish this i used the TWinControl.PaintTo-routine which works well with other controls but the virtual-treeview is missing the header when using PaintTo.
I did some research but couldn't figure out why it is missing. Besides that I tried using WM_PRINT, which seems to work better as it does paint the header but kinda messes with the border.
So both ways aren't perfect.
I uploaded a delphi 10.1 project to demonstrate the problem on my personal webspace (as github seems to refuse it for no apparent reason...): VirtualTreeCopy.zip

@joachimmarder
Copy link
Contributor

joachimmarder commented Jul 12, 2016

as github seems to refuse it for no apparent reason...

Strange, it worked for me. Demo project:
#632.zip

@joachimmarder
Copy link
Contributor

joachimmarder commented Jul 12, 2016

i'm trying to use the virtual-treeview and paint a copy of it (and other controls) into a panel.

May I ask why you want to do that?

I did some research but couldn't figure out why it is missing

This must be related to the fact that TBaseVirtualTree.WMPaint() paints the header using GetDCEx(), and TBaseVirtualTree.Paint() uses Canvas. There is already an if-condition in WMPaint() that checks for csPaintCopy, which is set in case CopyTo()was used. I have no ideas why this was made that way in the past.

@joachimmarder joachimmarder added Bug Pull Requests Invited There are no current plans to address the issue, but we would be happy if someone supplies a PR. labels Jul 12, 2016
@Deeem2031
Copy link
Author

May I ask why you want to do that?

The goal is to fade out the content of a form so the user is aware that he can't use the form right now. To achieve this the content of the form is drawn into a bitmap (with PaintTo) and this image (once mixed with a bit gray) is painted over the form.

This must be related to the fact that TBaseVirtualTree.WMPaint() paints the header using GetDCEx(), and TBaseVirtualTree.Paint() uses Canvas. There is already an if-condition in WMPaint() that checks for csPaintCopy, which is set in case CopyTo() was used.

Yes, if i change the GetDCEx() to something like

if csPaintCopy in ControlState then
  DC := Message.DC
else
  DC := GetDCEx(Handle, 0, DCX_CACHE or DCX_CLIPSIBLINGS or DCX_WINDOW or DCX_VALIDATE);

the Header is being drawn but over the first node/child. Easily reproducible by adding FVT.AddChild(nil); in FormCreate(). So it's not as easy as that because the PaintTree() already messes up the vertical position of all nodes in case you use PaintTo(). This also explains the black bar at the bottom of the PaintTo-Copy.
virtualtree_ 632

@joachimmarder
Copy link
Contributor

This also explains the black bar at the bottom of the PaintTo-Copy.

I also noticed that, I guess the viewport is shifted here, or the client area is defined differently.

@gthorn
Copy link

gthorn commented Sep 2, 2018

I have the same problem as originally reported by Deeem2031. It is apparent any time a VST is PaintTo a bitmap canvas or even if it is on a form and you use GetFormImage to get the form's image onto a canvas. I have an idea that the problem is caused by the fact that the VST ClientRect does not include the vst.Header area.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Pull Requests Invited There are no current plans to address the issue, but we would be happy if someone supplies a PR.
Projects
None yet
Development

No branches or pull requests

3 participants