Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Settings the size of a TPanel for saving and clipboard copy


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Jan 28, 2017 2:59 PM Last Post By: Asger Joergensen
Vaclav Smidl

Posts: 27
Registered: 1/23/11
Settings the size of a TPanel for saving and clipboard copy  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 28, 2017 2:18 PM
Hello,
I have a TPanel component (pSavingPanel ) which contains TStringGrid and TeeChart and other TPanels with captions. TeeChart has client align and other components has top align for example.
Iam using this code to take the screenshot of pSavingPanel:
HDC srcHDC;	TWinControl *winSrc;	Graphics::TBitmap *bmp;
bmp = new Graphics::TBitmap();
winSrc = pSavingPanel;
srcHDC = GetWindowDC( winSrc->Handle);
bmp->Width = winSrc->Width;
bmp->Height = winSrc->Height;
BitBlt(bmp->Canvas->Handle,0,0,bmp->Width,bmp->Height, srcHDC, 0,0,SRCCOPY);
bmp->SaveToFile(FileName+".bmp"); 

Resolution of this screenshot is based on currently rendered size of pSavingPanel. It is not suitable for me.I would like to set user requested resolution for this screenshot because some users have different monitor resolution and screenshots have different size too. I prefer screenshot with same resolution in each time.This is important especially for teechart component which has client alignment and content (axis labels, text position, curve details..) of graph depends on its width and height (resolution).
I achieve this by changing the resolution of my main panel pSavingPanel and then call my screenshot code and then set panel resolution back. Final bitmaps has required resolutions and graph layout is always same but there is bad flickering during changing the main panel.
I found similar question http://stackoverflow.com/questions/34923414/setting-the-size-of-a-tchart-when-saved-copied-to-clipboard. But this is working only for “standalone” teechart.
Is there any method how to do this for panel and their sub components?

Edited by: Vaclav Smidl on Jan 28, 2017 10:19 PM
Asger Joergensen

Posts: 370
Registered: 11/18/08
Re: Settings the size of a TPanel for saving and clipboard copy [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 28, 2017 2:59 PM   in response to: Vaclav Smidl in response to: Vaclav Smidl
Hi Vaclav

If I understand you correctly, my suggestion would be to do your
scaling /resizing on a form that is out of view.

Create panel that say Rendering Image or maybe a TImage showing
the contents of pSavingPanel

and let it replace pSavingPanel

you change Parent of pSavingPanel to the form that is out of view
resize pSavingPanel do your screenshot

Reverse all back to normal.

Maybe look into: TCustomForm::GetFormImage and TWinControl::ScaleBy

Best regards
Asger
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02