做一些测试......关于ownerdraw自定义控件。
此代码编译,但崩溃......由于那个'm'是<undefined value>
MySplitContainerControl::WndProc(m);
/*带刹车点,我可以看到一条消息....但是删除刹车点会导致崩溃!
我正在尝试覆盖 Splitcontainer 中的窗口外观。
protected: static int WM_PAINT = 0x000F;
protected: virtual void WndProc(Message% m) override
{
MySplitContainerControl::WndProc(m);
/*Form::WndProc(m);*/
if (m.Msg == WM_PAINT)
{
Graphics^ graphics = Graphics::FromHwnd(this->Handle);
PaintEventArgs^ pe = gcnew PaintEventArgs(graphics, Rectangle(0,0, this->Width, this->Height));
OnPaint(pe);
}
为了得到一个想法,我在这里做的是完整的代码:
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace MySplitContainer {
/// <summary>
/// Summary for MySplitContainerControl
/// </summary>
public ref class MySplitContainerControl : public System::Windows::Forms::SplitContainer
{
public:
MySplitContainerControl(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MySplitContainerControl()
{
if (components)
{
delete components;
}
}
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container^ components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
}
#pragma endregion
protected: static int WM_PAINT = 0x000F;
protected: virtual void WndProc(Message% m) override
{
MySplitContainerControl::WndProc(m);
/*Form::WndProc(m);*/
if (m.Msg == WM_PAINT)
{
Graphics^ graphics = Graphics::FromHwnd(this->Handle);
PaintEventArgs^ pe = gcnew PaintEventArgs(graphics, Rectangle(0,0, this->Width, this->Height));
OnPaint(pe);
}
}
protected: virtual void OnPaint(PaintEventArgs ^e) override
{
}
};
}