Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Funktionen in Unterobjekten abändern

Empfohlene Antworten

Veröffentlicht

Hallo Community,

Ich habe folgendes Problem.

Ich habe mir ein eigenes Objekt von einer TScrollBox abgeleitet,

die ich gerne als Basisklasse für meine weiteren Objekte die ich erstellen will

hernehme will.

In dieser Klasse sind also so Routinen wie MouseMove(Verschieben und Skalieren des Objekts) definiert.

Nun auf das Objekt wird ein TImage gelegt.

Und nun habe ich das Problem das in meinem abgeleiteten Objekt das von meinem Basisobjekt abgeleitet ist (Ich hoffe das ist noch verständlich)

ein Bild auf das Image gezeichnet werd.

Nun sollte das Bild aber auch neu gezeichnet werde wenn der User skaliert.

Aber das geht nicht, da das Programm nicht in die Neu zeichenroutine reinläuft, obwohl ich die Variable dafür abfrage.

Hier der MouseMove und alles was dazu gehört aus der BASISKLasse


__fastcall TBasis::TBasis(TComponent* Owner):TScrollBox(Owner)

{

  Parent   	= (TWinControl*)Owner;

  Left 		= 0;

  Top 		= 0;

  Height 	= 50;

  Width 	= 50;

  FBreite 	= 50;

  FHoehe 	= 50;

  Constraints->MinHeight = 30;

  Constraints->MinWidth = 30;


  TimerBlinker = new TTimer(this);


  Img		   = new TImage(this);

  Img->Parent  = this;

  Img->Visible = true;


  Img->OnMouseDown 	= MyMouseDown;

  Img->OnMouseMove 	= MyMouseMove;

  Img->OnMouseUp 	= MyMouseUp;

  Img->OnMouseLeave	= MyMouseLeave;

...


oid __fastcall TBasis::MyMouseMove(TObject *Sender, TShiftState Shift, int X,

	  int Y)

{


	if (!Shift.Contains(ssLeft)  &&  X > Width -10  &&  Y > Height -10)

  {

	Screen->Cursor = crSizeNWSE;

	return;

  }

  else

	if (!Shift.Contains(ssLeft))

	{

	  Screen->Cursor = crDefault;

	  return;

	}


  if (Moving)

  {

	Left = Left + X - AltX;

	if (Left < 0)  Left = 0;

	Top = Top + Y - AltY;

	if (Top < 0)  Top = 0;


	if (Left + Width > Parent->ClientWidth)

	  Left = Parent->ClientWidth - Width;

	if (Top + Height > Parent->ClientHeight)

	  Top = Parent->ClientHeight - Height;

  }


  if (Sizing)

  {

	Width  = Width  + X - AltX;

	if (Left + Width > Parent->ClientWidth)  Width = Parent->ClientWidth - Left;

	Img->Picture->Bitmap->Width = Width;

	AltX = X;


	Height = Height + Y - AltY;

	if (Top + Height > Parent->ClientHeight)  Height = Parent->ClientHeight - Top;

	Img->Picture->Bitmap->Height = Height;

	AltY = Y;


	FBreite = Width;

	FHoehe = Height;

  }

}

Und nun das abgeleitet Objekt wo ich die eigentlich Funktion abändere

void __fastcall TZweiRegelVentil::MyMouseMove(TObject *Sender, 

//Im Konstruktor

OnMouseMove = MyMouseMove;

...

TShiftState Shift, int X, int Y)

{

  TBasis::MyMouseMove(Sender, Shift, X, Y);

  if (Sizing)

    xxxZeichnen(); //NeuZeichnenroutine

}

Ist in dem Aufruf was falsch?

Oder Kann ich irgendwie anders diese ZeichenRoutine aufrufen?

Gruß

Alex

Bearbeitet von aLeXanDer..

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.