Проблема такая: рисую на Image->Canvas, Image невидимый. А потом функцией Form->Canvas->CopyRect копирую рисунок на форму. Так вот почему-то при изменении размеров формы, видимая часть не изменяется, т.е. рисунок обрубается по краям.
| Код | __fastcall TMainForm::TMainForm(TComponent* Owner) : TForm(Owner) { RoomDepth = 300; LookPoint = -300; } //--------------------------------------------------------------------------- void __fastcall TMainForm::DrawRoomWalls() { TCanvas * mCan = DrawImage->Canvas; int W = ClientWidth/2; int H = ClientHeight/2; int x = W/(1.0 - RoomDepth/LookPoint); int y = H/(1.0 - RoomDepth/LookPoint);
mCan->Brush->Color = clGrayText; mCan->Rectangle(-W, H, W, -H); mCan->Refresh(); mCan->Rectangle(-x, y, x, -y); mCan->MoveTo(-x, y); mCan->LineTo(-W, H); mCan->MoveTo(x, y); mCan->LineTo(W, H); mCan->MoveTo(x, -y); mCan->LineTo(W, -H); mCan->MoveTo(-x, -y); mCan->LineTo(-W, -H); mCan->MoveTo(-x, y); mCan->LineTo(-W, y); mCan->MoveTo(-x, -y); mCan->LineTo(-W, -y); }
//--------------------------------------------------------------------------- void __fastcall TMainForm::FormPaint(TObject *Sender) { HDC mDC = DrawImage->Canvas->Handle; /*Переносим координаты в центр и меняем направление осей*/ SetMapMode(mDC, MM_ISOTROPIC); SetWindowExtEx(mDC, ClientWidth, ClientHeight, 0); SetViewportExtEx(mDC, ClientWidth, -ClientHeight, NULL); SetViewportOrgEx(mDC, ClientWidth/2, ClientHeight/2, NULL); DrawRoomWalls(); TRect rect = ClientRect; TRect srect; srect.Right = ClientWidth/2; srect.Left = -ClientWidth/2; srect.Top = ClientHeight/2; srect.Bottom = -ClientHeight/2; Canvas->CopyRect(rect, DrawImage->Canvas, srect); } //--------------------------------------------------------------------------- void __fastcall TMainForm::FormResize(TObject *Sender) { MainForm->Invalidate(); }
|
|