//--------------------------------------------------------------------------- #include #pragma hdrstop #include "View.h" #include "Main.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPStretchImage" #pragma resource "*.dfm" TViewForm *ViewForm; //--------------------------------------------------------------------------- __fastcall TViewForm::TViewForm(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TViewForm::FormCreate(TObject *Sender) { Tbmp = NULL; if(MainForm->IsReport){ if (Width>Screen->Width) Left = 100; else Left = (Screen->Width-Width)/2; if (Height>Screen->Height) Top = 100; else Top = (Screen->Height-Height)/2; Orient = 0; SType = 0; }else{ zoom = 1; } } //--------------------------------------------------------------------------- void __fastcall TViewForm::FormDestroy(TObject *Sender) { if (Tbmp) { delete Tbmp; Tbmp = NULL; } } //--------------------------------------------------------------------------- void __fastcall TViewForm::Rearrange(int or, int st) { int cw, ch; if (CurrentDoc->Sheet->Orientation == poPortrait) { if (CurrentDoc->Sheet->SheetType == dstA4) { cw = 456; //7.6*60, 10.8*60 ch = 648; } else { cw = 486; //10.8*45, 15.4*45 ch = 693; } } else { if (CurrentDoc->Sheet->SheetType == dstA4) { cw = 648; ch = 456; } else { cw = 693; ch = 486; } } Orient = or; SType = st; ClientWidth = cw; ClientHeight = ch+Panel->Height; Image->Width = cw; Image->Height = ch; // Image->Bitmap->Resize(cw, ch, clWhite); if (Tbmp) { delete Tbmp; Tbmp = NULL; } if ((Tbmp = new TTexpiaBitmap) == NULL) goto fail; if (!(Tbmp->Create(Image->Width, Image->Height, 24))) goto fail; Image->Bitmap = Tbmp; return; fail: if (Tbmp) {delete Tbmp; Tbmp = NULL;} ShowMessage("MakeBitmap Fail"); } //--------------------------------------------------------------------------- void __fastcall TViewForm::spReviewClick(TObject *Sender) { if(MainForm->IsReport){ if (MainForm->ReportDoc->Sheet) ShowBitmap(); }else{ if (MainForm->DesignDoc->Sheet) { if (MainForm->DesignDoc->Sheet->Bitmap) { MainForm->DesignDoc->Sheet->DeleteBitmap(); MainForm->DesignDoc->Sheet->Bitmap = NULL; } ShowBitmap(); } } } //--------------------------------------------------------------------------- void __fastcall TViewForm::ShowBitmap() { HDC hDC = NULL, thDC = NULL; int w, h, or, st; /////////////// HDC dcSrc, dcMemV = NULL, dcForm = NULL; HBITMAP bmMemV = NULL; RECT r; TPDocElement *dp; CurrentDoc = NULL; if(MainForm->IsReport) CurrentDoc = MainForm->ReportDoc; else{ CurrentDoc = MainForm->DesignDoc; } if (CurrentDoc->Sheet) { if (CurrentDoc->Sheet->Bitmap == NULL) { if(!(CurrentDoc->Sheet->MakeBitmap(1, 1))) goto fail; } if (CurrentDoc->Sheet->Orientation == poPortrait) or = 0; else or = 1; if (CurrentDoc->Sheet->SheetType == dstA4) st = 0; else st = 1; if ((Orient != or) || (SType != st) ||(Tbmp == NULL)) { Rearrange(or, st); } w = CurrentDoc->Sheet->Bitmap->Width; h = CurrentDoc->Sheet->Bitmap->Height; ///////////////// if(MainForm->IsReport){ if ((dcSrc = CurrentDoc->Sheet->Bitmap->CreateDC()) == NULL) goto fail; bmMemV = CreateCompatibleBitmap(dcSrc, w, h); dcMemV = CreateCompatibleDC(dcSrc); SelectObject(dcMemV, bmMemV); r = Rect(0, 0, w, h); FillRect(dcMemV, &r, GetStockObject(WHITE_BRUSH)); for (int i = 0; i < CurrentDoc->Sheet->Element->Count; i++) { dp = (TPDocElement *)CurrentDoc->Sheet->Element->Items[i]; dp->PaintForm(dcMemV); } CurrentDoc->Sheet->PaintData(dcMemV, CurrentDoc->Sheet, false); }else{ if ((hDC = CurrentDoc->Sheet->Bitmap->CreateDC()) == NULL) goto fail; } if ((thDC = Image->Bitmap->CreateDC()) == NULL) goto fail; if(MainForm->IsReport){ StretchBlt(thDC, 0, 0, Image->Width, Image->Height, dcMemV, 0, 0, w, h, SRCCOPY); CurrentDoc->Sheet->Bitmap->DeleteDC(dcSrc); Image->Bitmap->DeleteDC(thDC); if (dcMemV) DeleteDC(dcMemV); if (bmMemV) DeleteObject(bmMemV); } else{ StretchBlt(thDC, 0, 0, Image->Width, Image->Height, hDC, 0, 0, w, h, SRCCOPY); Image->Bitmap->DeleteDC(thDC); CurrentDoc->Sheet->Bitmap->DeleteDC(hDC); } Image->Repaint(); //MainForm->ReportRePaint(); //made by k3dogs(20001027) preview formÀÌ ¶ç¿öÁ® ÀÖÀ¸¸é ÀÜ»óÀÌ ³²¾Æ¼­<-- ÀÌÀ¯´Â ¾Ë ¼ö ¾ø´Ù. if (SType) Edit->Text = " A3 Size "; else Edit->Text = " A4 Size "; } else { Visible = false; } return; fail: if (hDC) CurrentDoc->Sheet->Bitmap->DeleteDC(hDC); ShowMessage("Show Fail"); } //---------------------------------------------------------------------------