المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : problem extending datetimepicker



C++ Programming
09-28-2009, 10:00 PM
googling around i found some extension to the default datetimepicker to make backcolor suitable...what i have till now is:


namespace primoAlpha {

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::Security::Permissions;

public ref class extendedDateTimePicker : DateTimePicker
{
private:
Color _BackColor;
public:
property Color BackColor
{
virtual Color get() override {
return _BackColor;
}
virtual void set(Color value) override {
_BackColor = value;
Invalidate();
}
}

protected:
[SecurityPermission(SecurityAction::Demand, Flags=SecurityPermissionFlag::UnmanagedCode)]
virtual void WndProc( Message% m ) override
{
if ( m.Msg == (int) 0x0014 ) { //WM_ERASEBKGND

Graphics ^g = Graphics::FromHdc(m.WParam);
g->FillRectangle(gcnew SolidBrush(_BackColor),
ClientRectangle);
g->ReleaseHdc();
//g->Dispose();
return;

}
WndProc(m);
}
};

}


the code compile with no error but when i run it gives me an
"An unhandled exception of type 'System.StackOverflowException' occurred in primoAlpha.exe"

any help is really apprecieted, i'm a noob in c++