Thanks, Kambiz.
I changed:
PrintPreview= new TPrintPreview(PreviewPanel->Handle);
PrintPreview->Width = PreviewPanel->ClientWidth;
PrintPreview->Height= PreviewPanel->ClientHeight;
to:
PrintPreview= new TPrintPreview(this);
PrintPreview->Parent= PreviewBox;
and the problem is solved.
From the automatically generated Preview.hpp file in C++Builder I thought the constructor parameter was the Parent, but of course it is the Owner.
Johan
By Kambiz on November 30, 2009 at 2:31 pm
This issue does not look like a PrintPreview problem. I think if instead of Preview->Handle, you set the object as parent of PrintPreview, the problem is gine.
You are right about the mistakes in default units functions. Thank you for the hint!
By the way, the forum is a better place to discuss about these issues.
By Johan van Ooijen on November 30, 2009 at 1:30 pm
Hello Kambiz,
I am trying to use your TPrintPreview in a C++Builder 2010 runtime environment. I place the component on a panel using:
PrintPreview= new TPrintPreview(PreviewPanel->Handle);
PrintPreview->Width = PreviewPanel->ClientWidth;
PrintPreview->Height= PreviewPanel->ClientHeight;
and everything seems to work fine, except when the PreviewPanel is resized. After a resize the horizontal scroll bar moves out of sight and the right margin of the vertical scroll bar also moves out of sight. When I investigate the heights of PrintPreview and PreviewPanel, the PrintPreview is usually 26 pixels larger than the PreviewPanel, which explains the problem. I haven’t investigated the widths but something similar but with less pixels difference must be happening there.
Do you think you can solve this?
By the way, I found a possible mistake in
function TPrintPreview.GetSystemDefaultUnits: TUnits;
function TPrintPreview.GetUserDefaultUnits: TUnits;
it looks like the calls to GetLocaleInfo() should be interchanged:
GetSystemDefaultUnits has:
GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, Data, 2);
GetUserDefaultUnits has:
GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_IMEASURE, Data, 2);
Thanks!
Johan
Netherlands