안녕하세요..
업체에 넘겨줘야하는데;; 이부분 프린트가 안돼서;;
일주일째 삽질만 죽도록 하고 있는데 해결이 안되는군요...
TScrollBox를 이용해서.. 오브젝트들을 동적으로 생성하구요^^;;
장성호님의 GetPanelImage() 함수를 이용해서..
아래 소스와 같이 이용하였습니다.
허나 가려진 부분은 계속해서 보이지 않구.. 눈에 보이는 부분만 프린트가 되는군요..
참고해야할 함수나? 아님 잘못된부분.. 조언부분 모두 감사히 듣겠습니다.
조언 부탁드려요 ㅠㅠ;
pForm = ScrollBox1;
Graphics::TBitmap *mjbmp= GetPanelImage(pForm);
if (!PrintDialog1->Execute())
return;
TPrinter *prt = Printer();
mjbmp->HandleType = bmDIB;
double h = mjbmp->Height;
double w = mjbmp->Width;
double fct;
double wf;
prt->Orientation = poPortrait;
prt->Title = "EC PRINT";
wf = (double)prt->PageWidth / w;
fct = (double)prt->PageHeight / h;
if (fct > wf) fct = wf;
prt->BeginDoc();
prt->Canvas->StretchDraw(Rect(250, 500, fct*w+250, fct*h+500), mjbmp);
prt->EndDoc();
delete mjbmp;
Graphics::TBitmap * __fastcall GetPanelImage(TScrollBox *Panel)
{
if(Panel==NULL)return NULL;
Graphics::TBitmap *bmp=NULL;
bmp = new Graphics::TBitmap;
bmp->Width=Panel->ClientWidth;
bmp->Height=Panel->ClientHeight;
bmp->Canvas->Brush = Panel->Brush;
bmp->Canvas->FillRect(Panel->ClientRect);
bmp->Canvas->Lock();
try
{
int Ofs=0;
if(GetWindowLong(Panel->Handle, GWL_STYLE) & WS_BORDER )
Ofs = -1; // Don't draw form border
else
Ofs = 0; // There is no border
Panel->PaintTo(bmp->Canvas->Handle, Ofs, Ofs);
}
__finally
{
bmp->Canvas->Unlock();
}
return bmp;
} |