Problem bei Button mit Image
-
Ich möchte einen Button mit einem Bild haben. Dazu habe ich bis jetzt folgenden Quelltext:
imgButton.cpp:
//--------------------------------------------------------------------------- #include <vcl\vcl.h> #pragma hdrstop #include "imgButton.h" //--------------------------------------------------------------------------- static inline TimgButton *ValidCtrCheck() { return new TimgButton(NULL); } //--------------------------------------------------------------------------- __fastcall TimgButton::TimgButton(TComponent* Owner) : TButton(Owner) { buttonImage = new TImage(this); buttonImage->Parent = this; buttonImage->Left = 4; buttonImage->Top = 4; buttonImage->Width = Width-8; buttonImage->Height = Height-8; } //--------------------------------------------------------------------------- namespace Imgbutton { void __fastcall Register() { TComponentClass classes[1] = {__classid(TimgButton)}; RegisterComponents("Zusätzlich", classes, 0); } } //---------------------------------------------------------------------------imgButton.h:
//--------------------------------------------------------------------------- #ifndef imgButtonH #define imgButtonH //--------------------------------------------------------------------------- #include <vcl\SysUtils.hpp> #include <vcl\Controls.hpp> #include <vcl\Classes.hpp> #include <vcl\Forms.hpp> //--------------------------------------------------------------------------- class TimgButton : public TButton { private: protected: TImage *buttonImage; public: __fastcall TimgButton(TComponent* Owner); __published: }; //--------------------------------------------------------------------------- #endifDas Problem ist nun, dass ich nur am Rand daraufklicken kann, weil ansonsten TImage dadrüber ist.
Außerdem werden die Optionen von TImage nicht angezeigt (wenn ich das ganze als Komponente im Borland c++ Builder installiert hab und in einem Neue Form einfüge)
-
Gibt es bei TImage eine OnClick-Methode?
Wenn ja, wie kann ich in ihr die OnClick-Methode vom Button aufrufen?