警告:SYSLIB0003
'SecurityPermission' は旧形式です ('Code Access Security is not supported or honored by the runtime.')
WS_VSCROLL
WS_HSCROLL
を追加します。using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
namespace WindowControlWithScrollBar
{
public partial class MyComponentWithScrollBar : Control
{
// window style constants for scrollbars
public const int WS_VSCROLL = 0x00200000;
public const int WS_HSCROLL = 0x00100000;
public MyComponentWithScrollBar()
{
InitializeComponent();
}
public MyComponentWithScrollBar(IContainer container)
{
container.Add(this);
InitializeComponent();
}
protected override CreateParams CreateParams {
get
{
CreateParams cp = base.CreateParams;
cp.Style |= WS_HSCROLL + WS_VSCROLL;
return cp;
}
}
}
}
WS_VSCROLL
のみを設定します。 protected override CreateParams CreateParams {
get
{
CreateParams cp = base.CreateParams;
cp.Style |= WS_VSCROLL;
return cp;
}
}
WS_HSCROLL
のみを設定します。 protected override CreateParams CreateParams {
get
{
CreateParams cp = base.CreateParams;
cp.Style |= WS_HSCROLL;
return cp;
}
}
Demand()
メソッドを呼び出すコードがありましたが、最新バージョンでは旧形式のワーニングが発生します。using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Security.Permissions;
namespace WinformVisualComponent
{
public partial class VisualComponent : Control
{
// window style constants for scrollbars
public const int WS_VSCROLL = 0x00200000;
public const int WS_HSCROLL = 0x00100000;
public VisualComponent()
{
InitializeComponent();
}
public VisualComponent(IContainer container)
{
container.Add(this);
InitializeComponent();
}
protected override CreateParams CreateParams
{
get
{
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
CreateParams cp = base.CreateParams;
cp.Style |= WS_HSCROLL + WS_VSCROLL;
return cp;
}
}
}
}