Canvas und Image im Image
-
Hallo,
ich erstelle zur Laufzeit Images, die ich dann mit Pfeilen verbinde. Direkt in der Form. Nun will ich das in ein PageControl auf eine TabSheet bringen. Dort gibt es kein Canvas. Also habe ich ein Image und will nun meine erstellten Objekte darüber legen, die Pfeile zeichne ich dann auf dem darunterliegenden Image. Wenn ein Image per Drag&Drop bewegt wird zeichne ich alles entsprechend neu.
Nun hab ich aber das Problem, dass nur das Image angezeigt wird, dass bereits zur Entwurfszeit vorhanden ist. Auch BringForont / SendToBack bringt keinen Erfolg.
Hat jemand einen Tip ?
-
Hallo,
wie sieht denn dein Code zum neu Zeichnen nach Drag&Drop aus?
-
Hallo,
Image1 ist das Image, das auf dem TabSheet liegt.
Erstellen (wird auch nicht angezeigt)
img[iCount] = new TImage(this); img[iCount]->Name = "imgT" + IntToStr(iCount); img[iCount]->Parent = this; img[iCount]->Width = iGroesse; img[iCount]->Height = iGroesse; img[iCount]->Top = 100; img[iCount]->Left = 200; iPos[iCount][0] = 100; iPos[iCount][1] = 10; iPos[iCount][2] = 100; iPos[iCount][3] = 10; iPos[iCount][4] = iGroesse; if (iTyp == 2) { Zeichne_Typ2(); } img[iCount]->Stretch = true; img[iCount]->Proportional = true; img[iCount]->OnClick=Image1Click; img[iCount]->OnMouseDown=Image1MouseDown; img[iCount]->OnMouseMove=Image1MouseMove; img[iCount]->OnMouseUp=Image1MouseUp; img[iCount]->Show(); img[iCount]->BringToFront();TfrmMain::Image1MouseUp
frmMain->Image1->Canvas->FillRect(ClientRect); for (int i = 0; i < iAnzImg; i++) { img[i]->Repaint(); } for (int i = 0; i < iRelationCount; i++) { img[iRelation[i][0]]->BringToFront(); img[iRelation[i][1]]->BringToFront(); } for (int i = 0; i < iRelationCount + 1; i++) { frmMain->Image1->Canvas->Pen->Style = psSolid; if (iRelation[i][2] == 2) { frmMain->Image1->Canvas->Pen->Style = psDot; // psDash } // Diverser Code zum Füllen von Arrays frmMain->Image1->Canvas->MoveTo(img[iRelationVonZu[i][0]]->Left, img[iRelationVonZu[i][0]]->Top); frmMain->Image1->Canvas->LineTo(iLeft, iTop); cpic_draw_arrow(img[iRelationVonZu[i][0]]->Left, img[iRelationVonZu[i][0]]->Top, iLeft, iTop, true); }
-
Er stellt es wohl unter dem PageControl da.
-
Ich probiers mal mit meinem eingeschränkten Wissen, das ist nur als Anregung zu sehen:
img[iCount] = new TImage(this); // <= wird hier der korrekte Parent zugewiesen? img[iCount]->Name = "imgT" + IntToStr(iCount); img[iCount]->Parent = this; // <= wird hier der korrekte Parent zugewiesen? img[iCount]->Width = iGroesse; img[iCount]->Height = iGroesse; img[iCount]->Top = 100; // <= vielleicht muss hier die Angabe relativ erfolgen, // wenn der Parent die Form und nicht Tabsheet ist (Tabsheet-Topwert +/- 100)? img[iCount]->Left = 200; // <= siehe Top-Wert iPos[iCount][0] = 100; iPos[iCount][1] = 10; iPos[iCount][2] = 100; iPos[iCount][3] = 10; iPos[iCount][4] = iGroesse; if (iTyp == 2) { Zeichne_Typ2(); } img[iCount]->Stretch = true; img[iCount]->Proportional = true; img[iCount]->OnClick=Image1Click; img[iCount]->OnMouseDown=Image1MouseDown; img[iCount]->OnMouseMove=Image1MouseMove; img[iCount]->OnMouseUp=Image1MouseUp; img[iCount]->Show(); img[iCount]->BringToFront();
-
img[iCount] = new TImage(Image1);
img[iCount]->Name = "imgT" + IntToStr(iCount);
img[iCount]->Parent = TabSheet1;DANKE ! So geht es !